--- psiconv/trunk/program/psiconv/magick-aux.c 2000/12/10 16:49:40 58 +++ psiconv/trunk/program/psiconv/magick-aux.c 2014/10/20 11:44:17 343 @@ -1,6 +1,6 @@ /* magick-aux.c - Part of psiconv, a PSION 5 file formats converter - Copyright (c) 2000 Frodo Looijaard + Copyright (c) 2000-2005 Frodo Looijaard This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,25 +22,95 @@ #if IMAGEMAGICK #include "magick-aux.h" -#include -#include -/* This is so ugly, but it is the only way to make ImageMagick 5 behave - * properly. It really needs a better interface. - * OpenModules makes sure all needed modules are loaded. But it may not - * be called until some things are initialized, hence the extra - * GetMagickInfo call. Ugh. - */ +#endif + +#ifdef DMALLOC +#include "dmalloc.h" +#endif + +#if IMAGEMAGICK -extern void OpenModules(void); +/* This used to be very ugly, but nowadays it is much better */ -MagickInfo * GetMagickFileList(void) +#if IMAGEMAGICK_API == 1 || IMAGEMAGICK_API == 2 +const MagickInfo ** GetMagickFileList(void) { - GetMagickInfo(NULL); -#if defined(HasLTDL) - OpenModules(); -#endif - return GetMagickInfo(NULL); + int len,i; + const MagickInfo *ptr; + const MagickInfo *mi_ptr; + const MagickInfo **copy; + ExceptionInfo exc; + GetExceptionInfo(&exc); + OpenModules(&exc); + + mi_ptr = GetMagickInfo(NULL,&exc); + for (len = 0, ptr=mi_ptr; ptr != NULL; len++, ptr = ptr->next); + copy = malloc((len+1) * sizeof(*copy)); + for (i=0, ptr=mi_ptr; ptr != NULL; i++, ptr = ptr->next) + copy[i] = ptr; + copy[len] = NULL; + return copy; +} + +#elif IMAGEMAGICK_API == 3 + +const MagickInfo ** GetMagickFileList(void) +{ + MagickInfo **mi; + const MagickInfo **copy; + unsigned long len; + int i; + ExceptionInfo exc; + GetExceptionInfo(&exc); + OpenModules(&exc); + mi = GetMagickInfoList("*",&len); + copy = malloc((len+1) * sizeof(*copy)); + for (i = 0; i < len; i++) { + copy[i] = mi[i]; + } + copy[len] = NULL; + return copy; } +#elif IMAGEMAGICK_API == 4 + +const MagickInfo ** GetMagickFileList(void) +{ + MagickInfo **mi; + const MagickInfo **copy; + unsigned long len; + int i; + ExceptionInfo exc; + GetExceptionInfo(&exc); + OpenModules(&exc); + mi = GetMagickInfoList("*",&len,&exc); + copy = malloc((len+1) * sizeof(*copy)); + for (i = 0; i < len; i++) { + copy[i] = mi[i]; + } + copy[len] = NULL; + return copy; +} + +#elif IMAGEMAGICK_API == 100 +/* GraphicsMagick library */ +const MagickInfo ** GetMagickFileList(void) +{ + int i,len; + MagickInfo **mi; + const MagickInfo **copy; + ExceptionInfo exception; + GetExceptionInfo(&exception); + mi = GetMagickInfoArray(&exception); + for (len = 0; mi[len]; len++); + copy = malloc((len+1) * sizeof(*copy)); + for (i = 0; i <= len; i++) { + copy[i] = mi[i]; + } + return copy; +} + +#endif + #endif /* IMAGEMAGICK */