【发布时间】:2023-02-26 05:32:53
【问题描述】:
有人知道如何获取图片并将其存储在流中?
我的目标是在内存中使用它,并在 TImage 中向用户显示。
使用Ole保存图片文件图像可以保存为任何格式(PNG、BMP、JPG 等),但是保存在磁盘上。有人知道如何获取 IPicture 并将其保存到流中并将其放在 TImage 上吗?
我试过这种方式
// Obtaining the IPicture
var LPicture := DPBiometria.DPSC.ConvertToPicture(pSample) as IPicture;
// This line saves the image correctly, but i dont want this way.
// OleSavePictureFile(IPictureDisp(LPicture), 'D:\teste.jpg');
// Trying stores it on the stream and put on a bitmap or show on a TImage
var LStream := TBytesStream.Create;
var LOleG := TOleGraphic.Create;
LOleG.Picture := LPicture;
LOleG.SaveToStream(LStream);
// When loading it on a TImage, it doesnt shows...
// When loadgin on a TBitMap or TJPegImage, and trying to
// save to a file, its saved with 0 bytes.
// The TImage doesnt shows the image
SomeTImage.LoadFromFile(LStream);
// Saved with 0 bytes
var Lbmp := TBitmap.Create;
Lbmp.LoadFromStream(LStream);
Lbmp.SaveToFile('D:\testeStream.bmp');
谢谢你的帮助
【问题讨论】:
-
您很可能也需要
IStream,而不是TStream。您的DPBiometria是如何声明的,以便人们实际上能够重新编译您的代码示例?
标签: delphi com delphi-10.4-sydney