CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
不看会后悔的Windows XP之经验谈 简单快捷DIY实用家庭影院
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  Web 开发 >  ASP

图片处理的问题呀

楼主wenxingxi()2006-11-03 11:44:23 在 Web 开发 / ASP 提问

<%  
  Function   BinVal2(bin)  
            Dim   i  
            Dim   ret:ret   =   0  
            for   i   =   1   to   lenb(bin)  
                        ret   =   ret   *256   +   ascb(midb(bin,i,1))  
            next  
            BinVal2   =   ret  
  End   Function  
   
  Function   BinVal(bin)  
            Dim   i  
            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  
   
  function   SetImage(IMGPath,width,height,MAX)  
   
  dim   W,H,style,ret(2),bFlag,ADOS  
  'On   Error   Resume   Next  
  Set   Retrieval   =   CreateObject("Microsoft.XMLHTTP")    
  With   Retrieval    
  .Open   "Get","http://www.cnznc.com/"&IMGPath,   False,   "",   ""    
  .Send    
  GetBody   =   .ResponseBody  
  End   With    
  Set   Retrieval   =   Nothing    
   
  Set   ADOS   =   Server.CreateObject("ADODB.Stream")  
  ADOS.Type   =   1    
  ADOS.Mode   =   3    
  ADOS.Open  
   
  ADOS.Write   GetBody  
  ADOS.Position   =   0  
  bFlag   =   ADOS.read(3)  
   
  if   isNull(bFlag)   then    
    ret(0)   =   "unknow"  
    ret(1)   =   0  
    ret(2)   =   0  
  Exit   Function  
  end   if  
   
  '取文件类型和长宽  
   
  select   case   hex(binVal(bFlag))  
  case   "464947":  
    ADOS.read(3)  
    ret(0)   =   "gif"  
    ret(1)   =   BinVal(ADOS.read(2))  
    ret(2)   =   BinVal(ADOS.read(2))  
  case   "FFD8FF":  
    dim   p1  
    do    
    do:   p1   =   binVal(ADOS.Read(1)):   loop   while   p1   =   255   and   not   ADOS.EOS  
    if   p1   >   191   and   p1   <   196   then   exit   do   else   ADOS.read(binval2(ADOS.Read(2))-2)  
    do:p1   =   binVal(ADOS.Read(1)):loop   while   p1   <   255   and   not   ADOS.EOS  
    loop   while   true  
    ADOS.Read(3)  
    ret(0)   =   "jpg"  
    ret(2)   =   binval2(ADOS.Read(2))  
    ret(1)   =   binval2(ADOS.Read(2))  
  ADOS.Close  
  Set   ADOS   =   Nothing  
  end   select  
   
  W=ret(1)  
  H   =   ret(2)  
   
  if   H>W   then  
  if   W>MAX   then  
  style="   style='margin-left:-"   &   cint(MAX-width)/2   &   "px;margin-top:-"   &   cint((cint(MAX-width)*H)/W)/2   &   "px'"  
  SetImage=style&"   width="   &   MAX'   &   "   alt='"   &   W   &   ","   &   H   &   "'"  
  'else  
  'style="   style='margin-left:-"   &   cint(W-width)/2     &   "px;margin-top:-"   &   cint((cint(W-width)*H)/W)   &   "px'"  
  end   if  
  else  
  if   H>MAX   then  
  style="   style='margin-left:-"   &   cint((cint(MAX-height)*W)/H)/2   &   "px;margin-top:-"   &   cint(MAX-height)/2   &   "px'"  
  SetImage=style&"   height="   &   MAX'   &   "   alt='"   &   W   &   ","   &   H   &   "'"  
  else  
  'style="   style='margin-left:-20px;margin-top:-20px'"  
  SetImage=style&"   onload='if(this.height>this.width){if(this.width>"&width&")this.width="&width&";}else{if(this.height>"   &   height   &   "){this.height="   &   height   &   ";}else{this.width="   &   width   &   ";this.height="   &   height   &   ";}}'"  
  end   if  
  end   if  
  end   function  
  %>  
   
  为什么这段代码只能显示图片的一个左上角呀。。请高手回答呀。。急~~~~  
  问题点数:0、回复次数:0Top

相关问题

关键词

得分解答快速导航

  • 帖主:wenxingxi

相关链接

  • Web开发类图书

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo