Re: Inlining pixbufs



On 23 Jun 2000, Havoc Pennington wrote:

> 
> Hi,
> 
> We need an equivalent to 'convertrgb' in gnome-libs/tools in order to 
> inline our stock icons, and since convertrgb is crufty and this is a
> generally useful feature, I wrote a new program to handle it. The
> program gets installed, so other people can use it.
> 
> The idea is:
>  - we create a program image-to-inline that loads image files and 
>    can create a file full of C variable declarations
>  - we use this to create the inline variables for GTK
>  - gdk-pixbuf.h now contains gdk_pixbuf_new_from_inline() that 
>    reads the stuff image-to-inline outputs.
> 
> Patch appended.


uhm, look at the CSource plugin in gimp. i had to face this
problem earlier last year for beast, and CSource is what steamed
from it.
CSource can easily be extracted into a standalone saving routine
if you want that, and since i mostly use it for alpha icons, it
implements simple RLE to squeeze the obvious bloat out of the
executable (and is about as fast a memcpy() on extraction).
CSource saves a macro for RLE extraction on the way, but i have
a more sophisticated function that also does bounds checking
laying around in beast/bse/bseutils.c:bse_icon_from_pixdata()
already.

glancing at your patch, you're saving the pixels as a const guchar
array.
i did quite some testing back then and can say, saving arrays
has enourmous disadvantages, quoting the Gimp's ChangeLog
(and thus me, but who cares ;):

Mon Oct  4 21:09:20 1999  Tim Janik  <timj@gtk.org>

        * plug-ins/common/csource.c: minor cleanups. fixed up alpha channel
        elimination for RGBA_IMAGE && !config->alpha configuration.
        added option to save data with 1Byte Run Length Encoding, in this
        case the outputted source contains a macro (15 lines), implementing
        an RLE decoder for RGB or RGBA buffers.
        RLE gains us a size decrease of ca. 50% for average images, while
        decoding speed amounts to a few invokations of memcpy().

Wed Jul  7 02:24:22 1999  Tim Janik  <timj@gtk.org>

        * plug-ins/common/csource.c: save RGBA data as string and not seuqences
        of numbers and commas. this reduces the output file size significantly
        (by 50-70%) and reduces compile time memory requirement majorly (down
        to 20% for gcc).


in practice, the 80% memory savings of gcc can be quite important, it would
sometimes grow up to +100megs for moderately sized images.
and the RLE encoding is really worth the efford (often far more than 50%) for
your average icon pixmaps.

> 
> Havoc
> 

---
ciaoTJ





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]