如何建立逆PNG图像? [英] How to create inverse png image?

查看:175
本文介绍了如何建立逆PNG图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建png图片这画在我的基地,从基地,我可以保存为PNG图像,供大家参考。

i am creating png image which painted on my base, from the base i can save a png image, for your reference

Graphics g = e.Graphics;
 ....
g.DrawLine(pen, new Point(x, y), new Point(x1, y1));
 .....
base.OnPaint(e);

using (var bmp = new Bitmap(500, 50))
{
    base.DrawToBitmap(bmp, new Rectangle(0, 0, 500, 50));
    bmp.Save(outPath);
}

这是单色透明的形象,现在我怎么也逆这一形象像PNG填充任何颜色和真实图像部分应该是透明的,是没有任何可能性?

this is single color transparency image, now how do i can inverse this image like png filled with any color and the real image portion should be transparent, is there any possibilities?

一些细节:那么透明会去不透明,哪里有补会去透明

bit detail : so transparent will go nontransparent and where there is fill will go to transparent

推荐答案

修改(thaks为的托马斯符号)

EDIT (thaks for Thomas notation)

public void ApplyInvert()  
{  
    byte A, R, G, B;  
    Color pixelColor;  

    for (int y = 0; y < bitmapImage.Height; y++)  
    {  
        for (int x = 0; x < bitmapImage.Width; x++)  
        {  
            pixelColor = bitmapImage.GetPixel(x, y);  
            A = (byte)(255 - pixelColor.A); 
            R = pixelColor.R;  
            G = pixelColor.G;  
            B = pixelColor.B;  
            bitmapImage.SetPixel(x, y, Color.FromArgb((int)A, (int)R, (int)G, (int)B));  
        }  
    }  
}

从这里开始:在C#中图像处理:反转图像

这篇关于如何建立逆PNG图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆