Update ImageMagick support to API version 7
This commit is contained in:
parent
5df7f92647
commit
9d39ac393e
|
@ -6,24 +6,24 @@
|
||||||
int save_depth = 16;
|
int save_depth = 16;
|
||||||
|
|
||||||
#ifdef HAVE_MAGICK
|
#ifdef HAVE_MAGICK
|
||||||
#include <magick/api.h>
|
#include <MagickCore/MagickCore.h>
|
||||||
|
|
||||||
/* load given image to memory. return short RGB values */
|
/* load given image to memory. return short RGB values */
|
||||||
unsigned short *load_img(int *width, int *height, const char *filename, int index)
|
unsigned short *load_img(int *width, int *height, const char *filename, int index)
|
||||||
{
|
{
|
||||||
Image *image = NULL;
|
Image *image = NULL;
|
||||||
ImageInfo *imageinfo = NULL;
|
ImageInfo *imageinfo = NULL;
|
||||||
ExceptionInfo exception;
|
ExceptionInfo *exception;
|
||||||
unsigned short *img = NULL;
|
unsigned short *img = NULL;
|
||||||
|
|
||||||
MagickCoreGenesis(NULL, MagickFalse);
|
MagickCoreGenesis(NULL, MagickFalse);
|
||||||
// InitializeMagick(NULL);
|
// InitializeMagick(NULL);
|
||||||
imageinfo = CloneImageInfo(0);
|
imageinfo = CloneImageInfo(0);
|
||||||
GetExceptionInfo(&exception);
|
exception = AcquireExceptionInfo();
|
||||||
|
|
||||||
sprintf(imageinfo->filename, filename, index);
|
sprintf(imageinfo->filename, filename, index);
|
||||||
|
|
||||||
image = ReadImage(imageinfo, &exception);
|
image = ReadImage(imageinfo, exception);
|
||||||
if (!image) {
|
if (!image) {
|
||||||
// printf("failed to read image '%s' via *magick\n", filename);
|
// printf("failed to read image '%s' via *magick\n", filename);
|
||||||
goto exit;
|
goto exit;
|
||||||
|
@ -48,6 +48,9 @@ exit:
|
||||||
if (imageinfo)
|
if (imageinfo)
|
||||||
DestroyImageInfo(imageinfo);
|
DestroyImageInfo(imageinfo);
|
||||||
|
|
||||||
|
if (exception)
|
||||||
|
DestroyExceptionInfo(exception);
|
||||||
|
|
||||||
MagickCoreTerminus();
|
MagickCoreTerminus();
|
||||||
// DestroyMagick();
|
// DestroyMagick();
|
||||||
|
|
||||||
|
@ -60,18 +63,18 @@ int save_img(unsigned short *img, int width, int height, int alpha, const char *
|
||||||
int rc = -1;
|
int rc = -1;
|
||||||
Image *image = NULL;
|
Image *image = NULL;
|
||||||
ImageInfo *imageinfo = NULL;
|
ImageInfo *imageinfo = NULL;
|
||||||
ExceptionInfo exception;
|
ExceptionInfo *exception;
|
||||||
|
|
||||||
MagickCoreGenesis(NULL, MagickFalse);
|
MagickCoreGenesis(NULL, MagickFalse);
|
||||||
// InitializeMagick(NULL);
|
// InitializeMagick(NULL);
|
||||||
imageinfo = CloneImageInfo(0);
|
imageinfo = CloneImageInfo(0);
|
||||||
GetExceptionInfo(&exception);
|
exception = AcquireExceptionInfo();
|
||||||
|
|
||||||
imageinfo->quality = 100;
|
imageinfo->quality = 100;
|
||||||
if (strlen(filename) >= 4 && !strcmp(filename + strlen(filename) - 4, ".png"))
|
if (strlen(filename) >= 4 && !strcmp(filename + strlen(filename) - 4, ".png"))
|
||||||
imageinfo->quality = 1;
|
imageinfo->quality = 1;
|
||||||
|
|
||||||
image=ConstituteImage(width, height, (alpha)?"RGBA":"RGB", ShortPixel, img, &exception);
|
image=ConstituteImage(width, height, (alpha)?"RGBA":"RGB", ShortPixel, img, exception);
|
||||||
if (!image) {
|
if (!image) {
|
||||||
printf("%s:failed to prepare to write image\n", __func__);
|
printf("%s:failed to prepare to write image\n", __func__);
|
||||||
goto exit;
|
goto exit;
|
||||||
|
@ -81,7 +84,7 @@ int save_img(unsigned short *img, int width, int height, int alpha, const char *
|
||||||
image->depth = save_depth;
|
image->depth = save_depth;
|
||||||
|
|
||||||
sprintf(image->filename, filename, index); /* ACHTUNG: nicht imageinfo!!! */
|
sprintf(image->filename, filename, index); /* ACHTUNG: nicht imageinfo!!! */
|
||||||
if (!WriteImage(imageinfo, image)) {
|
if (!WriteImage(imageinfo, image, exception)) {
|
||||||
printf("%s:failed to write image\n", __func__);
|
printf("%s:failed to write image\n", __func__);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
@ -95,6 +98,9 @@ exit:
|
||||||
if (imageinfo)
|
if (imageinfo)
|
||||||
DestroyImageInfo(imageinfo);
|
DestroyImageInfo(imageinfo);
|
||||||
|
|
||||||
|
if (exception)
|
||||||
|
DestroyExceptionInfo(exception);
|
||||||
|
|
||||||
MagickCoreTerminus();
|
MagickCoreTerminus();
|
||||||
// DestroyMagick();
|
// DestroyMagick();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue