Re: refcounting images (was Re: Inline Images??? [ was: Re: Graphic Images ])


Subject: Re: refcounting images (was Re: Inline Images??? [ was: Re: Graphic Images ])
From: Paolo Molaro (lupus@debian.org)
Date: Sat Apr 21 2001 - 11:54:14 CDT


On 04/20/01 Paul Rohr wrote:
> At 04:43 PM 4/20/01 +0200, Paolo Molaro wrote:
> >What we should fix is this, instead: try to insert an image and
> >delete it from the document. Save the (empty) document and you will
> >find the image data there. Repeat a few times and the document
> >will grow to some MBs quickly.
[...]
> 1. open a document
> 2. do some typing
> 3. add an image
> 4. do some typing
> 5. remove the image
> 6. do some more typing
> 7. undo to step 4
> 8. undo to step 2
>
> Saves immediately after steps 1, 2, 5, 6, *and 8* should not include that
> image. Saves immediately after steps 3, 4, *and 7* should include it.

That simplified gets us a nice single rule:
1) don't save the image if it's not currently present in the document:-)

I just filed a bug about this in bugzilla.

As for keeping the image in the undo buffers it's fine with me
(especially if they are kept in compressed format).

> >Note also that if you insert
> >the same image twice it gets in the document twice, this is bad,
> >if the data is the same it should be stored only once.
>
> This sounds plausible, too. IIRC, there might have been a screw case here,
> but I forget what it was.
>
> One possibility -- if you insert the "same" image during two different
> sessions, how do you in fact know that it's the same? Scan through all the
> existing images and do a bitwise comparison with each? Maintain checksums
> instead and just check those?

My bet is that doing a memcmp() on the RGBA data is faster than checksumming
and both will be avoided in most cases just checking width and height.
There may be the issue of images that are not always kept in RGB format,
so maybe it's better to have a checksum of the RGB data after all.
I don't know, though, if all the decompression algorithms are stable
(i.e. does a jpeg always decompress to the same RGB data?).

lupus

-- 
-----------------------------------------------------------------
lupus@debian.org                                     debian/rules
lupus@ximian.com                             Monkeys do it better



This archive was generated by hypermail 2b25 : Sat Apr 21 2001 - 11:54:18 CDT