Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static unsafe void Main(string[] args)
- {
- Bitmap bmp = Image.FromFile("Testfile.bmp") as Bitmap;
- if (bmp.Width != 160 || bmp.Height != 43)
- throw new ArgumentException("Invalid bitmap size");
- byte[] buffer = new byte[160 * 43];
- var bmpData = bmp.LockBits(new Rectangle(0, 0, 160, 43), System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppRgb);
- byte* pixel = (byte*)bmpData.Scan0.ToPointer();
- for (int y = 0, y_dest = 42; y < 43; ++y, --y_dest)
- {
- for (int x = 0; x < 160; ++x)
- {
- buffer[y_dest * 160 + x] = pixel[(y * 160 + x) * 4];
- }
- }
- bmp.UnlockBits(bmpData);
- }
Advertisement
Add Comment
Please, Sign In to add comment