1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227
|
int main()
{
// Below is for the sprite.
//int Bitplane0_ROW[] = { 0b01100110 , 0b11111111, 0b01011010, 0b01111110, 0b00000000, 0b10000001, 0b11111111, 0b01111110 }; // Array to to store numbers Last Row is first.
//int Bitplane1_ROW[] = { 0b01111110, 0b11111111, 0b11111111, 0b11011011, 0b11111111, 0b01111110, 0b00000000, 0b00000000 };
//int Bitplane2_ROW[] = { 0b00000000 , 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000 };
//int Bitplane3_ROW[] = { 0b00000000 , 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000 };
// Colours 0 to 7
int Bitplane0_ROW[] = { 0b11111111, 0b00000000,0b11111111,0b00000000,0b11111111,0b00000000,0b11111111,0b00000000 };
int Bitplane1_ROW[] = { 0b11111111, 0b11111111,0b00000000,0b00000000,0b11111111,0b11111111,0b00000000,0b00000000 };
int Bitplane2_ROW[] = { 0b11111111, 0b11111111,0b11111111,0b11111111,0b00000000,0b00000000,0b00000000,0b00000000};
int Bitplane3_ROW[] = { 0b00000000, 0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000 };
/* Colours 8 - 15
int Bitplane0_ROW[] = { 0b11111111, 0b00000000,0b11111111,0b00000000,0b11111111,0b00000000,0b11111111,0b00000000 };
int Bitplane1_ROW[] = { 0b11111111, 0b11111111,0b00000000,0b00000000,0b11111111,0b11111111,0b00000000,0b00000000 };
int Bitplane2_ROW[] = { 0b11111111, 0b11111111,0b11111111,0b11111111,0b00000000,0b00000000,0b00000000,0b00000000 };
int Bitplane3_ROW[] = { 0b11111111, 0b11111111,0b11111111,0b11111111,0b11111111,0b11111111,0b11111111,0b11111111 };
*/
int N = 7; //to store bit
int c = 0;
BYTE* buf = new BYTE[8 * 5];
unsigned char White[] = {255, 255, 255};
unsigned char Green[] = {53, 189,104 }; ////////////////
unsigned char Brown[] = {59,85,142 }; /////////////////////
unsigned char Tan[] = {154,194,237 };
unsigned char Yellow[] = {0, 255, 255 }; /////////////
unsigned char Red[] = { 0,0,255 }; ///////////////////
unsigned char Blue[] = { 255,0,0 };
unsigned char Grey[] = { 128,128,128 };
unsigned char Purple[] = {255,0,255 };
unsigned char Black[] = { 0,0,0 };
unsigned char Aqua[] = {255,255,0};
unsigned char Orange[] = { 0,191,255 };
unsigned char Maroon[] = { 0,0,128 };
unsigned char Navy[] = { 128,0,0 };
unsigned char Lime[] = { 0,255,0 };
unsigned char Teal[] = { 128,128,0 };
unsigned char red[] = { 255, 104, 142, 154, 0, 0, 255 };
unsigned char green[] = { 255, 189, 85, 194, 255, 0, 0};
unsigned char blue[] = { 255, 53, 59, 237, 255, 255, 0 };
for (int p = 0; p < 8; p++)
{
for (int j = 0; j < 8; j++) // Row 6
{
std::bitset<4> bs;
bs.set(0, (Bitplane0_ROW[p] >> N) & 1);
bs.set(1, (Bitplane1_ROW[p] >> N) & 1);
bs.set(2, (Bitplane2_ROW[p] >> N) & 1);
bs.set(3, (Bitplane3_ROW[p] >> N) & 1);
unsigned long Index = bs.to_ulong();
cout << "The value is " << Index;
if(Index == 0) // White
{
buf[c + 0] = red[Index];
buf[c + 1] = green[Index];
buf[c + 2] = blue[Index];
}
else if (Index == 1) // Green
{
buf[c + 0] = red[Index];
buf[c + 1] = green[Index];
buf[c + 2] = blue[Index];
}
else if (Index == 2) // Brown
{
buf[c + 0] = blue[Index];
buf[c + 1] = green[Index];
buf[c + 2] = red[Index];
}
else if (Index == 3) // Tan
{
buf[c + 0] = red[Index];
buf[c + 1] = green[Index];
buf[c + 2] = blue[Index];
}
else if (Index == 4) // Yellow
{
buf[c + 0] = red[Index];
buf[c + 1] = green[Index];
buf[c + 2] = blue[Index];
}
else if (Index == 5) // red
{
buf[c + 0] = red[Index];
buf[c + 1] = green[Index];
buf[c + 2] = blue[Index];
}
else if (Index == 6)
{
// Index 6 (Blue)
buf[c + 0] = red[Index];
buf[c + 1] = green[Index];
buf[c + 2] = blue[Index];
}
else if (Index == 7)
{
// Index 7 (Grey)
Index = 0;
buf[c + 0] = Grey[Index];
buf[c + 1] = Grey[Index + 1];
buf[c + 2] = Grey[Index + 2];
}
else if (Index == 8)
{
// Index 8 (Purple)
Index = 0;
buf[c + 0] = Purple[Index];
buf[c + 1] = Purple[Index + 1];
buf[c + 2] = Purple[Index + 2];
}
else if (Index == 9)
{
// Index 9 (Black)
Index = 0;
buf[c + 0] = Black[Index];
buf[c + 1] = Black[Index + 1];
buf[c + 2] = Black[Index + 2];
}
else if (Index == 10)
{
// Index 10 (Aqua)
Index = 0;
buf[c + 0] = Aqua[Index];
buf[c + 1] = Aqua[Index + 1];
buf[c + 2] = Aqua[Index + 2];
}
else if (Index == 11)
{
// Index 11 (Orange)
Index = 0;
buf[c + 0] = Orange[Index];
buf[c + 1] = Orange[Index + 1];
buf[c + 2] = Orange[Index + 2];
}
else if (Index == 12)
{
// Index 12 (Maroon)
Index = 0;
buf[c + 0] = Maroon[Index];
buf[c + 1] = Maroon[Index + 1];
buf[c + 2] = Maroon[Index + 2];
}
else if (Index == 13)
{
// Index 13 (Navy)
Index = 0;
buf[c + 0] = Navy[Index];
buf[c + 1] = Navy[Index + 1];
buf[c + 2] = Navy[Index + 2];
}
else if (Index == 14)
{
// Index 14 (Lime)
Index = 0;
buf[c + 0] = Lime[Index];
buf[c + 1] = Lime[Index + 1];
buf[c + 2] = Lime[Index + 2];
}
else if (Index == 15)
{
// Index 15 (Teal)
Index = 0;
buf[c + 0] = Teal[Index];
buf[c + 1] = Teal[Index+1];
buf[c + 2] = Teal[Index+2];
}
c += 3;
N--;
}
N = 7;
}
SaveBitmapToFile((BYTE*)buf, 8, 8, 24, 0, "C:\\Users\\Chris\\Desktop\\Link_Sprite.bmp");
delete[] buf;
return 0;
|