[Lazarus] Graphics changes (r15472)

Mattias Gaertner nc-gaertnma at netcologne.de
Sat Jun 21 03:27:33 CEST 2008


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.
2. SaveStream often contains information, that is not stored in the
corresponding TGraphic class. For example header information or higher
resolution.
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).

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.

 
> >> There's also another problem with it: if the image is modified
> >> using LCLIntf functions like BitBlt the buffer will not be updated
> >> and next time SaveToFile/Stream is called, the buffer (with the
> >> outdated data) 
> >  > will be used.

If you alterthe image then 'Changed' must be called anyway. To free
SaveStream and to let TImage invalidate and to call OnChange.
Maybe 'Changed' should be make public? What has the VCL here?


> > Which buffer do you mean ?
> 
> The SaveStream.


Mattias



More information about the Lazarus mailing list