如何从Delphi中的Blob字段中提取jpg并在TImage中显示? [英] How to pull jpg from a Blob Field in Delphi and display in a TImage?

查看:94
本文介绍了如何从Delphi中的Blob字段中提取jpg并在TImage中显示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码,但在TImage中不显示jpg:

I have the following code, but it doesn't display the jpg in the TImage:

  sf := TfrmSplash.Create(nil);
  ms := TMemoryStream.Create;
  try
    bf := TBlobField(dbfuncs.tblBlobs.FieldByName('BBlob'));
    bf.SaveToStream(ms);
    ms.Position := 0;
    sf.imgDisplay.Picture.Graphic.LoadFromStream(ms);
    sf.Show;
    Sleep(2000);
  finally
    ms.Free;
    sf.Free;
  end;

为什么不起作用?我在涉及的两种形式的uses子句中都有jpeg。但是图像中什么也没有显示。.

Why doesn't this work? I have jpeg in the uses clause of both forms involved. But nothing is displayed in the image.....

推荐答案

您不必先将其流化为TJPEG,然后将其分配给TImage?我在这里没有可用的代码(尽管以后可以进行挖掘),但是当我过去这样做时,我很确定我必须做类似的事情

Don't you have to stream it into a TJPEG first, then assign that into the TImage? I don't have code handy here (though can dig it out later) but when I've done this in the past I'm pretty sure I have to do something like

MyJPeg.LoadFromStream

其后是

MyPicture.Graphic.Bitmap.Assign(MyJPeg)...?

这篇关于如何从Delphi中的Blob字段中提取jpg并在TImage中显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆