[Lazarus] Bitmap transparency problem (I don't want transparency)
Pierre Delore
dpliste at free.fr
Mon Feb 22 09:59:41 CET 2010
I Howard,
> Difficult to be sure based on an uncompilable code snippet. Presumably TImgList is a TImage (not a TImageList)?
> But you carefully create a bitmap and draw it on the component's canvas, and then draw over it again with a call to inherited Paint.
ImgList is a TImageList.
In my application I first load images in TImageList and after, with an 'index', I want to display an image from this list.
The class I use is inherited from a TCustomControl.
This is not for me easy for me to works with graphics. So this code is inspired from examples founded over the net.
I probably not used the best way to this job.
If you have an example that do this, send it to me.
Thanks in advance.
--
Pierre Delore
http://datalinkwristapps.free.fr
http://dpsite.free.fr
----- "Howard Page-Clark" <hdpc at talktalk.net> a écrit :
> On 21/2/10 6:57, Pierre Delore wrote:
> Hi,
>
> I have a transparency problem when I try to display a bitmap stored in a TImagList.
> The bitmap I want to display is a green arrow with a white background. I want to display it without transparency.
> With the code below the bitmap is displayed but the background is not white (it's a copy of a part of the screen). If I uncomment the 2 lines with the fillrect, the background is set to green.
>
> Any ideas?
>
> >--------------------------------------------------------------------------------------------------------
> procedure TImgList.Paint;
> var
> Bitmap: TBitmap;
> begin
> Bitmap := TBitmap.Create;
> try
> Bitmap.Height := pHeight;
> Bitmap.Width := pWidth;
>
> TImgListItem(ListImg.Items[index]).ImgList.GetBitmap(tagv,Bitmap); //the image is a green arrow with a white background
>
> Bitmap.Transparent:=False;
> //Canvas.Brush.Color := clGreen; If I uncomment this part the background is set to green
> //Canvas.FillRect(0,0,pwidth,pheight);
> Canvas.Draw(0, 0, Bitmap);
> finally
> Bitmap.Free;
> end;
>
> inherited Paint;
> end;
>
> Difficult to be sure based on an uncompilable code snippet. Presumably TImgList is a TImage (not a TImageList)?
> But you carefully create a bitmap and draw it on the component's canvas, and then draw over it again with a call to inherited Paint.
>
> HTH
>
> Howard
>
> -- _______________________________________________ Lazarus mailing list Lazarus at lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20100222/b2bd365a/attachment-0004.html>
More information about the Lazarus
mailing list