111,129
社区成员
发帖
与我相关
我的任务
分享
Color pixel = bitmap.GetPixel(j, i);
private void Form1_Load(object sender, EventArgs e)
{
pictureBox1.Load(@"C:\Documents and Settings\scai\My Documents\My Pictures\black cat.jpg");
}
private void button1_Click(object sender, EventArgs e)
{
Bitmap bitmap = pictureBox1.Image as Bitmap;
if (bitmap != null)
{
for (int i = 0; i < bitmap.Height; i++)
{
for (int j = 0; j < bitmap.Width; j++)
{
Color pixel = bitmap.GetPixel(j, i);
Console.WriteLine(pixel.R.ToString() + ", " + pixel.G.ToString() + ", " + pixel.B.ToString());
}
}
}
}
for (int xa = this.pictureBox1.Location.X; xa < this.pictureBox1.Width; xa += 1)
{
for (int ya = this.pictureBox1.Location.Y; ya <this.pictureBox1.Height; ya += 1)
{
swr.Write("坐标为{0} {1}", xa, ya);
//afil.Write (Convert .ToString (xa),)
Color pixelcolor = mybm.GetPixel(xa, ya);
byte red = pixelcolor.R;
byte green = pixelcolor.G;
byte blue = pixelcolor.B;
swr.Write("像素值R为{0},G为{1},B为{2}",Convert.ToInt16 (red ),Convert.ToInt16 (green ),Convert.ToInt16 (blue ));
swr.Write(Environment.NewLine);
}
swr.Write (Environment .NewLine );
}
swr .Close ();
afil .Close();