pictureBox本身是没有这个功能的,建议使用GDI+来实现。 可以参考http://www.codeproject.com/script/Articles/list_articles.asp?userid=6556 这里的GDI+文章来实现。 Image Processing for Dummies with C# and GDI+ Part 1 - Per Pixel Filters The first in a series of articles which will build an image processing library in C# and GDI+ Image Processing for Dummies with C# and GDI+ Part 2 - Convolution Filters The second in a series of articles which will build an image processing library in C# and GDI+ Image Processing for Dummies with C# and GDI+ Part 3 - Edge Detection Filters The third in a series of articles which will build an image processing library in C# and GDI+ Image Processing for Dummies with C# and GDI+ Part 4 - Bilinear Filters and Resizing The fourth installment covers how to write a filter that resizes an image, and uses bilinear filtering Image Processing for Dummies with C# and GDI+ Part 5 - Displacement filters, including swirl In the fifth installment, we build a framework for generating filters that work by changing a pixel's location, rather than colour. Image Processing for Dummies with C# and GDI+ Part 6 - The HSL color space A discussion of the HSL color space, including code for a color picker and image filters
試下這樣可以嗎 if(this.openFileDialog1.ShowDialog()==DialogResult.OK) { bmp=new Bitmap(this.openFileDialog1.FileName); for (int i=0;i<bmp.Width-1;i++) { for(int j=0;j<bmp.Height-1;j++) { Color Color1=bmp.GetPixel(i,j); Color Color2=bmp.GetPixel(i+1,j+1); int red=Math.Abs(Color1.R-Color2.R+128); int green=Math.Abs(Color1.G-Color2.G+128); int blue=Math.Abs(Color1.B-Color2.B+128); //晇伎揭燴 if(red>255) red=255; if(red<0) red=0; if(green>255) green=255; if(green<0) green=0; if(blue>255) blue=255; if(blue<0) blue=0; bmp.SetPixel(i,j,Color.FromArgb(red,green,blue)); } } this.pictureBox1.Image=bmp; } 此代碼可以改變圖片顯示.你可以擴展為你所需要的
agree upto... reusable classes such as PhotoHelper that contains methods to adjust the brightness, contrast, saturation, gamma, convert to grayscale and sepia, rotate, flip, resize and crop images.
图象的色调你编写程序去对图象进行处理.
可以参考http://www.codeproject.com/script/Articles/list_articles.asp?userid=6556
这里的GDI+文章来实现。
Image Processing for Dummies with C# and GDI+ Part 1 - Per Pixel Filters
The first in a series of articles which will build an image processing library in C# and GDI+ Image Processing for Dummies with C# and GDI+ Part 2 - Convolution Filters
The second in a series of articles which will build an image processing library in C# and GDI+ Image Processing for Dummies with C# and GDI+ Part 3 - Edge Detection Filters
The third in a series of articles which will build an image processing library in C# and GDI+ Image Processing for Dummies with C# and GDI+ Part 4 - Bilinear Filters and Resizing
The fourth installment covers how to write a filter that resizes an image, and uses bilinear filtering Image Processing for Dummies with C# and GDI+ Part 5 - Displacement filters, including swirl
In the fifth installment, we build a framework for generating filters that work by changing a pixel's location, rather than colour. Image Processing for Dummies with C# and GDI+ Part 6 - The HSL color space
A discussion of the HSL color space, including code for a color picker and image filters
if(this.openFileDialog1.ShowDialog()==DialogResult.OK)
{
bmp=new Bitmap(this.openFileDialog1.FileName);
for (int i=0;i<bmp.Width-1;i++)
{
for(int j=0;j<bmp.Height-1;j++)
{
Color Color1=bmp.GetPixel(i,j);
Color Color2=bmp.GetPixel(i+1,j+1);
int red=Math.Abs(Color1.R-Color2.R+128);
int green=Math.Abs(Color1.G-Color2.G+128);
int blue=Math.Abs(Color1.B-Color2.B+128);
//晇伎揭燴
if(red>255) red=255;
if(red<0) red=0; if(green>255) green=255;
if(green<0) green=0; if(blue>255) blue=255;
if(blue<0) blue=0;
bmp.SetPixel(i,j,Color.FromArgb(red,green,blue));
}
}
this.pictureBox1.Image=bmp;
}
此代碼可以改變圖片顯示.你可以擴展為你所需要的
http://msdn.microsoft.com/smartclient/codesamples/fotovision/default.aspx
{
Bitmap bmp=(Bitmap)this.pictureBox1.Image;
try
{Color pixelColor=bmp.GetPixel(e.X,e.Y);
this.Text="("+pixelColor.R.ToString()+","+
pixelColor.G.ToString()+","+pixelColor.B.ToString()+")";
}
catch {}
}
這段代碼可以獲得圖片上任意點的RGB信息.
這樣做的處理速度非常的慢,你可以考慮用CopyMemery API函數把圖像的像素二進制數據讀取出來,然後再作處理。