使用MagickWand API从PNG转换为JPG时,如何为透明像素将背景设置为白色?
答案 0 :(得分:3)
if(current_wand && IsMagickWand(current_wand)){
status=MagickReadImage(current_wand, "test.png");
if (status == MagickFalse) {
ThrowWandException(current_wand);
}
PixelWand *color = NewPixelWand();
PixelSetColor(color, "white");
MagickSetImageBackgroundColor(current_wand, color);
MagickWand *newwand = MagickMergeImageLayers(current_wand, FlattenLayer);
MagickWriteImage(newwand, "test.jpg");
DestroyMagickWand(newwand);
}
答案 1 :(得分:1)
使用MagickMergeImageLayers