Board index » delphi » Transparency problems

Transparency problems

Hi all,

I have a tGraphic Database field called Bitmap and I want to store there an
image 24x18 pixels. If the user enters a bigger image I want to STRETCH it
and store it stretched. For this reason, I use an intermediate tImage to do
the stretch and copy the final image into the DbImage with this code:

with DbImage.Picture.Bitmap do
begin
  MyRect := Rect(0, 0, 23, 17);
  Width := 24;
  Height := 18;
  Transparent := True;
  Canvas.StrechtDraw(MyRect, Image.Picture.Graphic);
end;

My problem is that with this code I loose the original transparency of the
image.

Please, how could I copy the stretched image into the DbImage without
loosing the transparency?

Thanks for your knowledge and help :)

Best regards
Manuel Sebares

 

Re:Transparency problems


Maybe.. BMP doesn't save transparency?
When you say transparency, do you really mean transparency, or the colour
you defined previously as the "transparent colour"
It depends what format the image was in the first place.

Quote
M. Sebares <m...@idecnet.com> wrote in message news:3b49e907_2@dnews...
> Hi all,

> I have a tGraphic Database field called Bitmap and I want to store there
an
> image 24x18 pixels. If the user enters a bigger image I want to STRETCH it
> and store it stretched. For this reason, I use an intermediate tImage to
do
> the stretch and copy the final image into the DbImage with this code:

> with DbImage.Picture.Bitmap do
> begin
>   MyRect := Rect(0, 0, 23, 17);
>   Width := 24;
>   Height := 18;
>   Transparent := True;
>   Canvas.StrechtDraw(MyRect, Image.Picture.Graphic);
> end;

> My problem is that with this code I loose the original transparency of the
> image.

> Please, how could I copy the stretched image into the DbImage without
> loosing the transparency?

> Thanks for your knowledge and help :)

> Best regards
> Manuel Sebares

Re:Transparency problems


TBitmap (ie the .bmp image format) doesn't support transparency. Delphi
fudges transparency by assuming that the bottom left pixel of a bitmap is
the transparent colour. StretchDraw, on the other hand, doesn't do this. In
order to draw your image resized and with transparency you will need to use
an intermediate storage bitmap of some form - I personally use a TImageList
because these are very quick and support transparency (you can manually set
the transparent colour fromt he bottom left pixel your self to duplicate
what Delphi does).

Hope this helps.

Nick

Quote
> I have a tGraphic Database field called Bitmap and I want to store there
an
> image 24x18 pixels. If the user enters a bigger image I want to STRETCH it
> and store it stretched. For this reason, I use an intermediate tImage to
do
> the stretch and copy the final image into the DbImage with this code:

> with DbImage.Picture.Bitmap do
> begin
>   MyRect := Rect(0, 0, 23, 17);
>   Width := 24;
>   Height := 18;
>   Transparent := True;
>   Canvas.StrechtDraw(MyRect, Image.Picture.Graphic);
> end;

> My problem is that with this code I loose the original transparency of the
> image.

> Please, how could I copy the stretched image into the DbImage without
> loosing the transparency?

Other Threads