include stdio include bmp bool FileExists const char f_name FILE p_fil

 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
#include <stdio.h>
#include "bmp.h"
bool FileExists(const char *f_name) {
FILE *p_file = fopen(f_name, "rt");
if(!p_file)
return false;
fclose(p_file);
return true;
}
int main(int, char **) {
char szBmpName[256];
printf("Enter bitmap name: ");
scanf("%s", szBmpName);
if(!FileExists(szBmpName))
return -1;
bitmap bmp;
bmp.Load(szBmpName);
int w = bmp.GetWidth(),
h = bmp.GetHeight();
pixel p;
p = bmp.GetPixel(0, 0);
p = bmp.GetPixel(0, 1);
p = bmp.GetPixel(1, 0);
p = bmp.GetPixel(1, 1);
p = pixel();
bmp.SetPixel(1, 1, p);
bmp.SaveAs("ccc.bmp");
return 0;
}