-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2.c
116 lines (105 loc) · 2.53 KB
/
2.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
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
#include <graphics.h>
#include <stdio.h>
#include <conio.h>
struct header
{
unsigned int bfType;
long bfSize;
unsigned int bfReserved1;
unsigned int bfReserved2;
long bfoffBits;
};
struct tinfoheader
{
long biSize;
long biWidth;
long biHeight;
unsigned int biPlanes;
unsigned int biBitCount;
long biCompression;
long biSizeImage;
long biXPelsPerMeter;
long biYPelsPerMeter;
long biClrUsed;
long biClrImportant;
};
struct header HEADER;
struct tinfoheader INFO;
unsigned char charbuf[40000];
void Loadfile()
{
int i, ld;
FILE *fp;
char *bmpfile = "c:\\test.bmp";
fp = fopen(bmpfile, "rb");
fseek(fp, 0, SEEK_SET);
fseek(fp, 0, SEEK_END);
ld = ftell(fp);
fclose(fp);
fp = fopen(bmpfile, "rb");
if (fp != NULL) {
fread(&charbuf, ld, 1, fp);
fclose(fp);
}
fp = fopen(bmpfile, "rt");
if (fp != NULL) {
fread(&HEADER, sizeof(struct header), 1, fp);
fread(&INFO, sizeof(struct tinfoheader), 1, fp);
fclose(fp);
}
}
void showpic(int x,int y)
{
int i, j, k, l = 0;
int num, m, x0, x1, x2;
unsigned char b,c,c1;
m = INFO.biWidth / 32;
if ((INFO.biWidth % 32) != 0) {
m = m + 1;
}
num = HEADER.bfoffBits;
for (l = INFO.biHeight - 1; l >= 0; l--) {
for (i = 0; i < m; i++) {
x0 = i << 5;
for (j = 0; j < 4; j++)
{
x1 = j << 3;
c = charbuf[num];
num++;
for (k = 7; k >= 0; k--)
{
x2 = x0 + x1 + 7 - k;
if (x2 >= INFO.biWidth) {
continue;
}
else {
b = 1 << k;
c1 = c & b;
if (c1 == 0) {
putpixel(x + x2, y + l, RED);
}
else {
putpixel(x + x2, y + l, YELLOW);
}
}
}
}
}
}
}
void main()
{
int driver, mode;
driver = DETECT;
initgraph(&driver, &mode, NULL);
directvideo = 0;
//setfillstyle(SOLID_FILL,WHITE);
//bar(0,0,639,479);
//line(0, 0, 200, 200);
//setcolor(RED);
//Loadfile();
cprintf("ÎÒ");
//showpic(0, 0);
getch();
closegraph();
}