FNCBitmapSelector images displayed too large

Hi
We are using a FNCBitmapSelector to display some images. Some images display too large for their item so spill out and overlap other images. How do we specify that we want images to fit inside their own respective item?
Thanks

Can you show us a screenshot? The default behavior is that the image is stretched inside the item.

Sure, please find attached the screenshot and the image used.


Hi,

I've tested this here on a default TTMSFNCBitmapSelector

image

Did you change properties? Can you provide a sample that demonstrates this?

bitmapSelector.zip (1.8 MB)
Hi, no we didn't change any properties. The attached example shows the behaviour. I dropped a bitmap selector on a new form. If you change the width but keep the height small it doesn't overlap but when you increase the height it does overlap

Thank you very much for your sample! To work around this, you can use the following code:

procedure TForm1.bsDocImagesItemBeforeDrawContent(Sender: TObject;
  AGraphics: TTMSFNCGraphics; ARect: TRectF; AItemIndex: Integer;
  var ADefaultDraw: Boolean);
begin
  ADefaultDraw := False;
  AGraphics.DrawBitmap(ARect, bsDocImages.Items[AItemIndex].Bitmap);;
end;

Thank you for your reply. I've tried the code above with the latest updates and I'm getting and error - "There is no overloaded version of 'DrawBitmap' that can be called with these arguments" Do I need to modify anything?

It should not require other code. please check if the necessary units are included and are set in the right order. Perhaps it's mixing VCL & FMX?

This project is in VCL and the using's are all set to VCL. I have the following overloads available. It looks like mine is looking for a TTMSFNCBitmapHelperClass?

procedure DrawBitmap(ALeft, ATop, ARight, ABottom: Double; ABitmap: TTMSFNCBitmapHelperClass; AAspectRatio: Boolean = True;
  AStretch: Boolean = False; ACenter: Boolean = True; ACropping: Boolean = False); overload; virtual;
procedure DrawBitmap(ARect: TRectF; ABitmap: TTMSFNCBitmapHelperClass; AAspectRatio: Boolean = True;
  AStretch: Boolean = False; ACenter: Boolean = True; ACropping: Boolean = False); overload; virtual;
procedure DrawBitmap(ALeft, ATop, ARight, ABottom: Integer; ABitmap: TTMSFNCBitmapHelperClass; AAspectRatio: Boolean = True;
  AStretch: Boolean = False; ACenter: Boolean = True; ACropping: Boolean = False); overload; virtual;
procedure DrawBitmap(ARect: TRect; ABitmap: TTMSFNCBitmapHelperClass; AAspectRatio: Boolean = True;
  AStretch: Boolean = False; ACenter: Boolean = True; ACropping: Boolean = False); overload; virtual;
procedure DrawBitmap(ALeft, ATop: Integer; ABitmap: TTMSFNCBitmapHelperClass); overload; virtual;
procedure DrawBitmap(ALeft, ATop: Single; ABitmap: TTMSFNCBitmapHelperClass); overload; virtual;

Can you use BitmapToDrawBitmap(bsDocImages.Items[AItemIndex].Bitmap) ?

Apologies I think it was something else interfering with TRectF. Your suggested code works. Many thanks.

1 Like

Thanks for the feedback!