Bitmap
배열에서 int[]
배열로 픽셀 정보를 복사하려면 Marshal.Copy()
을 사용하고 있습니다. 문제는이 배열로 오는 정보가 모두 나오고 있다는 사실입니다 잘못, 같은 :Marshal.Copy()를 사용하여 비트 맵 int []
[0] = -8682109;
[1] = -8682109;
[2] = -8616573;
[3] = -8616573;
[4] = -8550527;
and so on...
메소드의 코드는 다음과 같습니다
private unsafe int[] BmpToBytes_Unsafe(Bitmap bmp)
{
BitmapData bData = bmp.LockBits(new Rectangle(new Point(), bmp.Size),
ImageLockMode.ReadOnly,
PixelFormat.Format32bppRgb);
// number of bytes in the bitmap
byteCount = bData.Stride * (bmp.Height);
int[] bytes = new int[byteCount/4];
Marshal.Copy(bData.Scan0, bytes, 0, byteCount/4);
// don't forget to unlock the bitmap!!
bmp.UnlockBits(bData);
return bytes;
나는 byte[]
배열, 정확 저장된 정보를 사용하여, 그래서 내가 무슨 일이 일어나고 있는지 모른다 이리.
문제는 Marshal.Copy 메서드가 uint []를 사용하지 않는다는 것입니다. RGB 구성 요소를 분리하면 어떻게 그 값을 조작 할 수 있습니까? –
Color.FromArgb()를 사용하면 int를 사용합니다. –