使用MagickWand接口从PNG转换为JPG时,如何将透明像素的背景设置为指定的颜色?我仍然只得到我不想要的白色背景。
我知道有类似的问题,但没有答案= How to set background color for transparent pixels in MagickWand?
发布于 2010-11-30 21:34:18
我找到了..。我错过了MagickMergeImageLayers要归还新魔杖的消息!所以代码看起来像这样:
if(current_wand && IsMagickWand(current_wand)){
status=MagickReadImage(current_wand, "test.png");
if (status == MagickFalse) {
ThrowWandException(current_wand);
}
PixelWand *color = NewPixelWand();
PixelSetColor(color, "red");
MagickSetImageBackgroundColor(current_wand, color);
MagickWand *newwand = MagickMergeImageLayers(current_wand, FlattenLayer);
MagickWriteImage(newwand, "test.jpg");
DestroyMagickWand(newwand);
}
https://stackoverflow.com/questions/4314605
复制