-
Notifications
You must be signed in to change notification settings - Fork 0
/
ppmImageLib.h
99 lines (68 loc) · 1.63 KB
/
ppmImageLib.h
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
#ifndef PPMIMAGELIB_H
#define PPMIMAGELIB_H
/*****************************************
* Color part
****************************************/
typedef struct Color
{
unsigned char r;
unsigned char g;
unsigned char b;
} Color;
/*
* Usage:
* Color * red = CreateColor(255, 0, 0);
*/
Color * CreateColor(unsigned char red, unsigned char green, unsigned char blue);
/*
* Return 1 if equal colors, and 0 if not
*/
int ColorCompare(Color * c1, Color * c2);
void DeleteColor(Color * color);
/*****************************************
* ppmImage part
****************************************/
typedef struct ppmImg
{
Color * img;
Color **imgPtr;
int width;
int height;
int maxVal;
char * format;
} ppmImg;
/*
* Usage:
* ppmImg * img1 = CreateImg(4, 4, 255);
*/
ppmImg * CreateImg(int width, int height, int maxVal);
/*
* Return integer as index made from 2D array
*/
int arr2D(ppmImg * img, int x, int y);
void SetPixelColor(ppmImg * img, int x, int y, Color * color);
void SetBackgroundColor(ppmImg * img, Color * color);
/*
* Usage:
* FlipImageVertically(img);
*/
void FlipImageVertically(ppmImg * img);
/*
* Usage:
* Color * c1 = GetPixelColor(img, x, y);
*/
Color * GetPixelColor(ppmImg * img, int x , int y);
void WriteImgToFile(ppmImg * img, char * fileName);
/*
* For "P3" format
* Generates human-readable image
*/
void WriteImgToFileASCII(ppmImg * img, char * fileName);
/*
* For "P6" format
* Generates PC-readable image
*/
void WriteImgToFileBinary(ppmImg * img, char * fileName);
//int ReadImgFromFile(ppmImg * img, char * fileName);
void DeleteImg(ppmImg * img);
#endif /* PPMIMAGELIB_H */