【发布时间】:2019-02-15 01:32:35
【问题描述】:
我希望从WMF 图像文件中删除所有颜色,只删除一种颜色。
Metafile img = new Metafile(path + strFilename + ".wmf");
float planScale = 0.06615f;
float scale = 1200f / (float)img.Width;
planScale = planScale / scale; ;
float widht = img.Width * scale;
float height = img.Height * scale;
using (var target = new Bitmap((int)widht, (int)height))
{
using (var g = Graphics.FromImage(target))
{
g.DrawImage(img, 0, 0, (int)widht, (int)height);
target.Save("image.png", ImageFormat.Png);
}
}
目前,我加载一个WMF 文件,设置比例并将其保存为PNG 文件。
但现在我需要删除所有颜色(绿色、紫色……)并只设置一种颜色,例如灰色。
【问题讨论】:
-
试试这个 - 因为你提到了灰色 - stackoverflow.com/questions/2265910/…
-
你想要一张只有白色或一个特定灰度值的二值图像,还是应该将不同的颜色映射到不同的灰度值?
-
如果你想要一个灰度,认为在RGB中,灰色调是那些R = G = B的颜色。如果你想要一个二值图像(黑色和白色),你需要选择一个阈值并将通道设置为 0 或 255(低于或高于阈值)。
标签: c# graphics colors png wmf