Re: Using GdkPixbuf buffers with GraphicsMagick



2009/1/6 Luka Napotnik <luka napotnik gmail com>:
I'm trying to use GraphicsMagic (the successor of ImageMagick) to
manipulate a GdkPixbuf image buffer. The problem is that the program
segfaults, probably due to the raw nature of the buffer which the Magick
API doesn't handle very good.
I'm opening the image buffer with MagickReadImageBlob() and then apply
some filters.

libMagick (usually) expects images as RGBARGBARGBA, with 16 bits for
each value. GdkPixbuf is always  RGBRGBRGB, or RGBARGBARGBA, with 8
bits per value.

You will probably need to allocate a big chunk of memory and unpack
your GdkPixbuf into that as 16-bit values, then call
MagickReadImageBlob(). Going the other way, you'll need to build an
empty GdkPixbuf (ie. one with memory allocated for it), then pack the
libMagick buffer down into that from 16 to 8 bits.

Other image processing libraries are more flexible in how they can
represent pixels and can skip these pack/unpack steps. It depends what
kind of processing you want to perform and whether some other library
also has what you need.

I help maintain vips:

  http://www.vips.ecs.soton.ac.uk

Which can do RGB or RGBA with 8 bit values, but of course might not
have the particular filter you need.

John



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