透明背景 - 显示为黑色(将 pcx 转换为 png)

问题描述 投票:0回答:1

我的目标是将 pcx 图像转换为 png。 pcx 图像具有透明背景和白线\草图。

我尝试使用以下方法转换它:

magick convert abc.pcx abc.png
magick convert abc.pcx -flatten abc.png
magick convert abc.pcx -background white -flatten abc.png

我也尝试过以编程方式进行(这是我的最终目标)但什么都没有

using (var magickImage = new MagickImage(file))
{
magickImage.Format = MagickFormat.Png;

 // this one kind of works, it does make the background
 // transparent but the lines\sketch has white lines and black
 // (only at the sketch)
 // where we need transparent background and black lines\sketch
 // magickImage.FloodFill(MagickColors.Transparent, 0, 0);

var filePng = Path.ChangeExtension(file, ".png");
magickImage.Write(filePng);
}

仅供参考 - 当 .pcx 图像在 adobe express 中打开时正确显示 - 带黑线的透明背景。 在 ImageMagick (IMDisplay) 中打开时显示黑色背景和白线。

这是 .pcx 和转换后的 .png 的链接 https://drive.google.com/file/d/1x2fWswUFWL6hrLRCW1zuztC1Cry-QDqY/view?usp=sharing

有什么想法我需要做什么吗?

image imagemagick processing transparent
1个回答
0
投票

这里是如何实现的:

using (var magickImage = new MagickImage(file))
{
   magickImage.Format = MagickFormat.Png;
   magickImage.Negate();
   magickImage.Transparent(MagickColors.White);

   var filePng = Path.ChangeExtension(file, ".png");                    
   magickImage.Write(filePng);
}
© www.soinside.com 2019 - 2024. All rights reserved.