Re: Correct use of pixbuf, pixmap, and image?

Ari Jolma wrote:
muppet wrote:

Similarly, image data can be stored in "bitmaps" (1-bit images, or
maps of bits) or "pixmaps" (maps of more-than-one-bit pixels, or
pixel maps).  These are stored on the server, at device bit
resolution and bit depth, and this can be manipulated quite quickly.

looking at process info, it seems that X is piling up memory, the code
creates a new pixmap every time a new object it selected (a crude way of
getting rid of the old selection), but pixmaps should be automatically
unref'd since the new pixmap is put into the same place as the old, the
code is effectively:

create $self->{pixbuf}
loop: {
    $self->{pixmap} = $self->{pixbuf}->render_pixmap_and_mask;

    $self->{pixmap}->draw_line etc.


I'm not sure why that would pile up pixmaps without seeing more of your code.

You may wish to take a different approach.  Render the pixbuf once, turn it
into a pixmap once, and then keep that as an untouched server-side resource. 
Copy the necessary portions from the source pixmap to the onscreen window on
demand, and draw on the onscreen window.  Alternatively, use a single
offscreen pixmap for the source buffer, and another for the annotate image; to
"undraw" previous annotations, copy from the clean one.  This avoids the whole
re-render stage.

GtkImage provides a way for you to set the source data directly from
a pixbuf --- $image->set_from_pixbuf($pixbuf) --- so you could avoid
the pixmap/mask stage.

but I can't draw on an image? I need the pixmap for that, I believe.

You need the pixmap only for X's drawing primitives.  You can use gd, libart,
cairo, imagemagick, and even direct pixel manipulation to deal with the 24-bit
image data in the pixbuf.

muppet <scott at asofyet dot org>

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