I have an image, that has a sequence of two frames. The second frame is supposed to be an alpha mask for the first frame.
Here is an example:
http://i.imgur.com/c2M10u7.png
I've written the following code using Magick++ to split the image into two halves, and apply the alpha mask:
Code: Select all
#include "stdafx.h"
#include <iostream>
#include <Magick++.h>
int main(int argc, char **argv)
{
Magick::InitializeMagick(*argv);
Magick::Image base, mask;
std::string image;
if (argc > 1)
{
image = argv[1];
}
else
return EXIT_FAILURE;
// Read image
base.read(image);
mask = base;
// Crop out mask and sprite
base.crop(Magick::Geometry(base.columns() / 2, base.rows(), 0, 0));
mask.crop(Magick::Geometry(mask.columns() / 2, mask.rows(), mask.columns() / 2, 0));
// Apply mask
base.composite(mask, 0, 0, Magick::BlendCompositeOp);
// Write
base.write("output.png");
return EXIT_SUCCESS;
}
Any help would be greatly appreciated.