var jpg: TJpegImage; bmp:TBitmap; begin if not OpenPictureDialog1.Execute then exit; if UpperCase(ExtractFileExt(OpenPictureDialog1.FileName))='.BMP' then begin bmp:=TBitmap.Create; bmp.LoadFromFile(OpenPictureDialog1.FileName); showmessage(inttostr(bmp.Width)+' '+inttostr(bmp.Width)) end else begin jpg:=TJpegImage.Create; jpg.LoadFromFile(OpenPictureDialog1.FileName); showmessage(inttostr(jpg.Width)+' '+inttostr(jpg.Width)) end; Bmp或Jpg图片可以用上述方法获取。其它格式的需要另想办法。其实PNG、Gif、TIF等图片格式也是可以做到的,关键是你给分太少。 甚至PSD格式的都可以帮你做出来。至于它们之间格式相互转换,转成AVI都没有问题。
2.使用文件API,filesize即为大小
jpg: TJpegImage;
bmp:TBitmap;
begin
if not OpenPictureDialog1.Execute then exit; if UpperCase(ExtractFileExt(OpenPictureDialog1.FileName))='.BMP' then
begin
bmp:=TBitmap.Create;
bmp.LoadFromFile(OpenPictureDialog1.FileName);
showmessage(inttostr(bmp.Width)+' '+inttostr(bmp.Width))
end
else
begin
jpg:=TJpegImage.Create;
jpg.LoadFromFile(OpenPictureDialog1.FileName);
showmessage(inttostr(jpg.Width)+' '+inttostr(jpg.Width))
end;
Bmp或Jpg图片可以用上述方法获取。其它格式的需要另想办法。其实PNG、Gif、TIF等图片格式也是可以做到的,关键是你给分太少。
甚至PSD格式的都可以帮你做出来。至于它们之间格式相互转换,转成AVI都没有问题。