1

I try to make use of a TImage32 to combine several layers with positions and transparency etc. So I create in runtime a TImage32, set parent to nil, load from file a bitmap and load from file a layer on top of that bitmap. Now I want to save the result, but I seem to be unable to find where the actual result is. If I do the same with creating the TImage32 in designtime, make it visible, the result of the combined bitmaps is in the Buffer field of TImage32, and I can save the result using Image32.Buffer.SaveToFile('test.bmp'). If the component is not visible, the Buffer is an empty bitmap and the combined bitmap seem to be not created.

Can someone shed light on this? How do I combine bitmaps with GR32, save them, but with invisible components?

Thanks a lot! Willem

Willem
  • 61
  • 4
  • Why are you using TImage32? That's a visual control. Don't you use one of the non-visual classes? http://graphics32.org/documentation/Docs/Examples.htm – David Heffernan Apr 01 '16 at 11:13
  • Hi David. Thanks for answering. The main reason for using TImage32 is that it holds a layers property, which I need for storing and positioning individual layers. Which non-visual classes could I use for the same functionality? – Willem Apr 01 '16 at 12:55
  • Follow the link I gave you and look at the examples which use layers – David Heffernan Apr 01 '16 at 13:05
  • OK David, Thanks! The example indeed had the answer, in the procedure FlattenClick. The trick is in the PaintTo method. Thanks!!! – Willem Apr 01 '16 at 13:15
  • As I explained in [another question](http://stackoverflow.com/a/32741852/33732), `TImage32` is the wrong class for this task. In fact, you could probably make do with plain old `TBitmap`. – Rob Kennedy Apr 01 '16 at 13:28

1 Answers1

0

You don't need to use visual controls like TImage.

The library you're using graphics32 has all the methods you need.

Use TBitmap32: The Bitmap can be displayed and scaled using its DrawMode, MasterAlpha and StretchFilter properties.

You simply use the MyBitmap.LoadFromFile method to get it.
I suggest you then store your bitmaps in a TObjectList.
Combine them using TBitmap32.Draw{To}, note that you can use the DrawMode to modify the behavior of Draw.

And use the SaveToFile method as usual when done manipulating the bitmap.

Johan
  • 74,508
  • 24
  • 191
  • 319