Tom
Tom

Reputation: 3637

Delphi ios scale Bitmap inside ImageControl

I have 75*75 .png files, but I want them to show in a 150x150 sized ImageControl with transparent background. I currently use this code:

  FBitmapBufferLoadFromFile(...);
  icContactsDetails.Bitmap := TBitmap.Create(0, 0);
  icContactsDetails.Bitmap.Assign(FBitmapBuffer);
  icContactsDetails.Width := icContactsDetails.Bitmap.Width;
  icContactsDetails.Height := icContactsDetails.Bitmap.Height;
  icContactsDetails.Scale.X := 150 / icContactsDetails.Bitmap.Width;
  icContactsDetails.Scale.Y := 150 / icContactsDetails.Bitmap.Height;

I have the following questions:

1) How do I keep transparency? (Transparent area in .png is converted to white.) 2) Should I do the scaling outside the ImageControl to avoid setting width/height?

Upvotes: 0

Views: 705

Answers (1)

AvgustinTomsic
AvgustinTomsic

Reputation: 1841

Set

icContactsDetails.WrapMode:=TImageWrapMode.iwStretch

instead of scaling the control.

Upvotes: 3

Related Questions