Hello,
I'm running in circle since some hours, achieving nothing. I apologize for the seemingly stupid problem I have, but after reading several time the help (low level imaging, high level imaging) plus the demo, I'm still stuck.
I'm using BDS2007. What I want to achieve is to display two PNG, with alpha channel preserved, on the canvas of a TImage. The PNGs will be rotated also.
So... seems obvious?
First, I create a TSingleImage, then rotate it for good measure.
Then, I want to try using the canvas... Correct me if I'm wrong, but some manipulations are made of TSingleImage, while others are made on ImagingCanvas, right? Say I'll reverse the color.
Question 1: Do I need to do a CreateForImage each time I bind a canvas to an image? Am I not doing a memory leak here, as I already created the canvas, so doing CreateForImage which is also a Constructor seems weird here.
Next step, if I want to display properly on a TImage (I named my Viewport), I need to replace its Graphics with a TImagingBitmap, so I do
And again, a question, if I do that, what about the original Graphic of the TImage? It is lost in limbo and so ... memory leak?
Last step, I want to display something.
ViewPort.Picture.Graphic.Assign(SImg);
It works! But here I'm displaying SImg onto the whole TImage Canvas... But what if I wanted to add twice this image? As this is an assign, one will replace another, so not good!
Another solution, that will not work either :o is to not associate a TImagingBitmap to the TImage Graphic, so I can use:
DisplayImage(ViewPort.Canvas, 50, 50, SImg);
DisplayImage(ViewPort.Canvas, 75, 75, SImg);
But here the images are not shown with correct transparency...
So basically I'm stuck. Plus I have several questions... The logic of the library is difficult to grasp for me.... You have to replace the Graphic part of a TImage with a special TImagingBitmap, then you can do some operations directly on class TSingleImage, but some require a special TCanvas... and all that, how you use it in the end to display combinated images with transparency? I feel dumb and I need directions.
Just to summarize ... I want to be able to display in a TImage several PNG which are rotated and with their alpha channel preserved (so not just transparent/not transparent)... Is it possible? Would you help me understand how to do that?
I'm running in circle since some hours, achieving nothing. I apologize for the seemingly stupid problem I have, but after reading several time the help (low level imaging, high level imaging) plus the demo, I'm still stuck.
I'm using BDS2007. What I want to achieve is to display two PNG, with alpha channel preserved, on the canvas of a TImage. The PNGs will be rotated also.
So... seems obvious?
First, I create a TSingleImage, then rotate it for good measure.
Code Select
SImg := TSingleImage.CreateFromParams(10, 10, ifA8R8G8B8);
SImg.LoadFromFile('candles.png');
SImg.Rotate(135);
Then, I want to try using the canvas... Correct me if I'm wrong, but some manipulations are made of TSingleImage, while others are made on ImagingCanvas, right? Say I'll reverse the color.
Code Select
FImageCanvas := TImagingCanvas.Create;
FImageCanvas.CreateForImage(SImg);
FImageCanvas.InvertColors;
Question 1: Do I need to do a CreateForImage each time I bind a canvas to an image? Am I not doing a memory leak here, as I already created the canvas, so doing CreateForImage which is also a Constructor seems weird here.
Next step, if I want to display properly on a TImage (I named my Viewport), I need to replace its Graphics with a TImagingBitmap, so I do
Code Select
FBitmap := TImagingBitmap.Create;
ViewPort.Picture.Graphic := FBitmap;
And again, a question, if I do that, what about the original Graphic of the TImage? It is lost in limbo and so ... memory leak?
Last step, I want to display something.
ViewPort.Picture.Graphic.Assign(SImg);
It works! But here I'm displaying SImg onto the whole TImage Canvas... But what if I wanted to add twice this image? As this is an assign, one will replace another, so not good!
Another solution, that will not work either :o is to not associate a TImagingBitmap to the TImage Graphic, so I can use:
DisplayImage(ViewPort.Canvas, 50, 50, SImg);
DisplayImage(ViewPort.Canvas, 75, 75, SImg);
But here the images are not shown with correct transparency...
So basically I'm stuck. Plus I have several questions... The logic of the library is difficult to grasp for me.... You have to replace the Graphic part of a TImage with a special TImagingBitmap, then you can do some operations directly on class TSingleImage, but some require a special TCanvas... and all that, how you use it in the end to display combinated images with transparency? I feel dumb and I need directions.
Just to summarize ... I want to be able to display in a TImage several PNG which are rotated and with their alpha channel preserved (so not just transparent/not transparent)... Is it possible? Would you help me understand how to do that?