Delphi

本类阅读TOP10

·分布式网络考试系统原型分析及实现
·游戏外挂设计技术探讨①
·使用HOOK随心监视Windows
·Delphi 水晶报表打包解决
·试题库开发中非文本数据的处理
·如何将几个DBGRID里的内容导入同一个EXCEL表中....的问题
·如何使用Delphi设计强大的服务器程序
·工人线程中关闭窗体的实现
·用DLL方式封装MDI子窗体。
·支持XP下托盘栏气球提示的托盘单元

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
怎样读出不同格式图形的高和宽

作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站

 

最近开发的一个系统,需根据用户提交的图片(图片文件以字符流的形式从客户机传到服务器)读出该图片的高和宽,通过下列代码实现了该功能,现在拿出来给大家参考。
……
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




相关文章

相关软件