-
Notifications
You must be signed in to change notification settings - Fork 13
/
tvpic.c
57 lines (46 loc) · 970 Bytes
/
tvpic.c
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
#include "dis.h"
#include "lodepng.h"
static void convert_word (unsigned char *x)
{
word_t word = 0;
int i;
for (i = 0; i < 32; i++)
{
word <<= 1;
if (x[0] > 10)
word |= 1;
x += 4;
}
word <<= 4;
write_word (stdout, word);
}
static void convert_line (unsigned char *x)
{
int i;
for (i = 0; i < 18; i++)
convert_word (x + i * 4*32);
}
int main (int argc, char *argv[])
{
unsigned error;
unsigned char* image = 0;
unsigned width, height;
int y;
error = lodepng_decode32_file(&image, &width, &height, argv[1]);
if(error)
{
fprintf (stderr, "error %u: %s\n", error, lodepng_error_text (error));
exit (1);
}
if (width != 01100)
{
fprintf (stderr, "Picture must be 576 pixels wide.\n");
exit (1);
}
fprintf (stderr, "Picture is %d pixels high.\n", height);
for (y = 0; y < height; y++)
{
convert_line (image + y * 576 * 4);
}
return 0;
}