C#GDI+可以画灰度图么,用什么语句啊
答案:1 悬赏:20 手机版
解决时间 2021-11-09 19:23
- 提问者网友:疯子也有疯子的情调
- 2021-11-09 14:27
C#GDI+可以画灰度图么,用什么语句啊
最佳答案
- 五星知识达人网友:怀裏藏嬌
- 2021-11-09 15:12
Bitmap bmp = new Bitmap(100, 100);
using (Graphics g = Graphics.FromImage(bmp))
{
g.FillEllipse(Brushes.Red, new Rectangle(0, 0, 80, 80));
g.FillRectangle(new SolidBrush(Color.FromArgb(128, Color.Green)), new Rectangle(20, 20, 80, 80));
}
e.Graphics.DrawImage(bmp, new Point(10, 10));
//简单的
ControlPaint.DrawImageDisabled(e.Graphics, bmp, 120, 10, Color.White);
//用颜色矩阵
System.Drawing.Imaging.ImageAttributes attr = new System.Drawing.Imaging.ImageAttributes();
float[][] colorMatrixElements = {
new float[] {.33f, .33f, .33f, 0, 0}, // r = (r+g+b)/3
new float[] {.33f, .33f, .33f, 0, 0}, // g = (r+g+b)/3
new float[] {.33f, .33f, .33f, 0, 0}, // b = (r+g+b)/3
new float[] {0, 0, 0, 1, 0}, // alpha scaling factor of 1
new float[] {0, 0, 0, 0, 1}}; //
System.Drawing.Imaging.ColorMatrix matrix = new System.Drawing.Imaging.ColorMatrix(colorMatrixElements);
attr.SetColorMatrix(matrix);
e.Graphics.DrawImage(bmp, new Rectangle(10, 120, 100, 100), 0, 0, 100, 100, GraphicsUnit.Pixel, attr);C#中GDI+可以画灰度图么,用什么语句啊-CSDN论坛-CSDN.NET-中国最大的IT技术社区
http://bbs.csdn.net/topics/391016859?page=1
using (Graphics g = Graphics.FromImage(bmp))
{
g.FillEllipse(Brushes.Red, new Rectangle(0, 0, 80, 80));
g.FillRectangle(new SolidBrush(Color.FromArgb(128, Color.Green)), new Rectangle(20, 20, 80, 80));
}
e.Graphics.DrawImage(bmp, new Point(10, 10));
//简单的
ControlPaint.DrawImageDisabled(e.Graphics, bmp, 120, 10, Color.White);
//用颜色矩阵
System.Drawing.Imaging.ImageAttributes attr = new System.Drawing.Imaging.ImageAttributes();
float[][] colorMatrixElements = {
new float[] {.33f, .33f, .33f, 0, 0}, // r = (r+g+b)/3
new float[] {.33f, .33f, .33f, 0, 0}, // g = (r+g+b)/3
new float[] {.33f, .33f, .33f, 0, 0}, // b = (r+g+b)/3
new float[] {0, 0, 0, 1, 0}, // alpha scaling factor of 1
new float[] {0, 0, 0, 0, 1}}; //
System.Drawing.Imaging.ColorMatrix matrix = new System.Drawing.Imaging.ColorMatrix(colorMatrixElements);
attr.SetColorMatrix(matrix);
e.Graphics.DrawImage(bmp, new Rectangle(10, 120, 100, 100), 0, 0, 100, 100, GraphicsUnit.Pixel, attr);C#中GDI+可以画灰度图么,用什么语句啊-CSDN论坛-CSDN.NET-中国最大的IT技术社区
http://bbs.csdn.net/topics/391016859?page=1
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯