tony
2006-09-12 08:20:08 UTC
œÐ°Ý,nŠpŠóŒg€~¯àšÏÁY¹ÏÅܱo²MŽ·.ÁÂÁÂ!
<%@ WebHandler Language="VB" Class="GetImage" %>
Imports System.Drawing
Imports System.Drawing.Imaging
Public Class GetImage : Implements IHttpHandler
Public Sub ProcessRequest(ByVal context As HttpContext) Implements
IHttpHandler.ProcessRequest
Dim StrImageId As String = context.Request.QueryString("pic")
Dim StrPath As String = context.Server.MapPath("Image/PicPro/")
Dim ImgWid As Integer
Dim ImgHig As Integer
Dim Image As System.Drawing.Image = Nothing
Dim Percent As Double
Dim TargetWid As Integer = context.Request.QueryString("wid")
Dim TargetHig As Integer
'Dim Image As System.Web.UI.WebControls.Image
If File.Exists(StrPath & StrImageId & ".jpg") Then
Image = Bitmap.FromFile(StrPath & StrImageId & ".jpg")
ImgWid = Image.Width
ImgHig = Image.Height
Percent = TargetWid / ImgWid
TargetHig = Int(ImgHig * Percent)
Image = Image.GetThumbnailImage(TargetWid, TargetHig, Nothing,
IntPtr.Zero)
Image.Save(context.Response.OutputStream, ImageFormat.Jpeg)
End If
context.Response.Flush()
End Sub
Public ReadOnly Property IsReusable() As Boolean Implements
IHttpHandler.IsReusable
Get
Return False
End Get
End Property
End Class
<%@ WebHandler Language="VB" Class="GetImage" %>
Imports System.Drawing
Imports System.Drawing.Imaging
Public Class GetImage : Implements IHttpHandler
Public Sub ProcessRequest(ByVal context As HttpContext) Implements
IHttpHandler.ProcessRequest
Dim StrImageId As String = context.Request.QueryString("pic")
Dim StrPath As String = context.Server.MapPath("Image/PicPro/")
Dim ImgWid As Integer
Dim ImgHig As Integer
Dim Image As System.Drawing.Image = Nothing
Dim Percent As Double
Dim TargetWid As Integer = context.Request.QueryString("wid")
Dim TargetHig As Integer
'Dim Image As System.Web.UI.WebControls.Image
If File.Exists(StrPath & StrImageId & ".jpg") Then
Image = Bitmap.FromFile(StrPath & StrImageId & ".jpg")
ImgWid = Image.Width
ImgHig = Image.Height
Percent = TargetWid / ImgWid
TargetHig = Int(ImgHig * Percent)
Image = Image.GetThumbnailImage(TargetWid, TargetHig, Nothing,
IntPtr.Zero)
Image.Save(context.Response.OutputStream, ImageFormat.Jpeg)
End If
context.Response.Flush()
End Sub
Public ReadOnly Property IsReusable() As Boolean Implements
IHttpHandler.IsReusable
Get
Return False
End Get
End Property
End Class