Omskrivning fra C til VB
Hej kan i hjælpe mig med en omskrivning af denne kode fra C til VB.<%@ Page language="c#"%>
<%@ Import Namespace="System.Drawing"%>
<%@ Import Namespace="System.Drawing.Imaging"%>
<%@ Import Namespace="System.Drawing.Drawing2D"%>
<HTML>
<HEAD>
<title>Scaling Images</title>
<script language="C#" runat="server">
bool ServerValidation()
{
Regex r = new Regex(".*\\.(jpg|gif|png)$", RegexOptions.IgnoreCase|RegexOptions.Compiled);
return r.IsMatch(File1.PostedFile.FileName);
}
void Button1_Click(object Source, EventArgs e)
{
if (File1.PostedFile != null)
{
if(ServerValidation())
{
try
{
Bitmap BitmapSource = new Bitmap(File1.PostedFile.InputStream);
int DestWidth = BitmapSource.Width ;
int DestHeight = BitmapSource.Height;
Bitmap BitmapDest = new Bitmap(DestWidth,DestHeight);
Graphics bmpGraphics = Graphics.FromImage(BitmapDest);
// set Drawing Quality
bmpGraphics.InterpolationMode = InterpolationMode.High;
Rectangle compressionRectangle = new Rectangle(0, 0, DestWidth, DestHeight);
bmpGraphics.DrawImage(BitmapSource, compressionRectangle);
//BitmapDest.Save(Response.OutputStream, ImageFormat.Jpeg);
BitmapDest.Save((Server.MapPath("images/slideshow/Test.jpeg")), ImageFormat.Jpeg);
BitmapSource.Save((Server.MapPath("images/Test.jpeg")), ImageFormat.Jpeg);
}
catch (Exception exc)
{
Span1.InnerHtml = "Error Uploading file <b>" + exc.ToString();
}
}
else
{
RequiredFieldValidator.Text = "<br> Vælg en fil af typen jpg, gif eller png<br>";
}
}
}
</script>
</HEAD>
<body>