0

I am trying to show a previously saved image in a blob field with Delphi's TImageViewer component. I am developing with Delphi 10.1 Berlin.

The image does not fit in the TImageViewer component, even using the BestFit command, as shown below. The image is bigger than the component. But it fits in the component if the image does not come from a database field.

Here is my code:

BlobStream := qryFoto.CreateBlobStream(qryFoto.FieldByName('image'), TBlobStreamMode.bmRead);
Image1.Bitmap.LoadFromStream(BlobStream);
Image1.BestFit;
BlobStream.Free;

How to fit it?

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
RicardoPin
  • 21
  • 4
  • Have you tried setting Strecht property to True ?. – Marc Guillot Sep 28 '16 at 07:24
  • I didn't find strecht property in TImageViewer component. It has? When i was using TImage, and set strecht property, the image became distorted. – RicardoPin Sep 28 '16 at 12:45
  • @RicardoPin Your code worked fine for me in a new project using the TImageViewer. You can also try use a **TMemoryStream** instead of a **TStream** and use this code: `TBlobField(qryFoto.FieldByName('image')).SaveToStream(BlobStream);` to create the stream. – Filipe Martins Sep 28 '16 at 12:51
  • My fault, I thought you were using a TImage. By the way, you can set Proportional to True to avoid a TImage getting distorted. – Marc Guillot Sep 28 '16 at 12:59

0 Answers0