Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2008-04

TCustomBitmap

6 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Marc Weustink

Hi,

Tonight I introduced a new base class for all raster based images(*) This is to remove OO inpurities in the current TBitmap implementation (**), to keep the loaded and cached stream of the correct type and I needed a clean base to implement TIcon.
This means that in the near future, you won't be able to use a TBitmap to load for instance a png image. You should use TPngImage instead. Also assigning directly TBitmap := TPnGImage will fail since they share only a common baseclass. However TBitmap.Assign(TPnGImage) will work.

For the time being if your project fails to compile, you can enable the {.$define BITMAP_OLDSTYLE} define in graphics.pp

Marc

*) now thinking of, maybe I should have called it TRasterImage. **) some parts of TMyBitmap wil fail to function if you derive a TMyBitmap = class(TBimap)

Graeme Geldenhuys
to Marc Weustink
Marc Weustink wrote
This means that in the near future, you won't be able to use a TBitmap to load for instance a png image. You should use TPngImage instead.

Good work!

And now you should be able to mix in some creational design patterns. Any of the Factory patterns (Simple Factory, Factory Method or Abstract Factory) could be used to instantiate the correct image class by looking at the file extension, or even better the file id (first few bytes of the file).

Regards,
- Graeme -

_______________________________________________________ fpGUI - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net/fpgui/

Chris Kirkpatrick
to Marc Weustink: Tonight I introduced a new base class for all raster based images(*) This is to remove OO…

Attempting to build Lazarus from IDE (SVN 14951, FPC 10779). With 'Examples' checked in Build Config menu, I get the following errors (presumably related to Mark's changes):

Compiling testall.pp
Compiling testallform.pp
/home/kirkpatc/FreePascal/lazarus/trunk/examples/testtools.inc(1430,27) Error: Incompatible type for arg no. 1: Got "TPixmap", expected "TBitmap" /home/kirkpatc/FreePascal/lazarus/trunk/examples/testtools.inc(1787,29) Error: Incompatible type for arg no. 1: Got "TPixmap", expected "TBitmap" /home/kirkpatc/FreePascal/lazarus/trunk/examples/testallform.pp(956,20) Error: Incompatible type for arg no. 1: Got "TPortableNetworkGraphic", expected "TBitmap"
/home/kirkpatc/FreePascal/lazarus/trunk/examples/testallform.pp(2259,18) Error: Incompatible type for arg no. 1: Got "TPortableNetworkGraphic", expected "TBitmap"
/home/kirkpatc/FreePascal/lazarus/trunk/examples/testallform.pp(2280,18) Error: Incompatible type for arg no. 1: Got "TPortableNetworkGraphic", expected "TBitmap"
/home/kirkpatc/FreePascal/lazarus/trunk/examples/testallform.pp(2302,18) Error: Incompatible type for arg no. 1: Got "TPortableNetworkGraphic", expected "TBitmap"
/home/kirkpatc/FreePascal/lazarus/trunk/examples/testallform.pp(2324,16) Error: Incompatible type for arg no. 1: Got "TPortableNetworkGraphic", expected "TBitmap"
/home/kirkpatc/FreePascal/lazarus/trunk/examples/testallform.pp(2538) Fatal: There were 7 errors compiling module, stopping

When I turned off compiling the Examples, the Lazarus re-build completed OK.

Regards - Chris

Marc Weustink wrote 26 lines
Hi, Tonight I introduced a new base class for all raster based images(*) This is to remove OO inpurities in the current TBitmap implementation (**), to keep the loaded and cached stream of the correct type and I needed a clean base to implement TIcon. This means that in the near future, you won't be able to use a TBitmap to load for instance a png image. You should use TPngImage instead. Also assigning directly TBitmap := TPnGImage will fail since they share only a common baseclass. However TBitmap.Assign(TPnGImage) will work. For the time being if your project fails to compile, you can enable the {.$define BITMAP_OLDSTYLE} define in graphics.pp Marc *) now thinking of, maybe I should have called it TRasterImage. **) some parts of TMyBitmap wil fail to function if you derive a TMyBitmap = class(TBimap) _______________________________________________ Lazarus mailing list http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
Marc Weustink
to Graeme Geldenhuys: Good work! And now you should be able to mix in some creational design patterns. Any of…
Graeme Geldenhuys wrote 11 lines
Marc Weustink wrote: > This means that in the near future, you won't be able to use a TBitmap > to load for instance a png image. You should use TPngImage instead. Good work! And now you should be able to mix in some creational design patterns. Any of the Factory patterns (Simple Factory, Factory Method or Abstract Factory) could be used to instantiate the correct image class by looking at the file extension, or even better the file id (first few bytes of the file).

IIRC tpicure already has this.

Marc

Marc Weustink
to Marc Weustink
Marc Weustink wrote 6 lines
Chris Kirkpatrick wrote: > Attempting to build Lazarus from IDE (SVN 14951, FPC 10779). > With 'Examples' checked in Build Config menu, I get the following errors > (presumably related to Mark's changes): Yes... maybe I should ahve compiled the examples too :)

Now I know why I skip them... Anyway, should be fixed (and some memleaks too)

Marc