Forums
This topic is locked
Need help with some aspx code, anyone can you help
Posted 12 Sep 2005 03:11:17
1
has voted
12 Sep 2005 03:11:17 Calum MacRae posted:
i used code found on different websites and tried to put them together, didn't work. Could someone please go over my code and check it. What it is suppose to do is to resize a image with request.querystrings in it and create a thumbnail of the image, 230 x 230. The user uploads using asp, then is put onto a aspx page to be resized. Sounds the long way round but i have resons for this.Here is the code guys;
@ Page Language="VB" Debug="true"
@ import Namespace="System.IO"
@ import Namespace="System.Drawing.Imaging"
@ import Namespace="System.Drawing"
script language="VB" runat="server"
Dim uploadSucess As Boolean
Dim strFileName As String
Dim filepath as String
Sub btnUpload_Click(sender As Object, e As EventArgs)
Dim imageUrl as String = Request.QueryString("img"
imageurl = strfilename
Dim strLongFilePath As String = imageUrl
strFileName = imageUrl
Dim bm as Bitmap = System.Drawing.Image.FromFile(strFileName)
'Declare Thumbnails Height and Width
Dim newWidth as Integer = 230
Dim newHeight as Integer = 230
Response.Write("doneresize"
'Create the new image as a blank bitmap
Dim resized as Bitmap = new Bitmap(newWidth,newHeight)
'Create a new graphics object with the contents of the origional image
Dim g as Graphics = Graphics.FromImage(resized)
'Resize graphics object to fit onto the resized image
g.DrawImage(bm, new Rectangle(0,0,resized.Width,resized.Height),0,0,bm.Width,bm.Height,GraphicsUnit.Pixel)
'Get rid of the evidence
g.Dispose()
'Create new path and filename for the resized image
Dim newStrFileName as String = FilePath & "Thumbnails/T_" & strFileName
'Save the new image to the same folder as the origional
resized.Save(newStrFileName,ImageFormat.Jpeg)
End sub
script
sorry about the layout!<img src=../images/dmxzone/forum/icon_smile_blush.gif border=0 align=middle>
Edited by - CmacRae on 12 Sep 2005 18:25:59
Edited by - CmacRae on 12 Sep 2005 18:26:11