¡¡¡¡ÍøÉÏÓв»ÉÙÉú³ÉËõÂÔͼµÄASP×é¼þ¡£ÈôÄãµÄÐéÄâ¿Õ¼ä²»Ö§³Ö×¢²áÐÂ×é¼þ£¬¿ÉÄÜ»á¸Ð¾õ×Ô¼ºµÄÍøվʧɫ²»ÉÙ¡£ÐÄÇç²»²Å£¬½áºÏÍøÉÏ×ÊԴдÁ˸öÎÞ×é¼þÉú³ÉËõÂÔͼ³ÌÐò£¬½ö¹©²Î¿¼¡£
¡¡¡¡»¹ÊÇÏÈ¿´¿´»ù´¡²¿·Ö°É¡£Ê×ÏÈ£¬ÎÒÃÇÖªµÀÔÚÒ³ÃæÖÐÏÔʾͼƬÊÇÈçÏ´úÂ룺
¡¡¡¡<img src="pic.gif" border="0" width="300" height="260"> ¡¡¡¡srcÊÇͼƬ·¾¶£¬border¿ØÖÆͼƬ±ßÔµ¿í¶È£¬widthÊÇͼƬµÄ³¤¶È£¬heightÊÇͼƬµÄ¸ß¶È¡£ËõÂÔͼµÄÉú³ÉÆäʵ¾ÍÊÇÔÚÔʼ³ß´çÉÏËõ·Å¡£µ«Ò»°ãΪÁ˾¡Á¿ÉÙʧÕ棬ÎÒÃǶ¼»á°´±ÈÀýËõ·Å¡£ÓÚÊÇ£¬»ñȡͼƬµÄ³¤¿í³ß´çÒ²¾Í³ÉÁËÉú³ÉËõÂÔͼµÄÖص㡣
¡¡¡¡ÏÂÃæ±ãÊDZàдÎÞ×é¼þÉú³ÉËõÂÔͼµÄ²½Ö裺
¡¡¡¡1.ÎÞ×é¼þ»ñȡͼƬ´óС
¡¡¡¡ÒÔÇ°¸ÕѧASP²»¾Ãʱ¿´µ½¹ýһƪÀûÓÃASCIIÂëʵÏÖÎÞ×é¼þ»ñȡͼƬ³ß´çµÄÎÄÕ¡£ºóÀ´ÊÔÁËÊÔ£¬·¢ÏÖÔÚ»ñÈ¡jpgÀàͼƬ³ß´çʱ×ÜÊDz»ÄÜÕýÈ·ÏÔʾ£¬ÔÚÍøÉϲéÁ˲飬¾ÓÈ»Óв»ÉÙÍøվתÔØÕâ¸ö³ÌÐò£¬µ«Ã»ÓÐÒ»¼ÒÖ¸³ö´Ë³ÌÐòµÄȱÏÝ£¬Ò²¾Í¸ü̸²»ÉϽâ¾öȱÏݵİ취ÁË¡£ºóÀ´ÓÖgoogleÁËһϣ¬ÖÕÓÚÕÒµ½ÁËһƪ½éÉÜÀûÓÃADODB.stream»ñȡͼƬ³ß´çµÄÎÄÕ£¬°´Æä½éÉܵķ½·¨£¬ÐÞ¸ÄÀïÃæµÄ´úÂëÊÔÁËÊÔ£¬Ð§¹ûÕæµÄ»¹²»´í£¬ÏÖÔÚ½«ÆäÄóöÀ´Óë´ó¼Ò·ÖÏí£º
¡¡¡¡ÀûÓÃADODB.stream»ñȡͼƬ³ß´çµÄͨÓÃÀà <% '//////////// GPS£ºGet Picture Size ////////////// '//////////////ÀûÓÃADODB.stream»ñȡͼƬ³ß´ç////////////// '/////////Cited By Leon£¨ÐÄÇ磩 2005Äê8ÔÂ11ÈÕ//////////
Class GPS Dim aso
Private Sub Class_Initialize Set aso=CreateObject("Adodb.Stream") aso.Mode=3 aso.Type=1 aso.Open End Sub
Private Sub Class_Terminate set aso=nothing End Sub
Private Function Bin2Str(Bin) Dim I, Str For I=1 to LenB(Bin) clow=MidB(Bin,I,1) if AscB(clow)<128 then Str = Str & Chr(ASCB(clow)) Else I=I+1 if I <= LenB(Bin) then Str = Str & Chr(ASCW(MidB(Bin,I,1)&clow)) end If Next Bin2Str = Str End Function
Private Function Num2Str(num,base,lens) 'GPS (2005-8-11) dim ret ret = "" while(num>=base) ret = (num mod base) & ret num = (num - num mod base)/base wend Num2Str = right(string(lens,"0") & num & ret,lens) End Function
Private Function Str2Num(str,base) 'GPS (2005-8-11) dim ret ret = 0 for i=1 to len(str) ret = ret *base + cint(mid(str,i,1)) next Str2Num=ret End Function
Private Function BinVal(bin) 'GPS (2002-8-11) dim ret ret = 0 for i = lenb(bin) to 1 step -1 ret = ret *256 + ascb(midb(bin,i,1)) next BinVal=ret End Function
Private Function BinVal2(bin) 'GPS (2002-8-11) dim ret ret = 0 for i = 1 to lenb(bin) ret = ret *256 + ascb(midb(bin,i,1)) next BinVal2=ret End Function
'///ÒÔÏÂÊǵ÷ÓôúÂë/// Function getImageSize(filespec) 'GPS (2002-8-11) dim ret(3) aso.LoadFromFile(filespec) bFlag=aso.read(3) select case hex(binVal(bFlag)) case "4E5089": aso.read(15) ret(0)="PNG" ret(1)=BinVal2(aso.read(2)) aso.read(2) ret(2)=BinVal2(aso.read(2)) case "464947": aso.read(3) ret(0)="GIF" ret(1)=BinVal(aso.read(2)) ret(2)=BinVal(aso.read(2)) case "535746": aso.read(5) binData=aso.Read(1) sConv=Num2Str(ascb(binData),2 ,8) nBits=Str2Num(left(sConv,5),2) sConv=mid(sConv,6) while(len(sConv)<nBits*4) binData=aso.Read(1) sConv=sConv&Num2Str(ascb(binData),2 ,8) wend ret(0)="SWF" ret(1)=int(abs(Str2Num(mid(sConv,1*nBits+1,nBits),2)-Str2Num(mid(sConv,0*nBits+1,nBits),2))/20) ret(2)=int(abs(Str2Num(mid(sConv,3*nBits+1,nBits),2)-Str2Num(mid(sConv,2*nBits+1,nBits),2))/20) case "FFD8FF": do do: p1=binVal(aso.Read(1)): loop while p1=255 and not aso.EOS if p1>191 and p1<196 then exit do else aso.read(binval2(aso.Read(2))-2) do:p1=binVal(aso.Read(1)):loop while p1<255 and not aso.EOS loop while true aso.Read(3) ret(0)="JPG" ret(2)=binval2(aso.Read(2)) ret(1)=binval2(aso.Read(2)) case else: if left(Bin2Str(bFlag),2)="BM" then aso.Read(15) ret(0)="BMP" ret(1)=binval(aso.Read(4)) ret(2)=binval(aso.Read(4)) else ret(0)="" end if end select ret(3)="width=""" & ret(1) &""" height=""" & ret(2) &"""" getimagesize=ret End Function End Class %> ¡¡¡¡½«ÒÔÉÏ´úÂ븴ÖÆÉú³ÉGPS.aspÎļþ£¬ÕâÑùÎÞ×é¼þ»ñȡͼƬ³ß´çµÄͨÓÃÀà¾ÍOKÁË¡£ ¡¡¡¡2.»ñȡͼƬ·¾¶
¡¡¡¡ÓÉÓÚ²»Ö»Ò»ÕÅͼƬ£¬ÒÔ¼°Í¼Æ¬Ðè·ÖÀà´æ·Å£¬ÎÒÃÇÔÚÊý¾Ý¿âÖÐÉè¼ÆÁËÒ»¸ö´æ·ÅͼƬÏà¶Ô·¾¶µÄ×Ö¶ÎImgURL¡£ÎÒÃÇ°ÑÉÏ´«µÄͼƬ¶¼·ÅÔÚÒ»¸öÃûΪimagesµÄÎļþ¼ÐÖУ¨ÖÁÓÚÈçºÎÎÞ×é¼þÉÏ´«Í¼Æ¬ÐÄÇç¾Í²»ÔÚ¶à˵ÁË£©¡£ÏÖÔÚÎÒÃÇÏÈÉè¼ÆÒ»¸öShowImg.aspÒ³ÃæÓÃÀ´ÏÔʾËõÂÔͼ¼°Ïà¹ØÐÅÏ¢¡£¾ßÌåÉè¼ÆÈçÏ£º
¡¡¡¡Í¼Æ¬£º
¡¡¡¡Í¼Æ¬¸ñʽ£º
¡¡¡¡Í¼Æ¬³ß´ç£º
¡¡¡¡Í¼Æ¬´óС£º
¡¡¡¡µã»÷´ÎÊý£º
¡¡¡¡ÏÂÃ棬ÎÒÃÇ»ñȡͼƬµÄ¾ø¶Ô·¾¶¡£´úÂëÈçÏ£º <% '/////»ñÈ¡ShowImg.aspµÄ¾ø¶Ô·¾¶///// Dim curFile curFile=Server.mappath(Request.servervariables("PATH_INFO")) Dim curfilename,filename
'/////ͼƬÏà¶Ô·¾¶£¨´æÓÚÊý¾Ý¿âÖУ© cufilename=rs("ImgURL")
'/////ÒòΪShowImg.aspÓëimagesÔÚͬһĿ¼£¬ËùÒÔÎÒÃÇÓÃinstrrev»ñÈ¡imagesµÄ·¾¶///// filename=left(curFile,instrrev(curFile,"\"))&cufilename
'/////½¨Á¢GPSÀàʵÌå///// Dim GetPicSize Set GetPicSize=new GPS Set fs=Server.CreateObject("Scripting.FileSystemObject")
'/////»ñȡͼƬÀàÐÍ///// Dim PicSuffixName PicSuffixName=fs.GetExtensionName(filename) Dim PD '//Picture Dimension Dim PWidth,PHeight Select Case PicSuffixName Case "gif","bmp","jpg","png":
'/////µ÷ÓÃGPSͨÓÃÀàÖеÄGetImageSizeº¯Êý»ñȡͼƬ³ß´ç///// PD=GetPicSize.GetImageSize(filename) PWidth=PD(1) '//»ñȡͼƬ¿í¶È PHeight=PD(2) '//»ñȡͼƬ¸ß¶È Case "swf" PD=GetPicSize.GetImageSize(filename) PWidth=PD(1) '//»ñÈ¡Flash¿í¶È PHeight=PD(2) '//»ñÈ¡Flash¸ß¶È Case Else End Select Set fs=Nothing Set GetPicSize=Nothing %>
¡¡¡¡½«ÉÏÃæµÄ´úÂ븴ÖƵ½<body>µÄÉÏÃæ¾ÍOKÁË£¡
¡¡¡¡µ±È»£¬ÓÐÈË»á˵£¬»ñȡ·¾¶²»Ò»¶¨ÒªÓÃPATH_INFO£¬Ö±½ÓÓÃserver.mappath()²»¾Í¿ÉÒÔÁËÂºÇºÇ£¬Âܲ·Çà²Ë¸÷ÓÐËù°®£¬Ö÷ÒªÊÇÎÒÓÃPATH_INFO¿ÉÒÔʵÏÖFSOµÄһЩ¹¦ÄܶøÓÃserver.mappath()ûÓи㶨£¬ËùÒÔһֱʹÓÃÕâ¸ö¡£
¡¡¡¡3.¶¨ÒåËõÂÔͼ³ß´ç
¡¡¡¡Õⲿ·Ö´úÂë¾ÍÊÇÈÊÕß¼ûÈÊ£¬ÖÇÕß¼ûÖÇÁË¡£Ê×ÏÈ£¬ÎÒÃÇÐèÒª¹æ¶¨ËõÂÔͼÏÔʾ³ß´ç·¶Î§£¬Æ©È磺300X260£¬´úÂë¿ÉÒÔÕâÑùд£º <% Dim PXWidth,PXHeight Dim Pp '//Proportion If PWidth=0 Or PWidth="" Then PXWidth=0 PXHeight=0 Else Pp=FormatNumber(PWidth/PHeight,2) '//³¤¿í±È End If If PWidth>=PHeight Then If PWidth>=300 Then PXWidth=300 PXHeight=FormatNumber(300/Pp,0) Else PXWidth=PWidth PXHeight=PHeight End If Else If PHeight>=260 Then PXHeight=260 PXWidth=FormatNumber(260*Pp,0) Else PXWidth=PWidth PXHeight=PHeight End If End If %>
¡¡¡¡½«ÉÏÃæµÄ´úÂë½ô½ÓµÚ¶þ²½Ð´Ï¼´¿É¡£µ÷ÓÃʱ´úÂëÈçÏ£º <img src=<%=curfilename%> border="0" width=<%=PXWidth%> height=<%=PXHeight%>>
¡¡¡¡ÖÁÓÚͼƬ¸ñʽ¿ÉÒÔÓõõ½£¬Í¼Æ¬³ß´ç¿ÉÒÔд³É <% response.write PXWidth&"X"&PXHeight %>
¡¡¡¡Í¼Æ¬´óС¿ÉÒÔÓÃFSO.GetFileSize(filename)À´ÊµÏÖ£¬¶øµã»÷´ÎÊý¿ÉÒÔ¼òµ¥µØÓÃSQLÓï¾äʵÏÖ£¬¾ßÌå±àÂë¾Í²»ÔÙÀÛÊöÁË¡£
¡¡¡¡ÕâÑù£¬Ò»¸öÎÞ×é¼þÉú³ÉËõÂÔͼ³ÌÐò¾ÍдºÃÁË£¬¿ÉÄÜÓеãÄÃÀ´Ö÷Ò壬²»¹ýÖ»Òª´ó¼ÒÄܽ«·½·¨ÕÆÎÕÏàÐÅ»¹ÊÇÓкܴóÌá¸ßµÄ¡£ |