> Hi,
>
> I would like to save some image data, created and held within a structure in
> my C program, using imagemagick. The sample code below compiles without
> errors, but does not actually produce a file at the end of it. I suspect I am
> making a trivial error but dont understand the magickcore library enough at
> the moment to work out what it may be!
>
> Please can someone point out where I am going wrong?
>
> Oh, I should probably point out that I can successfully load files from disk,
> into my impixbuf structure, using imagemagick, so I think it is probably my
> incorrect use of the API which is the problem here!
>
> Best regards,
>
> Chris.
>
> void impixbuf_save_to_file(impixbuf *pixbuf, const char *path) {
> Image *image;
> ImageInfo *image_info;
> ExceptionInfo *exception;
> PixelPacket *dst;
> guchar *src, *s;
> gint r, p;
>
> g_print("%s \n", path);
>
> InitializeMagick("/usr/bin/");
> exception = g_malloc(sizeof(ExceptionInfo));
> GetExceptionInfo(exception);
> image_info = CloneImageInfo((ImageInfo *) NULL);
> image = AllocateImage(image_info);
> image->columns = pixbuf->width;
> image->rows = pixbuf->height;
> strcpy(image_info->filename, path);
>
> g_print("%s \n", image_info->filename);
>
> src = NULL;
> for (r=0; r<pixbuf->height; r++) {
> s = src = impixbuf_get_pixel_row(pixbuf, src, 0, r, pixbuf->width);
> dst = (PixelPacket *)SetImagePixels(image, 0, r, image->columns, 1);
> for (p=0; p<pixbuf->width; p++) {
> dst->red = s[PIXEL_RED];
> dst->green = s[PIXEL_GREEN];
> dst->blue = s[PIXEL_BLUE];
> dst->opacity = 255 - s[PIXEL_RGB_ALPHA];
> s+=pixbuf->stride;
> dst++;
> }
> }
> WriteImage(image_info, image);
>
> DestroyMagick();
> }
>
>
_______________________________________________
Magick-users mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-users