Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- byte[,] imgdata = new byte[128, 32]; // Contains the palette used on each pixel from x0y0 to x128y64
- byte[] data;
- int[] positions = new int[] { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 };
- public void load4bpp(int pos = 0)
- {
- for (int j = 0; j < 4; j++)
- {
- for (int i = 0; i < 16; i++)
- {
- int offset = (hexOffset + (pos * 0x800)) + ((j * 32) * 16) + (i * 32);
- for (int x = 0; x < 8; x++)
- {
- for (int y = 0; y < 8; y++)
- {
- byte tmpbyte = 0;
- if ((data[offset + (x * 2)] & positions[y]) == positions[y])
- {
- tmpbyte += 1;
- }
- if ((data[offset + (x * 2) + 1] & positions[y]) == positions[y])
- {
- tmpbyte += 2;
- }
- if ((data[offset + 16 + (x * 2)] & positions[y]) == positions[y])
- {
- tmpbyte += 4;
- }
- if ((data[offset + 16 + (x * 2) + 1] & positions[y]) == positions[y])
- {
- tmpbyte += 8;
- }
- imgdata[y+(i*8), x+(j*8)] = tmpbyte;
- }
- }
- }
- }
- }
- //To set create the image :
- for (int x = 0;x<128;x++)
- {
- for (int y = 0; y < 32; y++)
- {
- image.SetPixel(x, y, palette[imgdata[x,y]]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement