<script runat="server">
Sub sendFile()
dim g as System.Drawing.Image = System.Drawing.Image.FromFile(server.mappath(request("src")))
dim thisFormat=g.rawformat
dim imgOutput as New Bitmap(g, cint(request("width")), cint(request("height")))
if thisformat.equals(system.drawing.imaging.imageformat.Gif) then
response.contenttype="image/gif"
else
response.contenttype="image/jpeg"
end if
imgOutput.save(response.outputstream, thisformat)
g.dispose()
imgOutput.dispose()
end sub
Sub sendError()
dim imgOutput as New bitmap(120, 120, pixelformat.format24bpprgb)
dim g as graphics = graphics.fromimage(imgOutput)
g.clear(color.yellow)
g.drawString("毛病!", New font("黑体",14,fontstyle.bold),systembrushes.windowtext, New pointF(2,2))
response.contenttype="image/gif"
imgOutput.save(response.outputstream, imageformat.gif)
g.dispose()
imgOutput.dispose()
end sub
</script>
<%
response.clear
if request("src")="" or request("height")="" or request("width")="" then
call sendError()
else
if file.exists(server.mappath(request("src"))) then
call sendFile()
else
call sendError()
end if
end if
response.end
%>
Function NewthumbSize(currentwidth, currentheight)
dim tempMultiplier as Double
if currentheight > currentwidth then
tempMultiplier = 200 / currentheight
Else
tempMultiplier = 200 / currentwidth
end if
dim NewSize as New Size(CInt(currentwidth * tempMultiplier), CInt(currentheight * tempMultiplier))
return NewSize
End Function