Forum Moderators: open
you honestly don't ever have to size your pictures. when the page loads, the browser will automatically display them as their full size. although, the advantage of sizing the pictures is that the page will load much quicker due to the browser not having to figure out the size of the picture, rendering the picture, etc. you have already provided the preset values for the image to be displayed at. i hope i described that accurately....
as far as the LoadPicture() function, i have never used it before. interested to see how it works though.
-Matt
tempMultiplier = 150 / currentwidth
end if
dim NewSize as New Size(CInt(currentwidth * tempMultiplier), CInt(currentheight * tempMultiplier))
return NewSize
End Function
Sub sendFile()
' create New image and bitmap objects. Load the image file and put into a resized bitmap.
dim g as System.Drawing.Image = System.Drawing.Image.FromFile(server.mappath(request("src")))
dim thisFormat=g.rawformat
dim thumbSize as New size
thumbSize=NewthumbSize(g.width,g.height)
dim test as System.Drawing.Image.GetThumbnailImageAbort
dim testb as System.IntPtr
g = new Bitmap(g,thumbSize.width,thumbSize.height)
' Set the contenttype
if thisformat.equals(system.drawing.imaging.imageformat.Gif) then
response.contenttype="image/gif"
else
response.contenttype="image/jpeg"
end if
' send the resized image to the viewer
' output to the user
g.save(response.outputstream, thisFormat) ' output to the user
' tidy up
g.dispose()
'imgOutput.dispose()
end sub
Sub sendError()
' if no height, width, src then output "error"
dim imgOutput as New bitmap(120, 120, pixelformat.format24bpprgb)
dim g as graphics = graphics.fromimage(imgOutput) ' create a New graphic object from the above bmp
g.clear(color.yellow) ' blank the image
g.drawString("ERROR!", New font("verdana",14,fontstyle.bold),systembrushes.windowtext, New pointF(2,2))
' Set the contenttype
response.contenttype="image/gif"
' send the resized image to the viewer
imgOutput.save(response.outputstream, imageformat.gif) ' output to the user
' tidy up
g.dispose()
imgOutput.dispose()
end sub
</script>
<%
' make sure Nothing has gone to the client
response.clear
if request("src")="" then
call sendError()
else
if file.exists(server.mappath(request("src"))) then
call sendFile()
else
call sendError()
end if
end if
response.end
%>