Question

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?

Was it helpful?

Solution

Set

icContactsDetails.WrapMode:=TImageWrapMode.iwStretch

instead of scaling the control.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top