[Lazarus] Graphics changes (r15472)

Mattias Gaertner nc-gaertnma at netcologne.de
Sat Jun 21 11:23:54 CEST 2008


On Sat, 21 Jun 2008 03:44:08 +0200
Marc Weustink <marc at dommelstein.net> wrote:

> Mattias Gaertner wrote:
> > On Fri, 20 Jun 2008 21:24:13 -0300
> > Luiz Americo Pereira Camara <luizmed at oi.com.br> wrote:
> > 
> >> Marc Weustink wrote:
> >>> Luiz Americo Pereira Camara wrote:
> >>>   
> >>>> One old issue i have with TBitmap (not introduced now but that
> >>>> could be resolved with this refactoring) is that when a image is
> >>>> loaded with LoadFromStream or LoadFromFile a copy of the image
> >>>> buffer is kept in memory. This can speedup if is necessary to
> >>>> access the image data directly but for the more common case of
> >>>> loading a file to display is waste of memory.
> >>>>     
> >>> This is no error, this is by design. And is only kept once and as
> >>> long as the image isn't changed. Indeed, for cases where you know
> >>> you never want to save it, we can add an property.
> >>>   
> >> Since the most common case is not save it, just display, the
> >> default should be not keep a copy of the stream. This my point.
> > 
> > 1. Many images are only loaded, but never displayed.
> 
> ow ? which ones ?

Sorry, maybe 'never displayed' was confusing. I meant 'often never
displayed'.
The forms not shown, but loaded hidden (e.g. via CreateForm).
And formerly the images of an imagelist were created only if used.


> > 2. SaveStream often contains information, that is not stored in the
> > corresponding TGraphic class. For example header information or
> > higher resolution.
> 
> Not anymore. Most important info is stored in a rawimage description 
> and/or the object itself. The stream is only kept to save an image in 
> its original format.

And what about the other attributes?
For example save an image in gimp and it shows for nearly any format some
special properties.

What happens to images loaded in higher resolution than the current
resolution and is then saved without SaveStream?

> > 3. The SaveStream is kept to make sure, that loading/saving creates
> > the same stream. For example the IDE uses this a lot
> > (TGraphics.Equals).
> 
> imo, except for jpeg maybe, load and save image code should reproduce 
> the same image. TGraphic.Equals might get adapted to use better 
> comarisation based on imagedata.

Yes, of course, they should. But do they?

For example the xpm reader skips all comments and the extended
attributes. And there are many ways to represent the same
pixel/color.
And I don't see any extra properties of TPortableNetworkGraphic. Where
are they stored?

 
> > Therefore:
> > Iff the SaveStream is freed by default, *all* images of the LCL
> > must be checked and the biggest part must be enabled to keep
> > SaveStream at least at designtime.
> 
> I see no reason to check all images.

Ok. 


Mattias



More information about the Lazarus mailing list