中国IT动力,最新最全的IT技术教程
最新100篇 | 推荐100篇 | 专题100篇 | 排行榜 | 搜索 | 在线API文档 | 网通镜像
首 页 | 程序开发 | 操作系统 | 软件应用 | 图形图象 | 网络应用 | 精文荟萃 | 教育认证 | 硬件维护 | 未整理篇 | 站长教程
ASP JS PHP工程 ASP.NET 网站建设 UML J2EESUN .NET VC VB VFP 网络维护 数据库 DB2 SQL2000 Oracle Mysql
服务器 Win2000 Office C DreamWeaver FireWorks Flash PhotoShop 上网宝典 CorelDraw 协议大全 网络安全 微软认证
硬件维护  CPU  主板  硬盘  内存  显卡  显示器  键盘鼠标  声卡音箱  打印机  机箱电源  BIOS  网卡  C#  Java  Delphi  vs.net2005
  当前位置:> 程序开发 > 编程语言 > Delphi > 图形/图像
怎样读出不同格式图形的高和宽
作者:aton 时间:2001-10-29 10:37 出处:互联网 责编:chinaitpower
              摘要:怎样读出不同格式图形的高和宽

 

最近开发的一个系统,需根据用户提交的图片(图片文件以字符流的形式从客户机传到服务器)读出该图片的高和宽,通过下列代码实现了该功能,现在拿出来给大家参考。
……
type
  TGIFHeader = packed record
    Signature: array[0..2] of Char;
    Version: array[0..2] of Char;
    ScreenWidth: Word;
    ScreenHeight: Word;
    PackedFields,
    BackgroundColorIndex,
    AspectRatio: Byte;
  end;
    TGIFInfoHeader = TGIFHeader;
……   
procedure Ttempphoto.AddMediaRec(out content_no, succed, errno,
  errmsg: OleVariant; const PicName, Title, Author, Theme, PublishDate,
  KeyWord: WideString; Length: SYSUINT; const Memo: WideString; PicHight,
  PicWidth, Color_Pan: SYSUINT; content: OleVariant; PayNo: SYSINT;
  const GroupNo: WideString);
file://过程中部分相关的代码
var
    p : pwidechar;
    bb : string;
    tempchar : integer;
    mm : SYSUINT;
    jpeg: TJPEGImage;
    Gif:TGIFInfoHeader;
    bmp:TBitmapInfoHeader;
    phowidth: integer;
    Phoheight: integer;
    ss:TStringStream;
    fileheader:TBitmapfileheader;
begin
……
      
       p := Tvardata(content).volestr;
       setlength(bb,Length);
       mm := 1;
       while mm<=Length do
         begin
           tempchar := integer(p[(mm-1) div 2]);
           bb[mm]:= chr(tempchar mod 256);
           if mm           mm := mm+2;
         end;
       file://读取图片的高和宽
       ss:=tstringstream.Create(bb);
       if ((PicName='jpg')or(PicName='jpeg')) then begin
           jpeg:= TJPEGImage.Create;//需uses jpeg
           jpeg.LoadFromStream(ss);
           phowidth:=jpeg.width;
           phoheight:=jpeg.height;
           jpeg.free;
        end
        file://根据自己定义的gif格式图片文件头信息读取图片的高和宽
        else if (PicName='gif') then begin
             ss.Read(gif,sizeof(gif));
             phowidth:=gif.ScreenWidth;
             phoheight:=gif.ScreenHeight;
        end
        file://根据windows单元定义的bmp格式图片文件头信息读取图片的高和宽
        else if (PicName='bmp') then begin
             ss.Read(fileheader,sizeof(fileheader));       
             ss.Read(bmp,sizeof(bmp));
             phowidth:=bmp.biWidth;
             phoheight:=bmp.biHeight;
        end
        else begin
        end;
            ss.Free;
……           
end;

更详细资料请访问我的个人主页http://aton.126.com

关闭本页
 
首页 | 投资与合作 | 服务条款 | 隐私政策 | 收藏本站 | 设为首页 | 新用户注册 | 免责声明 | 使用帮助
Copyright ©2005-2008 chinaitpower.com All rights reserved. www.chinaitpower.com 版权所有