먼저 바이트를 얻을 :
ImageConverter
public static byte[] ImageToByte(Image img)
{
ImageConverter converter = new ImageConverter();
return (byte[])converter.ConvertTo(img, typeof(byte[]));
}
또는 메모리 스트림
public static byte[] ImageToByte2(Image img)
{
byte[] byteArray = new byte[0];
using (MemoryStream stream = new MemoryStream())
{
img.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
stream.Close();
byteArray = stream.ToArray();
}
return byteArray;
}
그런 다음 원하는 다차원 배열 변환합니다.
byte[][] multi = new byte[height][];
for (int y = 0; y < height; ++y)
{
multi[y] = new byte[width];
// Do optional translation of the byte into your own format here
// For purpose of illustration, here is a straight copy
Array.Copy(bitmapBytes, width * y, multi[y], 0, width);
}
예, 가능하다고 생각합니다. 너 뭐 해봤 니? –
Ive는 다른 stackoverflow 대답을 사용하기 전에 이것을 시도했지만 문제는 바이트 응답으로 전체 파일을 출력한다는 것이 었습니다. 색상과 같은 보이는 정보 만 원했습니다. – Mavain
비트 맵에는 모든 픽셀이 있습니다. 무엇이 문제일까요 ?? 파일에 데이터가 있습니까? 어떤 형식? 시도해 봤어? 'Bitmap bmp = new Bitmap ("yourImageFile");으로 시작하십시오. for (int x .. color (int x ..) color c = bmp.GetPixel (x, y); if (c == Color.White) .. ' – TaW