TTMSFMXPDFLib - Bitmap Quality


I get different results from the same jpeg image depending on how I draw it. The file is a larger than the required print size, so when I use DrawImage I change this with SetSize

1st way
    p.Graphics.DrawImageFromFile( 'pathname', PointF(480, 0 ));

Result is a very sharp image on screen and in print

2nd way
     logo  := TBitmap.Create; 
     logo.LoadFromStream( MyRs );   // file loaded as resource same as 'pathname'
     logo.SetSize( 105, 78 );
     p.Graphics.DrawImage( logo, PointF(480,0));

The quality is noticeably lower on screen and when I print.



The quality loss is most likely due to the FireMonkey framework that is compressing the original bitmap via the SetSize call. DrawImageFromFile simply calls DrawImage:

procedure TTMSFMXGeneralPDFGraphicsLib.DrawImageFromFile(AFileName: String; ABackgroundColor: TTMSFMXGraphicsColor; Rect: TRectF; Stretch: Boolean = True; 
  AspectRatio: Boolean = True; ImageType: TTMSFMXPDFGraphicsLibImageType = itOriginal; Quality: Single = 1.0);
  bmp: TTMSFMXBitmap;
  bmp := TTMSFMXBitmap.Create;
    DrawImage(bmp, ABackgroundColor, Rect, Stretch, AspectRatio, ImageType, Quality);

Pieter Scheldeman2017-04-25 14:02:50

Thanks for your reply.

When I resize the image in Photoshop so that it's the right size to use DrawImage without SetSize, it comes out at the right size, but again, at lower quality than the DrawImageFromFile.

Changing it in photoshop results in a smaller size with fewer pixels, so I guess it's understandable ... but it would be nice to be able to get the logo on the documents with max quality and have the image as a resource


Internally, the image is always converted to a JPEG, with the settings specified in the ImageType and Quality parameters. You can also try to include the image in a TTMSFMXBitmapContainer, then use the DrawImageWithName instead, to include the image as a resource.