![Image](https://1.baobeitu.com/upload/1806/04/1104123729!2.png)
convert 1.png -channel RGBA -separate ( +clone -remap pattern:gray50 ) +swap -combine 1.gif
1.gif
![Image](https://1.baobeitu.com/upload/1806/04/1104118678!2.gif)
If MagickWand APIs is used, what relevant APIs need to be used to implement this function?
please help me.
thanks.
Code: Select all
MagickWand *mw_rgba = NewMagickWand();
MagickReadImage(mw_rgba, "E:\\temp\\1.png");
MagickWand *mw_red = CloneMagickWand(mw_rgba);
MagickWand *mw_green = CloneMagickWand(mw_rgba);
MagickWand *mw_blue = CloneMagickWand(mw_rgba);
MagickWand *mw_alpha = CloneMagickWand(mw_rgba);
// -channel RGBA -separate ?
MagickSeparateImageChannel(mw_red, RedChannel);
MagickSeparateImageChannel(mw_green, GreenChannel);
MagickSeparateImageChannel(mw_blue, BlueChannel);
MagickSeparateImageChannel(mw_alpha, AlphaChannel);
// ( +clone -remap pattern:gray50 )
MagickWand *mw_clone = CloneMagickWand(mw_alpha); // +clone ?
MagickRemapImage(mw_clone, mw_rgba, FloydSteinbergDitherMethod); // -remap ?
MagickThresholdImage(mw_clone, QuantumRange * 50.0 / 100); // pattern:gray50 ?
// +swap -combine ?
MagickSetImageAlphaChannel(mw_clone, ActivateAlphaChannel);
//MagickSetImageAlphaChannel(mw_alpha, ActivateAlphaChannel);
MagickCompositeImage(mw_red, mw_green, CopyGreenCompositeOp, 0, 0);
MagickCompositeImage(mw_red, mw_blue, CopyBlueCompositeOp, 0, 0);
MagickCompositeImage(mw_red, mw_clone, CopyOpacityCompositeOp, 0, 0);
//MagickCompositeImage(mw_red, mw_alpha, CopyOpacityCompositeOp, 0, 0);
MagickAutoLevelImage(mw_red);
MagickWriteImage(mw_red, "E:\\temp\\3.gif");
Code: Select all
MagickWand *mw_rgba = NewMagickWand();
MagickReadImage(mw_rgba, "E:\\temp\\1.png");
MagickWand *mw_red = CloneMagickWand(mw_rgba);
MagickWand *mw_green = CloneMagickWand(mw_rgba);
MagickWand *mw_blue = CloneMagickWand(mw_rgba);
MagickWand *mw_alpha = CloneMagickWand(mw_rgba);
// -channel RGBA -separate ?
MagickSeparateImageChannel(mw_red, RedChannel);
MagickSeparateImageChannel(mw_green, GreenChannel);
MagickSeparateImageChannel(mw_blue, BlueChannel);
MagickSeparateImageChannel(mw_alpha, AlphaChannel);
// ( +clone -remap pattern:gray50 )
MagickWand *mw_clone = CloneMagickWand(mw_alpha); // +clone ?
MagickWand *mw_gray50 = CloneMagickWand(mw_rgba);
MagickThresholdImage(mw_gray50, QuantumRange * 50.0 / 100); // pattern:gray50 ?
MagickRemapImage(mw_clone, mw_gray50, FloydSteinbergDitherMethod); // -remap ?
// +swap -combine ?
MagickSetImageAlphaChannel(mw_clone, ActivateAlphaChannel);
MagickCompositeImage(mw_red, mw_green, CopyGreenCompositeOp, 0, 0);
MagickCompositeImage(mw_red, mw_blue, CopyBlueCompositeOp, 0, 0);
MagickCompositeImage(mw_red, mw_clone, CopyOpacityCompositeOp, 0, 0);
MagickAutoLevelImage(mw_red);
MagickWriteImage(mw_red, "E:\\temp\\3.gif");
Code: Select all
MagickWand *mw_clone = CloneMagickWand(mw_alpha); // +clone
MagickWand *mw_gray50 = CloneMagickWand(mw_rgba);
MagickThresholdImage(mw_gray50, QuantumRange * 95.0 / 100);
MagickRemapImage(mw_clone, mw_gray50, RiemersmaDitherMethod); // -remap
Code: Select all
MagickWand *mw_clone = CloneMagickWand(mw_alpha); // +clone
MagickWand *mw_gray50 = CloneMagickWand(mw_rgba);
MagickThresholdImageChannel(mw_gray50, AlphaChannel, QuantumRange * 50.0 / 100);
MagickOrderedPosterizeImage(mw_gray50, "o8x8,4");
MagickRemapImage(mw_clone, mw_gray50, RiemersmaDitherMethod); // -remap
Code: Select all
MagickWand *mw_rgba = NewMagickWand();
MagickReadImage(mw_rgba, "E:\\temp\\1.png");
MagickWand *mw_clone = CloneMagickWand(mw_rgba); // +clone ?
MagickWand *mw_gray50 = CloneMagickWand(mw_rgba);
MagickThresholdImageChannel(mw_gray50, AlphaChannel, QuantumRange * 50.0 / 100); // pattern:gray50 ?
MagickOrderedPosterizeImage(mw_gray50, "o8x8,4"); //(50 grey)
MagickRemapImage(mw_clone, mw_gray50, RiemersmaDitherMethod); // -remap ?
MagickSetImageAlphaChannel(mw_clone, ActivateAlphaChannel);
MagickCompositeImage(mw_rgba, mw_clone, CopyOpacityCompositeOp, 0, 0); // +swap -combine ?
MagickAutoLevelImage(mw_rgba);
MagickWriteImage(mw_rgba, "E:\\temp\\2.gif");