<html><head><style type='text/css'>p { margin: 0; }</style></head><body><div style='font-family: Verdana; font-size: 12pt; color: #000000'>hi all,<br><br>Thanks for your answers.<br><br>I forgot to specify that I'm in Win32 with 0.9.28.2 (not a snapshot).<br><br>Peter, I uncommented the 2 lines and I replaced clGreen by clWhite. The image is displayed correctly.<br>I changed the background of the image and I set it to blue (FF0000). The image is displayed correctly.<br>I also replace the clWhite by clBlue. The image is displayed correctly.<br><br>Somebody can explain me why I had this problem?<br><br>Is there a visual component that allow to display an image from an imagelist (a TImage descendant for example)? <br><br><br>Regards<br><br>--<br>Pierre Delore<br><br>http://datalinkwristapps.free.fr<br>http://dpsite.free.fr<br><br>----- "Peter Williams" <pewtas@gmail.com> a écrit :
<br>> Hi Pierre and Lazarus list,<br>> <br>> 2010/2/22 Pierre Delore <dpliste@free.fr>:<br>> > Hi,<br>> ><br>> > I have a transparency problem when I try to display a bitmap stored in a<br>> > TImagList.<br>> > The bitmap I want to display is a green arrow with a white background. I<br>> > want to display it without transparency.<br>> > With the code below the bitmap is displayed but the background is not white<br>> > (it's a copy of a part of the screen). If I uncomment the 2 lines with the<br>> > fillrect, the background is set to green.<br>> <br>> I think that you commented code reveals why this is happening. See my<br>> untested suggested code<br>> changes below.<br>> <br>> ><br>> > Any ideas?<br>> ><br>> a--------------------------------------------------------------------------------------------------------<br>> > procedure TImgList.Paint;<br>> > var<br>> > Bitmap: TBitmap;<br>> > begin<br>> > Bitmap := TBitmap.Create;<br>> > try<br>> > Bitmap.Height := pHeight;<br>> > Bitmap.Width := pWidth;<br>> ><br>> > TImgListItem(ListImg.Items[index]).ImgList.GetBitmap(tagv,Bitmap);<br>> > //the image is a green arrow with a white background<br>> ><br>> > Bitmap.Transparent:=False;<br>> ><br>> > //Canvas.Brush.Color := clGreen; If I uncomment this part the<br>> > background is set to green<br>> <br>> // set colour of the Canvas Brush to white (using the constant "clWhite")<br>> Canvas.Brush.Color := clWhite;<br>> <br>> > //Canvas.FillRect(0,0,pwidth,pheight);<br>> <br>> // now fill the background of the Canvas with the Canvas.Brush.Color<br>> set to colour white<br>> Canvas.FillRect(0,0,pwidth,pheight);<br>> <br>> // note that my changes (above) are proposed, untested to the code<br>> which you posted.<br>> <br>> // my modifications to your code *should* make the background of the<br>> Canvas clWhite before you draw Bitmap -- with the next line of code.<br>> <br>> > Canvas.Draw(0, 0, Bitmap);<br>> <br>> // hopefully now Bitmap will be drawn on a clWhite background... which<br>> is the effect you said in your email you're wanting.<br>> <br>> > finally<br>> > Bitmap.Free;<br>> > end;<br>> ><br>> > inherited Paint;<br>> > end;<br>> ><br>> ><br>> > Regards.<br>> ><br>> > --<br>> > Pierre Delore<br>> ><br>> > http://datalinkwristapps.free.fr<br>> > http://dpsite.free.fr<br>> ><br>> > --<br>> > _______________________________________________<br>> > Lazarus mailing list<br>> > Lazarus@lists.lazarus.freepascal.org<br>> > http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus<br>> ><br>> ><br>> <br>> I hope that these mods to your posted code help. Please note that they<br>> are proposed and untested.<br>> <br>> Note: in my comments I use the British spelling of the word "colour"<br>> not American spelling of "color".<br>> <br>> With LOVE from PEW ;-)))<br>> <br>> Fond Regards, Peter Eric (aka 'pew') WILLIAMS<br>> from Hobart, Tasmania, Australia -- phone (03) 6236-9675<br>> <br>> My free website is: http://pewtas.googlepages.com (or)<br>> http://tinyurl.com/yuyejs<br>> <br>> (please visit my free website and let me know what you think about it.)<br>> <br>> --<br>> _______________________________________________<br>> Lazarus mailing list<br>> Lazarus@lists.lazarus.freepascal.org<br>> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus<br>> </div></body></html>