From 3438402fe29d8ce0316bf59d2213c1694042f17d Mon Sep 17 00:00:00 2001 From: Andreas Eversberg Date: Sun, 20 May 2018 10:49:39 +0200 Subject: [PATCH] Update ImageMagick support to API version 7 --- configure.ac | 2 +- src/libimage/img.c | 22 ++++++++++++++-------- src/tv/main.c | 2 +- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/configure.ac b/configure.ac index c93de4a..0e75496 100644 --- a/configure.ac +++ b/configure.ac @@ -35,7 +35,7 @@ AC_ARG_WITH([imagemagick], [AS_HELP_STRING([--with-imagemagick], [compile with I AS_IF([test "x$with_alsa" != xno], [PKG_CHECK_MODULES(ALSA, alsa >= 1.0, with_alsa=yes, with_alsa=no)]) AS_IF([test "x$with_uhd" != xno], [PKG_CHECK_MODULES(UHD, uhd >= 3.0.0, with_sdr=yes with_uhd=yes, with_uhd=no)]) AS_IF([test "x$with_soapy" != xno], [PKG_CHECK_MODULES(SOAPY, SoapySDR >= 0.6.0, with_sdr=yes with_soapy=yes, with_soapy=no)]) -AS_IF([test "x$with_imagemagick" != xno], [PKG_CHECK_MODULES(IMAGEMAGICK, ImageMagick >= 6.0.0, with_imagemagick=yes, with_imagemagick=no)]) +AS_IF([test "x$with_imagemagick" != xno], [PKG_CHECK_MODULES(IMAGEMAGICK, ImageMagick >= 7.0.0, with_imagemagick=yes, with_imagemagick=no)]) AM_CONDITIONAL(HAVE_ALSA, test "x$with_alsa" == "xyes" ) AM_CONDITIONAL(HAVE_UHD, test "x$with_uhd" == "xyes" ) AM_CONDITIONAL(HAVE_SOAPY, test "x$with_soapy" == "xyes" ) diff --git a/src/libimage/img.c b/src/libimage/img.c index ccc79bb..42f2c43 100755 --- a/src/libimage/img.c +++ b/src/libimage/img.c @@ -6,24 +6,24 @@ int save_depth = 16; #ifdef HAVE_MAGICK -#include +#include /* load given image to memory. return short RGB values */ unsigned short *load_img(int *width, int *height, const char *filename, int index) { Image *image = NULL; ImageInfo *imageinfo = NULL; - ExceptionInfo exception; + ExceptionInfo *exception; unsigned short *img = NULL; MagickCoreGenesis(NULL, MagickFalse); // InitializeMagick(NULL); imageinfo = CloneImageInfo(0); - GetExceptionInfo(&exception); + exception = AcquireExceptionInfo(); sprintf(imageinfo->filename, filename, index); - image = ReadImage(imageinfo, &exception); + image = ReadImage(imageinfo, exception); if (!image) { // printf("failed to read image '%s' via *magick\n", filename); goto exit; @@ -48,6 +48,9 @@ exit: if (imageinfo) DestroyImageInfo(imageinfo); + if (exception) + DestroyExceptionInfo(exception); + MagickCoreTerminus(); // DestroyMagick(); @@ -60,18 +63,18 @@ int save_img(unsigned short *img, int width, int height, int alpha, const char * int rc = -1; Image *image = NULL; ImageInfo *imageinfo = NULL; - ExceptionInfo exception; + ExceptionInfo *exception; MagickCoreGenesis(NULL, MagickFalse); // InitializeMagick(NULL); imageinfo = CloneImageInfo(0); - GetExceptionInfo(&exception); + exception = AcquireExceptionInfo(); imageinfo->quality = 100; if (strlen(filename) >= 4 && !strcmp(filename + strlen(filename) - 4, ".png")) 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) { printf("%s:failed to prepare to write image\n", __func__); goto exit; @@ -81,7 +84,7 @@ int save_img(unsigned short *img, int width, int height, int alpha, const char * image->depth = save_depth; 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__); goto exit; } @@ -95,6 +98,9 @@ exit: if (imageinfo) DestroyImageInfo(imageinfo); + if (exception) + DestroyExceptionInfo(exception); + MagickCoreTerminus(); // DestroyMagick(); diff --git a/src/tv/main.c b/src/tv/main.c index 7331c1d..897bf26 100644 --- a/src/tv/main.c +++ b/src/tv/main.c @@ -377,7 +377,7 @@ static int tx_img(const char *filename) img = load_img(&width, &height, filename, 0); if (!img) { - fprintf(stderr, "Failed to load grey image '%s'\n", filename); + fprintf(stderr, "Failed to load image '%s'\n", filename); return -1; }