0
|
1 |
#include "bitmap.h"
|
|
2 |
#include "stdio.h"
|
|
3 |
|
|
4 |
Bitmap::Bitmap(char* b, int h, int w)
|
|
5 |
{
|
|
6 |
bits = b;
|
|
7 |
height = h;
|
|
8 |
width = w;
|
|
9 |
}
|
|
10 |
|
|
11 |
Bitmap::Bitmap(char* filename)
|
|
12 |
{
|
|
13 |
}
|
|
14 |
|
|
15 |
void Bitmap::WriteToFile(char* filename)
|
|
16 |
{
|
|
17 |
FILE* fileout;
|
|
18 |
if(! (fileout = fopen(filename, "w+")))
|
|
19 |
{
|
|
20 |
printf("Error while trying to write bitmap to %s\n", filename);
|
|
21 |
exit(1);
|
|
22 |
}
|
|
23 |
else
|
|
24 |
{
|
|
25 |
fprintf(fileout, "#define %s_width %d\n", filename, width);
|
|
26 |
fprintf(fileout, "#define %s_height %d\n", filename, height);
|
|
27 |
fprintf(fileout, "static char %s_bits[] = {\n", filename);
|
|
28 |
for(int row_counter = 0; row_counter < height; row_counter++)
|
|
29 |
{
|
|
30 |
for(int column_counter = 0; (8 * column_counter) < width; column_counter++)
|
|
31 |
{
|
|
32 |
fprintf(fileout, "%c,", bits[row_counter * width + column_counter]);
|
|
33 |
if((column_counter % 16) == 0)
|
|
34 |
fprintf(fileout, "\n"); /* put a newline once in a while */
|
|
35 |
}
|
|
36 |
}
|
|
37 |
fprintf(fileout, "};\n");
|
|
38 |
fclose(fileout);
|
|
39 |
}
|
|
40 |
}
|
|
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|