您可以修改copyBitmap2Array()
来将颜色RGB
保存到colorArray[y, x]
中吗?
结果,我想查看保存在colorArray中的rgb图像。
//Open 클릭
private void open_Click(object sender, EventArgs e) {
grBm = CreateGraphics();
ofdOpen.Title = "Open Image";
ofdOpen.Filter = "All Files(*.*) | *.*| Bitmap File(*.bmp) | *.bmp| JPEG File(*.jpg) | *.jpg";
if (ofdOpen.ShowDialog() == DialogResult.OK) {
string strFilename = ofdOpen.FileName;
image = Image.FromFile(strFilename);
this.ClientSize = new System.Drawing.Size(image.Width, image.Height);
setShadowBitmap();
grBm.DrawImage(image, 0, 0, image.Width, image.Height);
copyBitmap2Array();
}
Invalidate();
}
void copyBitmap2Array() {
int x, y, brightness;
Color color;
grayArray = new int[bitmap.Height, bitmap.Width];
for (y = 0; y < bitmap.Height; y++)
for (x = 0; x < bitmap.Width; x++) {
color = bitmap.GetPixel(x, y);
brightness = (int)(255.0 * color.GetBrightness());
// brightness = (int)( color.GetHue());
colorArray[y, x] = brightness;
}
}