Advertisement
Guest User

Untitled

a guest
Jan 11th, 2017
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.79 KB | None | 0 0
  1.         byte[,] imgdata = new byte[128, 32]; // Contains the palette used on each pixel from x0y0 to x128y64
  2.         byte[] data;
  3.         int[] positions = new int[] { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 };
  4.  
  5.         public void load4bpp(int pos = 0)
  6.         {
  7.  
  8.             for (int j = 0; j < 4; j++)
  9.             {
  10.                 for (int i = 0; i < 16; i++)
  11.                 {
  12.                     int offset = (hexOffset + (pos * 0x800)) + ((j * 32) * 16) + (i * 32);
  13.                     for (int x = 0; x < 8; x++)
  14.                     {
  15.                         for (int y = 0; y < 8; y++)
  16.                         {
  17.                             byte tmpbyte = 0;
  18.  
  19.                             if ((data[offset + (x * 2)] & positions[y]) == positions[y])
  20.                             {
  21.                                 tmpbyte += 1;
  22.                             }
  23.                             if ((data[offset + (x * 2) + 1] & positions[y]) == positions[y])
  24.                             {
  25.                                 tmpbyte += 2;
  26.                             }
  27.  
  28.                             if ((data[offset + 16 + (x * 2)] & positions[y]) == positions[y])
  29.                             {
  30.                                 tmpbyte += 4;
  31.                             }
  32.                             if ((data[offset + 16 + (x * 2) + 1] & positions[y]) == positions[y])
  33.                             {
  34.                                 tmpbyte += 8;
  35.                             }
  36.                             imgdata[y+(i*8), x+(j*8)] = tmpbyte;
  37.  
  38.                         }
  39.                     }
  40.                 }
  41.             }  
  42.  
  43.         }
  44.  
  45. //To set create the image :
  46. for (int x = 0;x<128;x++)
  47. {
  48.  for (int y = 0; y < 32; y++)
  49.    {
  50.      image.SetPixel(x, y, palette[imgdata[x,y]]);
  51.    }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement