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;