.net生成缩略图的CODE

http://www.guobog.com

是我自己的小站,最早用L-BLOG免费BLOG ASP程序,没用多久发现好几个重要漏洞。
站外提交漏洞: http://www.guoblog.com/blogview.asp?logID=254
引用通告漏洞: http://www.guoblog.com/blogview.asp?logID=321
网络书签漏洞: http://www.guoblog.com/blogview.asp?logID=268

以后我就用以前学习的.net开发自己的BLOG程序,虽然做完了,可和.TEXT一比唉还不如用人家的呢。国内就没有好些的原创.net blog程序,只等国外的提供出原码然后就是一个字改,改完后有的都觉的这是自己做的程序了,晕。什么时候才进步啊。

下面脚本是参考一些.net生成缩略图的思路做的脚本。那个乱啊。高手帮我改改。http://www.guoblog.com/blognet/
http://www.guoblog.com/blogphoto.asp 功能是实现了,希望优化些。

<%@ Page Language="VB" Debug="true" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Web" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
<script runat="server">
  
Sub Page_Load(ByVal sender As System.ObjectByVal e As System.EventArgs)
    GetThumbNail
  
End Sub


 
Sub GetThumbNail()
    
Dim guo,vPicMax As System.Drawing.Image
    
dim pfile,pfiled,vTmpPicName as string
    
dim PicFormat As System.Drawing.Imaging.ImageFormat
    
Dim Myfile As IO.File
    pfile
=request.querystring("file")
    pfiled
=request.querystring("filed")
    
'upfiles = pfile.Substring(pfile.LastIndexOf("\\") + 1)
    'pfilename=pfile.substring(pfile.lastindexOf(".")+1)
    'response.write (upfiles)
    'response.write (pfilename)
    guo=System.Drawing.Image.fromfile(server.mappath( pfiled & pfile ))
        
If Not (guo.RawFormat Is PicFormat.Gif Or guo.RawFormat Is PicFormat.Png) Then
                vTmpPicName 
= System.Guid.NewGuid.ToString() & ".png"
                vPicMax = guo
                guo.Save(HttpContext.Current.Server.MapPath(pfiled) 
& vTmpPicName, PicFormat.Png)
                vPicMax.Dispose()
                guo 
= System.Drawing.Image.FromFile(HttpContext.Current.Server.MapPath(pfiled) & vTmpPicName)
        
End If
        
'保存小文件=================================================================
        GetMinPic(guo,140,160).Save(HttpContext.Current.Server.MapPath(pfiled) & "140X105" & pfile, PicFormat.Jpeg)
        GetMinPic(guo,
320,240).Save(HttpContext.Current.Server.MapPath(pfiled) & "320X240" & pfile, PicFormat.Jpeg)
        GetMinPic(guo,
500,450).Save(HttpContext.Current.Server.MapPath(pfiled) & "500X450" & pfile, PicFormat.Jpeg)
        GetMinPic(guo,
102,101).Save(HttpContext.Current.Server.MapPath(pfiled) & "102X101" & pfile, PicFormat.Jpeg)
        GUO.Dispose    
        
'删除临时png文件=================================================================
        If vTmpPicName <> "" Then Myfile.Delete(HttpContext.Current.Server.MapPath(pfiled) & vTmpPicName)
  
End Sub

  
Private Function GetMinPic(ByVal MaxPic As System.Drawing.Image,ByVal PhotoW As Integer,ByVal PhotoH As IntegerAs System.Drawing.Image
    
dim w,h,nw,nh as integer
    w
=MaxPic.width
    h
=MaxPic.height
    
if w>then
       nw 
= PhotoW
       nh 
= h/w*nw
    
else
       nh 
= PhotoH
       nw 
= w/h*nh
    
end if
    
if nw>=and nh>=then
       
Return MaxPic.GetThumbnailImage(w, h, NothingNew System.IntPtr())
       
else
       
Return MaxPic.GetThumbnailImage(nw, nh, NothingNew System.IntPtr())  
    
end if
End Function

</script>

posted on 2005-03-04 16:19  Guo's Blog--老鼠爱大米  阅读(1977)  评论(1)    收藏  举报

导航