请教读取图像尺寸问题(100分)

  • 主题发起人 主题发起人 w009
  • 开始时间 开始时间
W

w009

Unregistered / Unconfirmed
GUEST, unregistred user!
请问:在windows目录中,点击到一个图像文件时,即刻显示出图像文件的尺寸和大小,
如何在delphi中得到这图像个文件尺寸?
 
包含在图象文件的头文件信息中
tagBITMAPINFOHEADER = packed record
biSize: DWORD;//位图数据头的长度
biWidth: Longint;//图像宽
biHeight: Longint;//图像高
biPlanes: Word;
biBitCount: Word;
biCompression: DWORD;
biSizeImage: DWORD;
biXPelsPerMeter: Longint;
biYPelsPerMeter: Longint;
biClrUsed: DWORD;
biClrImportant: DWORD;
end;
TBitmapInfoHeader = tagBITMAPINFOHEADER;
 
楼上的朋友,您好
能给些代码吗?我是初学者!谢谢
 
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);
//过程中部分相关的代码
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;
//读取图片的高和宽
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
//根据自己定义的gif格式图片文件头信息读取图片的高和宽
else if (PicName='gif') then begin
ss.Read(gif,sizeof(gif));
phowidth:=gif.ScreenWidth;
phoheight:=gif.ScreenHeight;
end
//根据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;
 
帮顶!

╭=========================================╮

80G海量源代码,控件,书籍全免费狂下不停!

http://www.source520.com

╰=========================================╯
 
多人接受答案了。
 
感谢各位的帮助
 
后退
顶部