1

Graphics32 class TBitmap32 has a canvas so everything that can draw on Canvas can draw on TBitmap32. I want to create my own bitmap class not derived from TBitmap nor TBitmap32 and also have a Canvas. I could just fake it by using a TBitmap with it's Canvas and then just copy pixels to my class. But that's quite slow.

Tom
  • 2,962
  • 3
  • 39
  • 69
  • *I want to create my own bitmap class not derived from `TBitmap` nor `TBitmap32` and also have a Canvas.* Why??? – Tom Brunberg Apr 17 '20 at 19:20
  • @TomBrunberg For performance reasons. – Tom Apr 17 '20 at 19:33
  • 1
    @Tom So, what is stopping you from simply writing a new class derived from `TCustomCanvas` to do what you need with the pixel data, and then using that class inside your custom bitmap class? The same thing that `TBitmap` and `TBitmap32` do. You need to be more specific about the issue you are having implementing what you want. – Remy Lebeau Apr 17 '20 at 21:02

1 Answers1

1

With Graphics32 several drawing "backends" are available. Each has different advantages and disadvantages. However, mostly related to performance and memory consumption.

The default (for TBitmap32) is TGDIBackend, which is quite versatile. This said, it inherits all the disadvantages from GDI. In particular the number of GDI elements is limited, so you can't have infinitesimally many instances.

A better choice would be TMemoryBackend, but this alone can not be drawn ("blitted") onto the screen (i.e. any DC). A compromise is the TGDIMemoryBackend, which is a TMemoryBackend with the ability to draw to the screen. However, it lacks font support if I remember correctly, but according to your requirements this is probably not necessary.

CWBudde
  • 1,783
  • 1
  • 24
  • 28