Support both versions of ImageMagick: 6 and 7
This commit is contained in:
committed by
Andreas Eversberg
parent
7b0168c713
commit
5dc6844c90
@@ -36,7 +36,8 @@ AS_IF([test "x$with_alsa" != xno], [PKG_CHECK_MODULES(ALSA, alsa >= 1.0, with_al
|
|||||||
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_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.8.0, soapy_0_8_0_or_higher="-DSOAPY_0_8_0_OR_HIGHER", soapy_0_8_0_or_higher=)])
|
AS_IF([test "x$with_soapy" != xno], [PKG_CHECK_MODULES(SOAPY, SoapySDR >= 0.8.0, soapy_0_8_0_or_higher="-DSOAPY_0_8_0_OR_HIGHER", soapy_0_8_0_or_higher=)])
|
||||||
AS_IF([test "x$with_soapy" != xno], [PKG_CHECK_MODULES(SOAPY, SoapySDR >= 0.5.0, with_sdr=yes with_soapy=yes, with_soapy=no)])
|
AS_IF([test "x$with_soapy" != xno], [PKG_CHECK_MODULES(SOAPY, SoapySDR >= 0.5.0, with_sdr=yes with_soapy=yes, with_soapy=no)])
|
||||||
AS_IF([test "x$with_imagemagick" != xno], [PKG_CHECK_MODULES(IMAGEMAGICK, ImageMagick >= 7.0.0, with_imagemagick=yes, with_imagemagick=no)])
|
AS_IF([test "x$with_imagemagick" != xno], [PKG_CHECK_MODULES(IMAGEMAGICK6, ImageMagick >= 6.0.0, with_imagemagick6=yes, with_imagemagick6=no)])
|
||||||
|
AS_IF([test "x$with_imagemagick" != xno], [PKG_CHECK_MODULES(IMAGEMAGICK7, ImageMagick >= 7.0.0, with_imagemagick7=yes with_imagemagick6=no, with_imagemagick7=no)])
|
||||||
AS_IF([test "x$with_fuse" != xno], with_fuse=check)
|
AS_IF([test "x$with_fuse" != xno], with_fuse=check)
|
||||||
AS_IF([test "x$with_fuse" == xcheck], [PKG_CHECK_MODULES(FUSE, fuse3 >= 0.30.0, with_fuse=yes, with_fuse=check)])
|
AS_IF([test "x$with_fuse" == xcheck], [PKG_CHECK_MODULES(FUSE, fuse3 >= 0.30.0, with_fuse=yes, with_fuse=check)])
|
||||||
AS_IF([test "x$with_fuse" == xcheck], [PKG_CHECK_MODULES(FUSE, fuse2 >= 0.29.0, with_fuse=yes, with_fuse=check)])
|
AS_IF([test "x$with_fuse" == xcheck], [PKG_CHECK_MODULES(FUSE, fuse2 >= 0.29.0, with_fuse=yes, with_fuse=check)])
|
||||||
@@ -46,12 +47,13 @@ AM_CONDITIONAL(HAVE_ALSA, test "x$with_alsa" == "xyes" )
|
|||||||
AM_CONDITIONAL(HAVE_UHD, test "x$with_uhd" == "xyes" )
|
AM_CONDITIONAL(HAVE_UHD, test "x$with_uhd" == "xyes" )
|
||||||
AM_CONDITIONAL(HAVE_SOAPY, test "x$with_soapy" == "xyes" )
|
AM_CONDITIONAL(HAVE_SOAPY, test "x$with_soapy" == "xyes" )
|
||||||
AM_CONDITIONAL(HAVE_SDR, test "x$with_sdr" == "xyes" )
|
AM_CONDITIONAL(HAVE_SDR, test "x$with_sdr" == "xyes" )
|
||||||
AM_CONDITIONAL(HAVE_MAGICK, test "x$with_imagemagick" == "xyes" )
|
AM_CONDITIONAL(HAVE_MAGICK6, test "x$with_imagemagick6" == "xyes" )
|
||||||
|
AM_CONDITIONAL(HAVE_MAGICK7, test "x$with_imagemagick7" == "xyes" )
|
||||||
AM_CONDITIONAL(HAVE_FUSE, test "x$with_fuse" == "xyes" )
|
AM_CONDITIONAL(HAVE_FUSE, test "x$with_fuse" == "xyes" )
|
||||||
AS_IF([test "x$with_alsa" == "xyes"],[AC_MSG_NOTICE( Compiling with Alsa support )], [AC_MSG_NOTICE( Alsa sound card not supported. Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. )])
|
AS_IF([test "x$with_alsa" == "xyes"],[AC_MSG_NOTICE( Compiling with Alsa support )], [AC_MSG_NOTICE( Alsa sound card not supported. Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. )])
|
||||||
AS_IF([test "x$with_uhd" == "xyes"],[AC_MSG_NOTICE( Compiling with UHD SDR support )], [AC_MSG_NOTICE( UHD SDR not supported. Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. )])
|
AS_IF([test "x$with_uhd" == "xyes"],[AC_MSG_NOTICE( Compiling with UHD SDR support )], [AC_MSG_NOTICE( UHD SDR not supported. Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. )])
|
||||||
AS_IF([test "x$with_soapy" == "xyes"],[AC_MSG_NOTICE( Compiling with SoapySDR support )], [AC_MSG_NOTICE( SoapySDR not supported. Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. )])
|
AS_IF([test "x$with_soapy" == "xyes"],[AC_MSG_NOTICE( Compiling with SoapySDR support )], [AC_MSG_NOTICE( SoapySDR not supported. Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. )])
|
||||||
AS_IF([test "x$with_imagemagick" == "xyes"],[AC_MSG_NOTICE( Compiling with ImageMagick )],[AC_MSG_NOTICE( ImageMagick not supported. Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. )])
|
AS_IF([test "x$with_imagemagick6" == "xyes" || "x$with_imagemagick7" == "xyes"],[AC_MSG_NOTICE( Compiling with ImageMagick )],[AC_MSG_NOTICE( ImageMagick not supported. Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. )])
|
||||||
AS_IF([test "x$with_fuse" == "xyes"],[AC_MSG_NOTICE( Compiling with FUSE )],[AC_MSG_NOTICE( FUSE not supported. There will be no analog modem support. Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. )])
|
AS_IF([test "x$with_fuse" == "xyes"],[AC_MSG_NOTICE( Compiling with FUSE )],[AC_MSG_NOTICE( FUSE not supported. There will be no analog modem support. Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. )])
|
||||||
|
|
||||||
AS_IF([test "x$with_alsa" != "xyes" -a "x$with_sdr" != "xyes"],[AC_MSG_NOTICE( Without sound nor SDR support this project does not make sense. Please support sound card for analog transceivers or better SDR!" )],[])
|
AS_IF([test "x$with_alsa" != "xyes" -a "x$with_sdr" != "xyes"],[AC_MSG_NOTICE( Without sound nor SDR support this project does not make sense. Please support sound card for analog transceivers or better SDR!" )],[])
|
||||||
|
@@ -1,12 +1,15 @@
|
|||||||
AM_CPPFLAGS = -Wall -Wextra -Wmissing-prototypes -g $(all_includes) \
|
AM_CPPFLAGS = -Wall -Wextra -Wmissing-prototypes -g $(all_includes) \
|
||||||
$(IMAGEMAGICK_CFLAGS)
|
$(IMAGEMAGICK6_CFLAGS) $(IMAGEMAGICK7_CFLAGS)
|
||||||
|
|
||||||
noinst_LIBRARIES = libimage.a
|
noinst_LIBRARIES = libimage.a
|
||||||
|
|
||||||
libimage_a_SOURCES = \
|
libimage_a_SOURCES = \
|
||||||
img.c
|
img.c
|
||||||
|
|
||||||
if HAVE_MAGICK
|
if HAVE_MAGICK6
|
||||||
AM_CPPFLAGS += -DHAVE_MAGICK
|
AM_CPPFLAGS += -DHAVE_MAGICK6
|
||||||
|
endif
|
||||||
|
if HAVE_MAGICK7
|
||||||
|
AM_CPPFLAGS += -DHAVE_MAGICK7
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@@ -5,25 +5,46 @@
|
|||||||
|
|
||||||
int save_depth = 16;
|
int save_depth = 16;
|
||||||
|
|
||||||
#ifdef HAVE_MAGICK
|
#if defined(HAVE_MAGICK6) || (HAVE_MAGICK7)
|
||||||
|
|
||||||
|
#if defined(HAVE_MAGICK6)
|
||||||
|
#include <magick/MagickCore.h>
|
||||||
|
#endif
|
||||||
|
#if defined(HAVE_MAGICK7)
|
||||||
#include <MagickCore/MagickCore.h>
|
#include <MagickCore/MagickCore.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
/* 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;
|
||||||
|
#if defined(HAVE_MAGICK6)
|
||||||
|
ExceptionInfo exception;
|
||||||
|
#endif
|
||||||
|
#if defined(HAVE_MAGICK7)
|
||||||
ExceptionInfo *exception;
|
ExceptionInfo *exception;
|
||||||
|
#endif
|
||||||
unsigned short *img = NULL;
|
unsigned short *img = NULL;
|
||||||
|
|
||||||
MagickCoreGenesis(NULL, MagickFalse);
|
MagickCoreGenesis(NULL, MagickFalse);
|
||||||
// InitializeMagick(NULL);
|
// InitializeMagick(NULL);
|
||||||
imageinfo = CloneImageInfo(0);
|
imageinfo = CloneImageInfo(0);
|
||||||
|
#if defined(HAVE_MAGICK6)
|
||||||
|
GetExceptionInfo(&exception);
|
||||||
|
#endif
|
||||||
|
#if defined(HAVE_MAGICK7)
|
||||||
exception = AcquireExceptionInfo();
|
exception = AcquireExceptionInfo();
|
||||||
|
#endif
|
||||||
|
|
||||||
sprintf(imageinfo->filename, filename, index);
|
sprintf(imageinfo->filename, filename, index);
|
||||||
|
|
||||||
|
#if defined(HAVE_MAGICK6)
|
||||||
|
image = ReadImage(imageinfo, &exception);
|
||||||
|
#endif
|
||||||
|
#if defined(HAVE_MAGICK7)
|
||||||
image = ReadImage(imageinfo, exception);
|
image = ReadImage(imageinfo, exception);
|
||||||
|
#endif
|
||||||
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,8 +69,10 @@ exit:
|
|||||||
if (imageinfo)
|
if (imageinfo)
|
||||||
DestroyImageInfo(imageinfo);
|
DestroyImageInfo(imageinfo);
|
||||||
|
|
||||||
|
#if defined(HAVE_MAGICK7)
|
||||||
if (exception)
|
if (exception)
|
||||||
DestroyExceptionInfo(exception);
|
DestroyExceptionInfo(exception);
|
||||||
|
#endif
|
||||||
|
|
||||||
MagickCoreTerminus();
|
MagickCoreTerminus();
|
||||||
// DestroyMagick();
|
// DestroyMagick();
|
||||||
@@ -63,18 +86,33 @@ 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;
|
||||||
|
#if defined(HAVE_MAGICK6)
|
||||||
|
ExceptionInfo exception;
|
||||||
|
#endif
|
||||||
|
#if defined(HAVE_MAGICK7)
|
||||||
ExceptionInfo *exception;
|
ExceptionInfo *exception;
|
||||||
|
#endif
|
||||||
|
|
||||||
MagickCoreGenesis(NULL, MagickFalse);
|
MagickCoreGenesis(NULL, MagickFalse);
|
||||||
// InitializeMagick(NULL);
|
// InitializeMagick(NULL);
|
||||||
imageinfo = CloneImageInfo(0);
|
imageinfo = CloneImageInfo(0);
|
||||||
|
#if defined(HAVE_MAGICK6)
|
||||||
|
GetExceptionInfo(&exception);
|
||||||
|
#endif
|
||||||
|
#if defined(HAVE_MAGICK7)
|
||||||
exception = AcquireExceptionInfo();
|
exception = AcquireExceptionInfo();
|
||||||
|
#endif
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
|
#if defined(HAVE_MAGICK6)
|
||||||
|
image=ConstituteImage(width, height, (alpha)?"RGBA":"RGB", ShortPixel, img, &exception);
|
||||||
|
#endif
|
||||||
|
#if defined(HAVE_MAGICK7)
|
||||||
image=ConstituteImage(width, height, (alpha)?"RGBA":"RGB", ShortPixel, img, exception);
|
image=ConstituteImage(width, height, (alpha)?"RGBA":"RGB", ShortPixel, img, exception);
|
||||||
|
#endif
|
||||||
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;
|
||||||
@@ -84,7 +122,12 @@ 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 defined(HAVE_MAGICK6)
|
||||||
|
if (!WriteImage(imageinfo, image)) {
|
||||||
|
#endif
|
||||||
|
#if defined(HAVE_MAGICK7)
|
||||||
if (!WriteImage(imageinfo, image, exception)) {
|
if (!WriteImage(imageinfo, image, exception)) {
|
||||||
|
#endif
|
||||||
printf("%s:failed to write image\n", __func__);
|
printf("%s:failed to write image\n", __func__);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
@@ -98,8 +141,10 @@ exit:
|
|||||||
if (imageinfo)
|
if (imageinfo)
|
||||||
DestroyImageInfo(imageinfo);
|
DestroyImageInfo(imageinfo);
|
||||||
|
|
||||||
|
#if defined(HAVE_MAGICK7)
|
||||||
if (exception)
|
if (exception)
|
||||||
DestroyExceptionInfo(exception);
|
DestroyExceptionInfo(exception);
|
||||||
|
#endif
|
||||||
|
|
||||||
MagickCoreTerminus();
|
MagickCoreTerminus();
|
||||||
// DestroyMagick();
|
// DestroyMagick();
|
||||||
@@ -262,12 +307,6 @@ int save_img_array(double *array, int width, int height, int alpha, const char *
|
|||||||
unsigned short *img = NULL;
|
unsigned short *img = NULL;
|
||||||
int components;
|
int components;
|
||||||
|
|
||||||
#ifndef HAVE_MAGICK
|
|
||||||
if (alpha) {
|
|
||||||
printf("%s:warning, cannot save alpha component with PPM support only\n", __func__);
|
|
||||||
alpha = 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
components = (alpha) ? 4 : 3;
|
components = (alpha) ? 4 : 3;
|
||||||
|
|
||||||
img = (unsigned short *)malloc(width * height * components * 2);
|
img = (unsigned short *)malloc(width * height * components * 2);
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
AM_CPPFLAGS = -Wall -Wextra -Wmissing-prototypes -g $(all_includes) \
|
AM_CPPFLAGS = -Wall -Wextra -Wmissing-prototypes -g $(all_includes)
|
||||||
$(IMAGEMAGICK_CFLAGS)
|
|
||||||
|
|
||||||
bin_PROGRAMS = \
|
bin_PROGRAMS = \
|
||||||
osmotv
|
osmotv
|
||||||
@@ -28,7 +27,7 @@ osmotv_LDADD = \
|
|||||||
$(top_builddir)/src/liblogging/liblogging.a \
|
$(top_builddir)/src/liblogging/liblogging.a \
|
||||||
$(LIBOSMOCORE_LIBS) \
|
$(LIBOSMOCORE_LIBS) \
|
||||||
$(ALSA_LIBS) \
|
$(ALSA_LIBS) \
|
||||||
$(IMAGEMAGICK_LIBS) \
|
$(IMAGEMAGICK6_LIBS) $(IMAGEMAGICK7_LIBS) \
|
||||||
-lm
|
-lm
|
||||||
|
|
||||||
if HAVE_SDR
|
if HAVE_SDR
|
||||||
@@ -51,7 +50,3 @@ if HAVE_SDR
|
|||||||
AM_CPPFLAGS += -DHAVE_SDR
|
AM_CPPFLAGS += -DHAVE_SDR
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if HAVE_MAGICK
|
|
||||||
AM_CPPFLAGS += -DHAVE_MAGICK
|
|
||||||
endif
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user