delphi 如何将ACCESS的OLE对象字段存储的BMP图象显示出来  
官方Delphi 学习QQ群: 682628230(三千人)\n
频道

delphi 如何将ACCESS的OLE对象字段存储的BMP图象显示出来


// 显示图象函数
// 返回值表示图象显示是否成功
// 显示图象函数,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;


推荐分享
图文皆来源于网络,内容仅做公益性分享,版权归原作者所有,如有侵权请告知删除!
 

Copyright © 2014 DelphiW.com 开发 源码 文档 技巧 All Rights Reserved
晋ICP备14006235号-8 晋公网安备 14108102000087号

执行时间: 0.039211988449097 seconds