Cromon

Program.cs

Aug 23rd, 2013
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.82 KB | None | 0 0
  1.         static unsafe void Main(string[] args)
  2.         {
  3.             Bitmap bmp = Image.FromFile("Testfile.bmp") as Bitmap;
  4.             if (bmp.Width != 160 || bmp.Height != 43)
  5.                 throw new ArgumentException("Invalid bitmap size");
  6.  
  7.             byte[] buffer = new byte[160 * 43];
  8.             var bmpData = bmp.LockBits(new Rectangle(0, 0, 160, 43), System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppRgb);
  9.  
  10.             byte* pixel = (byte*)bmpData.Scan0.ToPointer();
  11.  
  12.             for (int y = 0, y_dest = 42; y < 43; ++y, --y_dest)
  13.             {
  14.                 for (int x = 0; x < 160; ++x)
  15.                 {
  16.                     buffer[y_dest * 160 + x] = pixel[(y * 160 + x) * 4];
  17.                 }
  18.             }
  19.  
  20.             bmp.UnlockBits(bmpData);
  21.         }
Advertisement
Add Comment
Please, Sign In to add comment