-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimage.c
More file actions
43 lines (31 loc) · 747 Bytes
/
image.c
File metadata and controls
43 lines (31 loc) · 747 Bytes
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
#include"image.h"
FILE * initFile( const char * filename, int w, int h )
{
FILE *f = fopen(filename, "w");
fputc( 0, f );
fputc( 0, f );
fputc( 2, f );
fputc( 0, f ); fputc( 0, f );
fputc( 0, f ); fputc( 0, f );
fputc( 0, f );
fputc( 0, f ); fputc( 0, f );
fputc( 0, f ); fputc( 0, f );
fputc( (w & 0x00FF), f );
fputc( (w & 0xFF00) / 256, f );
fputc( (h & 0x00FF), f );
fputc( (h & 0xFF00) / 256, f );
fputc(24, f);
fputc(0, f);
return f;
}
void savePixelValue( FILE *f, char r, char g, char b )
{
if( !f ) return;
fputc( b, f); // Blue Value
fputc( g, f); // Green Value
fputc( r, f); // Red Value
}
void closeFile(FILE *file)
{
fclose(file);
}