File migrate-to-ImageMagick7.patch of Package digikam4
--- a/extra/kipi-plugins/videoslideshow/magickiface/magickiface.cpp 2017-06-03 02:40:37.468892096 +0200
+++ b/extra/kipi-plugins/videoslideshow/magickiface/magickiface.cpp 2017-06-03 12:54:16.615582508 +0200
@@ -118,7 +118,7 @@
MagickImage* img = 0;
unsigned char pixels[4];
- ExceptionInfo exception;
+ ExceptionInfo* exception;
/* initialize the pixel data */
memset(pixels, 0, sizeof(pixels));
@@ -133,9 +133,9 @@
img->setWidth(1);
img->setHeight(1);
- GetExceptionInfo(&exception);
+ exception = AcquireExceptionInfo();
- if (!(img->setImage(ConstituteImage(1, 1, "RGB", CharPixel, pixels, &exception))))
+ if (!(img->setImage(ConstituteImage(1, 1, "RGB", CharPixel, pixels, exception))))
{
parent->Q_EMIT signalsAPIError("ConstituteImage() failed");
parent->freeImage(*img);
@@ -144,16 +144,16 @@
img->getImage()->compression = UndefinedCompression;
img->getImage()->depth = 16;
- DestroyExceptionInfo(&exception);
+ DestroyExceptionInfo(exception);
return img;
}
- void blendPixel(PixelPacket* const dst, PixelPacket* const src0, PixelPacket* const src1, float a)
+ void blendPixel(Quantum* const dst, Quantum* const src0, Quantum* const src1, float a)
{
- dst->red = blendPixelColor(src0->red, src1->red, a);
- dst->blue = blendPixelColor(src0->blue, src1->blue, a);
- dst->green = blendPixelColor(src0->green, src1->green, a);
+ SetPixelRed(m_image, blendPixelColor(GetPixelRed(src0), GetPixelRed(src1), a), dst);
+ SetPixelBlue(m_image, blendPixelColor(GetPixelBlue(src0), GetPixelBlue(src1), a), dst);
+ SetPixelGreen(m_image, blendPixelColor(GetPixelGreen(src0), GetPixelGreen(src1), a), dst);
}
short unsigned int blendPixelColor(short unsigned int color0, short unsigned int color1, float a)
@@ -198,17 +198,20 @@
MagickImage* MagickApi::loadQImage(const QImage& qimage)
{
MagickImage* img = 0;
- PixelPacket* img_data = 0;
+ Quantum* img_data = 0;
Image* image = 0;
int x, y;
+ ExceptionInfo* exception;
img = d->allocImage();
if (!img)
return 0;
+ exception = AcquireExceptionInfo();
+
if (!(image = ResizeImage(img->getImage(), qimage.width(), qimage.height(), SCALE_FILTER_FAST,
- 1.0, &img->getImage()->exception)))
+ exception)))
{
Q_EMIT signalsAPIError("ResizeImage() failed\n");
freeImage(*img);
@@ -220,7 +223,7 @@
img->setWidth(img->getImage()->columns);
img->setHeight(img->getImage()->rows);
- if (!(img_data = GetAuthenticPixels(img->getImage(), 0, 0, img->getWidth(), img->getHeight(), &img->getImage()->exception)))
+ if (!(img_data = GetAuthenticPixels(img->getImage(), 0, 0, img->getWidth(), img->getHeight(), exception)))
{
Q_EMIT signalsAPIError("GetImagePixels() failed\n");
freeImage(*img);
@@ -232,14 +235,16 @@
for (x = 0 ; x < img->getWidth() ; x++)
{
QColor rgb = qimage.pixel(x, y);
- img_data->red = rgb.red() * USHRT_MAX / UCHAR_MAX;
- img_data->green = rgb.green() * USHRT_MAX / UCHAR_MAX ;
- img_data->blue = rgb.blue() * USHRT_MAX / UCHAR_MAX ;
- img_data++;
+ SetPixelRed(image, rgb.red() * USHRT_MAX / UCHAR_MAX, img_data);
+ SetPixelGreen(image, rgb.green() * USHRT_MAX / UCHAR_MAX, img_data);
+ SetPixelBlue(image, rgb.blue() * USHRT_MAX / UCHAR_MAXimg_data);
+ img_data+=GetPixelChannels(image);
}
}
- SyncAuthenticPixels(img->getImage(), &img->getImage()->exception);
+ SyncAuthenticPixels(img->getImage(), exception);
+
+ DestroyExceptionInfo(exception);
return img;
}
@@ -248,14 +253,14 @@
{
MagickImage* img = 0;
ImageInfo* info = 0;
- ExceptionInfo exception;
+ ExceptionInfo* exception;
img = d->allocImage();
if (!img)
return 0;
- GetExceptionInfo(&exception);
+ exception = AcquireExceptionInfo();
if (!(info = CloneImageInfo((ImageInfo*) NULL)))
{
@@ -272,7 +277,7 @@
if (img->getImage())
DestroyImage(img->getImage());
- if (!(img->setImage(ReadImage(info, &exception))))
+ if (!(img->setImage(ReadImage(info, exception))))
{
Q_EMIT signalsAPIError("ReadImage(%s) failed\n");
freeImage(*img);
@@ -282,7 +287,7 @@
img->setWidth(img->getImage()->columns);
img->setHeight(img->getImage()->rows);
DestroyImageInfo(info);
- DestroyExceptionInfo(&exception);
+ DestroyExceptionInfo(exception);
return img;
}
@@ -296,14 +301,14 @@
int fileHandle = stream.handle();
MagickImage* img = 0;
ImageInfo* info = 0;
- ExceptionInfo exception;
+ ExceptionInfo* exception;
img = d->allocImage();
if (!img)
return 0;
- GetExceptionInfo(&exception);
+ exception = AcquireExceptionInfo();
if (!(info = CloneImageInfo((ImageInfo*) NULL)))
{
@@ -318,7 +323,7 @@
if (img->getImage())
DestroyImage(img->getImage());
- if (!(img->setImage(ReadImage(info,&exception))))
+ if (!(img->setImage(ReadImage(info,exception))))
{
Q_EMIT signalsAPIError("ReadImage(%s) failed\n");
freeImage(*img);
@@ -328,7 +333,7 @@
img->setWidth(img->getImage()->columns);
img->setHeight(img->getImage()->rows);
DestroyImageInfo(info);
- DestroyExceptionInfo(&exception);
+ DestroyExceptionInfo(exception);
return img;
}
@@ -336,6 +341,7 @@
int MagickApi::saveToFile(const MagickImage& img, const QString& file)
{
ImageInfo* info = 0;
+ ExceptionInfo* exception;
if (!(info = CloneImageInfo(NULL)))
{
@@ -354,18 +360,23 @@
strcpy(img.getImage()->filename, nfile.toAscii());
strcpy(img.getImage()->magick, "PPM");
img.getImage()->depth = 8;
-
- if (WriteImage(info, img.getImage()) != MagickTrue)
+ exception = AcquireExceptionInfo();
+
+ if (WriteImage(info, img.getImage(), exception) != MagickTrue)
{
Q_EMIT signalsAPIError("WriteImage() failed\n");
return -1;
}
+ DestroyExceptionInfo(exception);
+
return 1;
}
int MagickApi::saveToStream(const MagickImage& img, QFile& stream)
{
+ ExceptionInfo* exception;
+
if (stream.isOpen())
stream.close();
@@ -387,14 +398,16 @@
strcpy(img.getImage()->filename, "");
strcpy(img.getImage()->magick, "PPM");
img.getImage()->depth = 8;
+ exception = AcquireExceptionInfo();
- if (WriteImage(info,img.getImage()) != MagickTrue)
+ if (WriteImage(info,img.getImage(),exception) != MagickTrue)
{
Q_EMIT signalsAPIError("WriteImage() failed\n");
return -1;
}
DestroyImageInfo(info);
+ DestroyExceptionInfo(exception);
return 1;
}
@@ -403,18 +416,18 @@
{
MagickImage* img = 0;
Image* image = 0;
- ExceptionInfo exception;
+ ExceptionInfo* exception;
img = d->allocImage();
if (!img)
return 0;
- GetExceptionInfo(&exception);
- QueryColorDatabase(color.toAscii(), &img->getImage()->background_color, &img->getImage()->exception);
- SetImageBackgroundColor(img->getImage());
+ exception = AcquireExceptionInfo();
+ QueryColorCompliance(color.toAscii(), AllCompliance, &img->getImage()->background_color, exception);
+ SetImageBackgroundColor(img->getImage(), exception);
- if (!(image = ResizeImage(img->getImage(), width, height, SCALE_FILTER_FAST, 1.0, &exception)))
+ if (!(image = ResizeImage(img->getImage(), width, height, SCALE_FILTER_FAST, exception)))
{
Q_EMIT signalsAPIError("ResizeImage() failed\n");
freeImage(*img);
@@ -425,7 +438,7 @@
img->setImage(image);
img->setWidth(img->getImage()->columns);
img->setHeight(img->getImage()->rows);
- DestroyExceptionInfo(&exception);
+ DestroyExceptionInfo(exception);
if (img->getWidth() != width || img->getHeight() != height)
{
@@ -440,26 +453,26 @@
MagickImage* MagickApi::duplicateImage(const MagickImage& src)
{
MagickImage* dst = 0;
- ExceptionInfo exception;
+ ExceptionInfo* exception;
dst = d->allocImage();
if (!dst)
return 0;
- GetExceptionInfo(&exception);
+ exception = AcquireExceptionInfo();
if (dst->getImage())
DestroyImage(dst->getImage());
- if (!(dst->setImage(CloneImage(src.getImage(), 0, 0, (MagickBooleanType)1, &exception))))
+ if (!(dst->setImage(CloneImage(src.getImage(), 0, 0, (MagickBooleanType)1, exception))))
{
Q_EMIT signalsAPIError("CloneImageInfo() failed\n");
freeImage(*dst);
return 0;
}
- DestroyExceptionInfo(&exception);
+ DestroyExceptionInfo(exception);
dst->setWidth(src.getWidth());
dst->setHeight(src.getHeight());
@@ -479,9 +492,9 @@
{
Image* cropped = 0;
Image* source = src.getImage();
- ExceptionInfo exception;
+ ExceptionInfo* exception;
- GetExceptionInfo(&exception);
+ exception = AcquireExceptionInfo();
if (sx != 0 || sy != 0 || w != src.getWidth() || h != src.getHeight())
{
@@ -491,14 +504,14 @@
geometry.width = w;
geometry.height = h;
- if (!(source = cropped = CropImage(src.getImage(), &geometry, &exception)))
+ if (!(source = cropped = CropImage(src.getImage(), &geometry, exception)))
{
Q_EMIT signalsAPIError("CropImage() failed\n");
return -1;
}
}
- if (CompositeImage(dst.getImage(), SrcOverCompositeOp, source, dx, dy) != MagickTrue)
+ if (CompositeImage(dst.getImage(), source, SrcOverCompositeOp, MagickFalse, dx, dy, exception) != MagickTrue)
{
Q_EMIT signalsAPIError("CompositeImage() failed\n");
return -1;
@@ -507,17 +520,18 @@
if (cropped)
DestroyImage(cropped);
- DestroyExceptionInfo(&exception);
+ DestroyExceptionInfo(exception);
return 1;
}
int MagickApi::blendImage(MagickImage& dst, const MagickImage& src0, const MagickImage& src1, float a)
{
- PixelPacket* src0_data = 0;
- PixelPacket* src1_data = 0;
- PixelPacket* dst_data = 0;
+ Quantum* src0_data = 0;
+ Quantum* src1_data = 0;
+ Quantum* dst_data = 0;
int x, y;
+ ExceptionInfo* exception = AcquireExceptionInfo();
/* check if the size matches */
if (src0.getWidth() != src1.getWidth() || src0.getHeight() != src1.getHeight())
@@ -532,19 +546,19 @@
return -1;
}
- if (!(src0_data = GetAuthenticPixels(src0.getImage(), 0, 0, src0.getWidth(), src0.getHeight(), &src0.getImage()->exception)))
+ if (!(src0_data = GetAuthenticPixels(src0.getImage(), 0, 0, src0.getWidth(), src0.getHeight(), exception)))
{
Q_EMIT signalsAPIError("GetImagePixels() failed\n");
return -1;
}
- if (!(src1_data = GetAuthenticPixels(src1.getImage(), 0, 0, src1.getWidth(), src1.getHeight(), &src1.getImage()->exception)))
+ if (!(src1_data = GetAuthenticPixels(src1.getImage(), 0, 0, src1.getWidth(), src1.getHeight(), exception)))
{
Q_EMIT signalsAPIError("GetImagePixels() failed\n");
return -1;
}
- if (!(dst_data = GetAuthenticPixels(dst.getImage(), 0, 0, dst.getWidth(), dst.getHeight(), &dst.getImage()->exception)))
+ if (!(dst_data = GetAuthenticPixels(dst.getImage(), 0, 0, dst.getWidth(), dst.getHeight(), exception)))
{
Q_EMIT signalsAPIError("GetImagePixels() failed\n");
return -1;
@@ -557,13 +571,14 @@
for (x = 0 ; x < dst.getHeight() ; x++)
{
d->blendPixel(dst_data, src0_data, src1_data, a);
- src0_data++;
- src1_data++;
- dst_data++;
+ src0_data+=GetPixelChannels(src0.getImage());
+ src1_data+=GetPixelChannels(src1.getImage());
+ dst_data+=GetPixelChannels(dst.getImage());
}
}
- SyncAuthenticPixels(dst.getImage(), &dst.getImage()->exception);
+ SyncAuthenticPixels(dst.getImage(), exception);
+ DestroyExceptionInfo(exception);
return 1;
}
@@ -638,13 +653,13 @@
int MagickApi::scaleImage(MagickImage& img, int width, int height)
{
Image* image = 0;
- ExceptionInfo exception;
+ ExceptionInfo* exception;
if (img.getWidth() != width || img.getHeight() != height)
{
- GetExceptionInfo(&exception);
+ exception = AcquireExceptionInfo();
- if (!(image = ResizeImage(img.getImage(), width, height,(FilterTypes)d->filter, 1.0, &exception)))
+ if (!(image = ResizeImage(img.getImage(), width, height,(FilterType)d->filter, exception)))
{
Q_EMIT signalsAPIError("ResizeImage() failed\n");
return -1;
@@ -654,7 +669,7 @@
img.setImage(image);
img.setWidth(img.getImage()->columns);
img.setHeight(img.getImage()->rows);
- DestroyExceptionInfo(&exception);
+ DestroyExceptionInfo(exception);
if (img.getWidth() != width || img.getHeight() != height)
{
@@ -674,6 +689,7 @@
#endif
ImageInfo* info = 0;
+ ExceptionInfo* exception;
if (!(info = CloneImageInfo((ImageInfo*) NULL)))
{
@@ -681,7 +697,9 @@
return false;
}
- MagickBooleanType done = DisplayImages(info, img.getImage());
+ exception = AcquireExceptionInfo();
+ MagickBooleanType done = DisplayImages(info, img.getImage(), exception);
+ DestroyExceptionInfo(exception);
if (done == MagickTrue)
return true;
--- b/extra/kipi-plugins/videoslideshow/magickiface/magickiface.h 2017-06-03 02:17:07.909965802 +0200
+++ b/extra/kipi-plugins/videoslideshow/magickiface/magickiface.h 2017-06-03 02:17:26.325965333 +0200
@@ -39,7 +39,7 @@
#define MAGICKCORE_QUANTUM_DEPTH 16
#define QuantumDepth MAGICKCORE_QUANTUM_DEPTH
-#include <magick/api.h>
+#include <MagickCore/MagickCore.h>
#define SCALE_FILTER_BEST GaussianFilter
#define SCALE_FILTER_FAST PointFilter