用c#修改图片曝光度的方法 我想编一个图片编辑器 ,用c# 怎样实现曝光度大小的调节呢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 *******************************请参阅下面两个例子的代码**********************************************下面的代码是将彩色图像变为单色图像的例子。GetPixel(i, j)是用来获得(i, j)位置处的颜色,它包括红绿蓝三色。看下例就明白了private void ToolStripMenuItemGrayR_Click(object sender, EventArgs e) { Bitmap b = new Bitmap(pictureBox1 .Image );//把图片框1中的图片给一个bitmap类型 Bitmap b1 = new Bitmap(pictureBox1.Image); Color c = new Color(); //Graphics g1 = pictureBox1.CreateGraphics();//容器设为图片框1 for (int i = 0; i < pictureBox1.Image.Width ; i++) for (int j = 0; j < pictureBox1.Image.Height; j++) { c = b1.GetPixel(i, j); Color c1 = Color.FromArgb(c.B, c.B, c.B);//用FromArgb方法由颜色分量值创建Color结构 b1.SetPixel(i, j, c1); //pictureBox2.Image = b1; //pictureBox2.Refresh(); } pictureBox2.Image = b1; pictureBox2.Refresh(); }再下面这一例,可以得到图片中各个物体的轮廓 private void ToolStripMenuItemOutline_Click(object sender, EventArgs e) { Color c1 = new Color(); // Represents an ARGB (alpha, red, green, blue) color. Color c2 = new Color(); Color c3 = new Color(); Color c4 = new Color(); int rr, gg, bb, r1, r2, r3, r4, fxr, fyr, i, j; int g1, g2, g3, g4, fxg, fyg, b1, b2, b3, b4, fxb, fyb; Bitmap box1 = new Bitmap(pictureBox1.Image);//把图片框中的图片给一个bitmap类型// Encapsulates a GDI+ bitmap, which consists of the pixel data for a graphics // image and its attributes. for (i = 0; i < pictureBox1.Image.Width -1 ; i++) { for (j = 0; j < pictureBox1.Image.Height - 1; j++) { c1 = box1.GetPixel(i, j); // GetPixel(i, j) Gets the color of the specified pixel in this System.Drawing.Bitmap. c2 = box1.GetPixel(i + 1, j + 1); c3 = box1.GetPixel(i + 1, j); c4 = box1.GetPixel(i, j + 1); r1 = c1.R; r2 = c2.R; r3 = c3.R; r4 = c4.R; fxr = r1 - r2; fyr = r3 - r4; rr = Math.Abs(fxr) + Math.Abs(fyr) ; // Math.Abs(fyr) Returns the absolute value of a 32-bit signed integer. if (rr < 0) rr = 0; if (rr > 255) rr = 255; g1 = c1.G; g2 = c2.G; g3 = c3.G; g4 = c4.G; fxg = g1 - g2; fyg = g3 - g4; gg = Math.Abs(fxg) + Math.Abs(fyg) ; if (gg < 0) gg = 0; if (gg > 255) gg = 255; b1 = c1.B; b2 = c2.B; b3 = c3.B; b4 = c4.B; fxb = b1 - b2; fyb = b3 - b4; bb = Math.Abs(fxb) + Math.Abs(fyb) ; if (bb < 0) bb = 0; if (bb > 255) bb = 255; Color cc = Color.FromArgb(rr, gg, bb);//用FromArgb由颜色分量值创建Color结构 //Color cc = Color.FromArgb(rr, rr, rr);//用FromArgb由颜色分量值创建Color结构.获得单色图像 // Color.FromArgb(rr, gg, bb) Creates a System.Drawing.Color structure from the specified 8-bit color values // (red, green, and blue). The alpha value is implicitly 255 (fully opaque). // Although this method allows a 32-bit value to be passed for each color component, // the value of each component is limited to 8 bits. box1.SetPixel(i, j, cc); // box1.SetPixel(i, j, cc) Sets the color of the specified pixel in this System.Drawing.Bitmap. pictureBox2.Image = box1; label2.Text = Convert.ToString(cc .B ); } pictureBox2.Refresh();//刷新 pictureBox2.Image = box1; } 菜单开发 请教个问题 C/S 客户端上传文件到服务器 C#的windows命名空间不能引用 急!!C# 调用c的DLL时提示“尝试读取或写入受保护内存...” C#连接数据库 .net三层架构;AJAX 关于Sleep? 请问如何向Web窗体中写入数据?(如果分数不够可以再加) 问:如果我在一个触发的事件a中又触发了一个事件b,那么,这两个事件是不是同步执行的?还是要等b执行完后a 才能继续执行 请教高手讲讲析构函数的理解 急!!!B/S混合C/S问题。B/S中有会话管理,请问在C/S中如何实现???
*******************************请参阅下面两个例子的代码**********************************************下面的代码是将彩色图像变为单色图像的例子。GetPixel(i, j)是用来获得(i, j)位置处的颜色,它包括红绿蓝三色。看下例就明白了private void ToolStripMenuItemGrayR_Click(object sender, EventArgs e)
{
Bitmap b = new Bitmap(pictureBox1 .Image );//把图片框1中的图片给一个bitmap类型
Bitmap b1 = new Bitmap(pictureBox1.Image);
Color c = new Color();
//Graphics g1 = pictureBox1.CreateGraphics();//容器设为图片框1
for (int i = 0; i < pictureBox1.Image.Width ; i++)
for (int j = 0; j < pictureBox1.Image.Height; j++)
{
c = b1.GetPixel(i, j);
Color c1 = Color.FromArgb(c.B, c.B, c.B);//用FromArgb方法由颜色分量值创建Color结构
b1.SetPixel(i, j, c1);
//pictureBox2.Image = b1;
//pictureBox2.Refresh();
}
pictureBox2.Image = b1;
pictureBox2.Refresh(); }再下面这一例,可以得到图片中各个物体的轮廓 private void ToolStripMenuItemOutline_Click(object sender, EventArgs e)
{
Color c1 = new Color(); // Represents an ARGB (alpha, red, green, blue) color.
Color c2 = new Color();
Color c3 = new Color();
Color c4 = new Color();
int rr, gg, bb, r1, r2, r3, r4, fxr, fyr, i, j;
int g1, g2, g3, g4, fxg, fyg, b1, b2, b3, b4, fxb, fyb;
Bitmap box1 = new Bitmap(pictureBox1.Image);//把图片框中的图片给一个bitmap类型// Encapsulates a GDI+ bitmap, which consists of the pixel data for a graphics
// image and its attributes.
for (i = 0; i < pictureBox1.Image.Width -1 ; i++)
{
for (j = 0; j < pictureBox1.Image.Height - 1; j++)
{
c1 = box1.GetPixel(i, j); // GetPixel(i, j) Gets the color of the specified pixel in this System.Drawing.Bitmap.
c2 = box1.GetPixel(i + 1, j + 1);
c3 = box1.GetPixel(i + 1, j);
c4 = box1.GetPixel(i, j + 1);
r1 = c1.R;
r2 = c2.R;
r3 = c3.R;
r4 = c4.R;
fxr = r1 - r2;
fyr = r3 - r4;
rr = Math.Abs(fxr) + Math.Abs(fyr) ; // Math.Abs(fyr) Returns the absolute value of a 32-bit signed integer.
if (rr < 0) rr = 0;
if (rr > 255) rr = 255;
g1 = c1.G;
g2 = c2.G;
g3 = c3.G;
g4 = c4.G;
fxg = g1 - g2;
fyg = g3 - g4;
gg = Math.Abs(fxg) + Math.Abs(fyg) ;
if (gg < 0) gg = 0;
if (gg > 255) gg = 255;
b1 = c1.B;
b2 = c2.B;
b3 = c3.B;
b4 = c4.B;
fxb = b1 - b2;
fyb = b3 - b4;
bb = Math.Abs(fxb) + Math.Abs(fyb) ;
if (bb < 0) bb = 0;
if (bb > 255) bb = 255;
Color cc = Color.FromArgb(rr, gg, bb);//用FromArgb由颜色分量值创建Color结构
//Color cc = Color.FromArgb(rr, rr, rr);//用FromArgb由颜色分量值创建Color结构.获得单色图像
// Color.FromArgb(rr, gg, bb) Creates a System.Drawing.Color structure from the specified 8-bit color values
// (red, green, and blue). The alpha value is implicitly 255 (fully opaque).
// Although this method allows a 32-bit value to be passed for each color component,
// the value of each component is limited to 8 bits.
box1.SetPixel(i, j, cc); // box1.SetPixel(i, j, cc) Sets the color of the specified pixel in this System.Drawing.Bitmap.
pictureBox2.Image = box1;
label2.Text = Convert.ToString(cc .B );
}
pictureBox2.Refresh();//刷新
pictureBox2.Image = box1;
}