本文整理自网络,侵删。
// 显示图象函数
// 返回值表示图象显示是否成功
// 显示图象函数,pictype 可为:'BMP' 'JPG' 'JPEG'
function ViewPicture(img:TImage; query:TADOQuery; fieldname:String; pictype:String):boolean;
var
jpg : TJpegImage;
ts : TStream;
gif : TGifImage;
begin
result := false;
pictype := LowerCase(pictype);
try
ts := query.CreateBlobStream(query.FieldByName(fieldname),bmRead);
if ts.Size=0 then exit;
if (pictype='bmp') or (pictype='image/bmp') then
begin
try
img.Picture.Bitmap.LoadFromStream(ts);
result := true;
except
end;
end;
if (pictype='jpg') or (pictype='image/pjpeg') then
begin
jpg := TJpegImage.Create;
try
jpg.LoadFromStream(ts);
img.Picture.Bitmap.Assign(jpg);
result:=true;
finally
jpg.Free;
end;
end;
if (pictype='gif') or (pictype='image/gif') then
begin
gif := TGifImage.Create;
try
gif.LoadFromStream(ts);
img.Picture.Bitmap.Assign(gif);
result:=true;
finally
gif.Free;
end;
end;
ts.Free;
except end;
end;
相关阅读 >>
Delphi xe5 中tmemo控件的应用――for android
Delphi 提升进程权限到sedebugprivilege
Delphi 实现 图灵机器人api(idhttp post )
更多相关阅读请进入《Delphi》频道 >>