why does png lose transparency on triple buffer or stretch? lazarus / 39-Graphics ---------------------------------------------------------------------- jw · 2010-03-21 18:36 ok If I make 2 sprite buffers like so spritenormal : TCustomBitmap; spritestretched : TCustomBitmap; spritenormal:= TPortableNetworkGraphic.Create; spritestretched:= TPortableNetworkGraphic.Create; and load sprite normal form a timagelist like so spriteimages.GetBitmap(0, spritenormal); then do a stretch to fit multiple screen resolution spritestretched.Canvas.StretchDraw(rect(0,0,screen.width*0.50,screen.h eight*0.50),spritenormal); then draw it to the form canvas like so Canvas.Draw(0,0, spritestretched); I lose the transparency of the ping in the stretchdraw command, but of I decide to just display the loaded spritenormal it works fine? how do I fix this?????? ---------------------------------------------------------------------- Marc · 2010-03-21 21:44 Drawing alpha is limited supported. When loading from images, a canvas has alpha, but as soon as you draw on it, the (destination) canvas looses alpha. Just think of it, how do you want to make a difference in drawing in the following examples: 1) draw an alpha image on an exiting background, so the image blends 2) draw an alpha image on an exiting background, so the image replaces At this moment, the LCL only does 1. ---------------------------------------------------------------------- jw · 2010-03-21 23:26 is there a hex value I can put into $????????; that will paint the canvas background transparent with a draw command? Canvas.pen.Color := $????????; Canvas.brush.Color := $????????; Canvas.rectangle(0,0,width,Height); if no!!!! Then is there a way to stretch without doing the stretchdaw? lf I'm pulling an image from a timiagelist can it be stretched within the timagelist during runtime before it's loaded into the tcustombitmap? ---------------------------------------------------------------------- circular · 2010-03-21 23:40 With my lib ( http://consume.o2switch.net/lazarus/bgrabitmap.zip ) you can do it this way : Code: [Select]var OriginalBitmap, StretchedBitmap: TBGRABitmap; begin   OriginalBitmap := TBGRABitmap.Create('some_image.png');   StretchedImage := TBGRABitmap(OriginalBitmap.Resample(200,200));   StretchedImage.Draw(Canvas,0,0,False); end; ---------------------------------------------------------------------- jw · 2010-03-23 14:57 wow circular you're far beyond my codeing skills.  I'll check out the library but for now I still want to deal with the LCL and learn it.  My thinking is that the LCL will do what I want because you can do an image stretch within a timagelist without loseing transparency.  I just can't find the command to to it. example I have a transparent image in a tcustombitmap and don't use any draw commands on it then I should be able to make another timage list for the stretching. Modifing the original post ok If I make a sprite buffer like so sprite : TCustomBitmap; sprite:= TPortableNetworkGraphic.Create; and load the unstretched sprite from a timagelist like so spriteimages.GetBitmap(0, spritenormal); then do a stretch to fit multiple screen resolution using a timagelistbuffer timagelistbuffer.width:=screen.width*0.50 timagelistbuffer.height:=screen.height*0.50; how do you get  stretch from runtime with a timagelist?? timangelistbuffer.stretch:=true;         //this errors timangelistbuffer.Insert(0, sprite, stretch);  //this errors timangelistbuffer.Insert(0, sprite, nil); //this loads but no stretch pull the stretched image back into the sprite timagelistbufferbuffer.GetBitmap(0, sprite); then draw it to the form canvas like so Canvas.Draw(0,0, sprite); ---------------------------------------------------------------------- jw · 2010-03-23 20:52 the command that worked was timagelist.insertmasked(index,tcustombitmap,mask color); now I can stretch all my sprites then reclaim transpareny through an imagelist and a backgroud color mask. ---------------------------------------------------------------------- circular · 2010-03-24 20:04 In fact you can directly draw an image from the TImageList with the Draw method, but I guess the transparency is only 1-bit. I mean that there can be opaque pixels or transparent pixels but nothing between the two. ---------------------------------------------------------------------- jw · 2010-04-13 19:59 circular how are you pulling the image directly from a timamgelist with a draw command? I first have to put the image into a tcutombitmap buffer then stretchdraw it to another tcustombitmap. It would be nice to skip a step. this is the only command I know of to get the image out timagelist.getbitmap(1,tcustombitmapbuffer) then stretch it ---------------------------------------------------------------------- circular · 2010-04-14 09:25 As I said you can use the Draw method. For stretching, there is also a StretchDraw method : Code: [Select]  ImageList1.Draw(Canvas,x,y,index);   ImageList1.StretchDraw(Canvas,index,rect(0,20,100,120));