我正在尝试使用 Magick.Net 调整图像大小。但是我压缩的图像尺寸更大,位深度为 32,而原始图像的位深度为 2。我也想保留或减少位深度。这是我的代码。
var imageMacig = new MagickImage(filePath);
//Percentage p = new Percentage(60);
//imageMacig.Threshold(p); // 60 is OK
imageMacig.VirtualPixelMethod = VirtualPixelMethod.Transparent;
imageMacig.Depth = 1;
imageMacig.FilterType = FilterType.Quadratic;
imageMacig.Transparent(MagickColor.FromRgb(0,0,0));
imageMacig.Format = MagickFormat.Png00;
imageMacig.Resize(newWidth, newHeight);
imageMacig.Write(targetPath);
imageMacig.Dispose();
originalBMP.Dispose();