发信人: d_fang()
整理人: soaringbird(2001-08-09 19:27:54), 站内信件
|
【 在 netunite 的大作中提到:】
:
:......
读出该图片的高和宽,通过下列代码实现了该功能
……
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;
---- 欢迎访问方文设计室!!
立即下载data2000,包含1000多个delphi技巧!!!
|
|