Re: pixmap to pixbuf
Espen S Johnsen <[email protected]> 31 May 2006 16:04:56 +0200
| Newsgroups | gmane.lisp.clg.devel |
|---|---|
| Message-ID | <[email protected]> |
ephrem boudonnet <[email protected]> writes: > Hi Espen, > > I would like to get a pixbuf from my offscreen drawable. > I have written these bindings: > > (defbinding colormap-get-system () colormap) > > (defbinding pixbuf-get-from-drawable() (referenced pixbuf) > (drawable drawable) > (colormap colormap) > (srx int) > (sry int) > (destx int) > (desty int) > (width int) > (heigth int)) > > But when I call this function: > > (defun pixmap-to-pixbuf () > (let ((map (gdk::pixmap-new 10 10 1)) > (cmap (gdk::colormap-get-system))) > (gdk::pixbuf-get-from-drawable map cmap 0 0 0 0 10 10) > )) > > I have this error message: > > Gdk: gdk_pixbuf_get_from_drawable: assertion `dest->colorspace == > GDK_COLORSPACE_RGB' failed > [Condition of type glib:critical-log-level] > > In fact I don't know how to "specify" the destination pixbuf as the > documentation says: > " If the specified destination pixbuf /dest/ is NULL, then this function > will create an RGB pixbuf with 8 bits per channel and no alpha". > > Have you any idea? Yes, a pixbuf could be given as the first argument to GdkPixbufGetFromDrawable, which is missing in your definition. This is how I would have done it: (defbinding %pixbuf-get-from-drawable () (referenced pixbuf) (dest (or null pixbuf)) (drawable drawable) (colormap (or null colormap)) (src-x int) (src-y int) (dest-x int) (dest-y int) (width int) (height int)) (defun pixbuf-get-from-drawable (drawable &key (src-x 0) (src-y 0) (dest-x 0) (dest-y 0) width height colormap dest) (unless (or (and width height) (not (typep drawable 'window))) (error "Width and height must be specified for windows")) (or (%pixbuf-get-from-drawable dest drawable (cond (colormap) ((slot-boundp drawable 'colormap) nil) ((colormap-get-system))) src-x src-y dest-x dest-y (or width -1) (or height -1)) (error "Couldn't get pixbuf from drawable"))) -- Espen