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;

相关阅读 >>

Delphi入门语法

Delphi 保证当前程序显示在最前

Delphi url取得文件名

Delphi判断ip地址是否正确

Delphi 在内存中直接运行exe类型的资源文件

Delphi xe5 中tmemo控件的应用――for android

Delphi 提升进程权限到sedebugprivilege

Delphi 实现 图灵机器人api(idhttp post )

Delphi 判断当前网络连接方式

Delphi 拷贝dbgrid当前行

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...