Skip to content

Instantly share code, notes, and snippets.

@20chan
Created July 8, 2017 15:56
Show Gist options
  • Save 20chan/18fa14fa9f72d81a0f6d799982715177 to your computer and use it in GitHub Desktop.
Save 20chan/18fa14fa9f72d81a0f6d799982715177 to your computer and use it in GitHub Desktop.
Bitmap 을 Flatten하게 만들어서 1차원 배열로 만들어버리기
Bitmap b = new Bitmap(@"D:\Image\design\치워\히오스.png");
var bitmapData = b.LockBits(new Rectangle(0, 0, b.Width, b.Height), System.Drawing.Imaging.ImageLockMode.ReadWrite, b.PixelFormat);
var length = bitmapData.Stride * bitmapData.Height;
byte[] bytes = new byte[length];
// Copy bitmap to byte[]
Marshal.Copy(bitmapData.Scan0, bytes, 0, length);
b.UnlockBits(bitmapData);
System.Diagnostics.Debugger.Break();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment