<% ' import all relevant namespaces %>
<%@ Page Language="VB" Debug="true" %>
 <%@ import Namespace =namespace="System" %>
 <%@ import Namespace =namespace="System.Drawing" %>
 <%@ import Namespace =namespace="System.Drawing.Imaging" %>
 <%@ import Namespace =namespace="System.IO" %>
<script runat="server">
Dim imageWidth = 640
Dim imageHeight = 480
 Sub Page_Load()Sub Page_Load(s as object, e as eventargs)
Try
dim g as System.Drawing.Image = System.Drawing.Image.FromFile(server.mappath("Img/Golfd.jpg"))
dim thisFormat=g.rawformat
dim imgOutput as New Bitmap(g, NewthumbSize(imageWidth,imageHeight))
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()
Catch
Call sendError()
End Try
End Sub
 Function NewthumbSize()Function NewthumbSize(currentwidth, currentheight)
dim tempMultiplier as Double
if currentheight > currentwidth then
tempMultiplier = 300 / currentheight
Else
tempMultiplier = 300 / currentwidth
end if
dim NewSize as New Size(CInt(currentwidth * tempMultiplier), CInt(currentheight * tempMultiplier))
return NewSize
End Function
 Sub sendError()Sub sendError()
dim imgOutput as New bitmap(120, 30, pixelformat.format24bpprgb)
dim g as graphics = graphics.fromimage(imgOutput)
g.clear(color.yellow)
g.drawString("Wrong£¡", 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>
发表于
2005-04-20 15:38
菲一打
阅读( 365)
评论()
收藏
举报
|