Can't get transparent color for TBitmap

Viewed 65

I have a bitmap that I want to draw on TPaintBox. The problem is that I have to rotate it to a specific angle before. I decided to use TBitmap32. I do it this way: I create a TBitmap first, then transfer it to TBitmap32, do a conversion and move TBitmap32 to TBitmap again. I am drawing this last TBitmap on TPaintBox. The problem is I can't get transparency.

The bitmap has a red background that I want to make transparent. Will you help? What am I doing wrong?

carImage32 := TBitmap32.Create;

carImage32.Width := carImageTMP.Width;
carImage32.Height := carImageTMP.Height;

carImage32.Canvas.Draw(0, 0, carImageTMP); //assign TBitmap

carImage := TBitmap.Create;
carImage.Width := carImageTMP.Width;
carImage.Height := carImageTMP.Height;


RotateBitmap(carImage32,angle,false,clNone,True);

carImage.Transparent:=True;
carImage.TransparentColor:=clRed;

carImage.Assign(carImage32);

paintBox.Canvas.Draw(0,0,carImage);
1 Answers

I solved my problem. I should use also for TBitmap32 this part of code:

auto.carImage32.DrawMode:=dmTransparent;
auto.carImage32.OuterColor:=clRed32;

and worked :)

Related