Re: pixmap/pixbuf confusion



On Sat, 2003-07-12 at 12:58, Michael Koppelman wrote:
Sorry, I'm confused.

I'm creating a pixmap:

GdkPixmap *pixmap = gdk_pixmap_new( draw->window, width, height, -1);
draw_plot( GDK_DRAWABLE(pixmap) );
pixbuf = gdk_pixbuf_get_from_drawable( NULL, pixmap,\
      gdk_colormap_get_system(), 0, 0, 0, 0, -1, -1);
  

The idea is that draw_plot is used to draw to a drawingarea for normal
use, but in the above it is used to draw to my pixmap so I can save it
out as a JPEG. This works just fine provided I don't mess with the width
and height. However, my goal is to allow them to choose the dimensions
of the JPEG. In draw_plot I get the size of the passed-in drawable, so
my theory was that it doesn't matter if they enter a size for the JPEG
that is bigger or smaller than the drawingarea.

The problem is, if the width and height they entered is bigger or
smaller than the drawingarea my pixbuf ends up with all sorts of data
from the screen in it. It if is the size of the drawing area it behaves
correctly.

If I comment out the draw_plot line, I would have thought my pixmap
would be empty, but it's not. It's got screen stuff in it.Clearly I
don't understand. I want a blank pixmap of arbitrary size. I want to
pass it into a routine that draws in it. Then I want to copy it into a
pixbuf so I can save it as a JPEG. Where do you think I am messing this
up?

Pixmaps are created with uninitialized contents.

What color do you think "empty" is? Draw a rectangle of that color
over the whole pixmap before drawing the contents.

(draw->style->bg[GTK_STATE_NORMAL] draw->style->bg_gc[GTK_STATE_NORMAL]
will be the color draw->window gets set to on expose unless you've
changed it)

Regards,
                                                Owen





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