-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpgmread.h
More file actions
36 lines (30 loc) · 1.12 KB
/
Copy pathpgmread.h
File metadata and controls
36 lines (30 loc) · 1.12 KB
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
// code from: https://www.uio.no/studier/emner/matnat/ifi/IN2140/v19/undervisningsmaterial/homeexamv2.tar.gz
#ifndef PGM_READ_H
#define PGM_READ_H
struct Image
{
int width;
int height;
unsigned char* data;
};
/* Image_create takes a buffer that contains all the bytes from a PGM
* image of type P2. It creates a struct Image and fills in the width
* and height information as well as the data. The buffer remains
' unchanged.
*/
struct Image* Image_create( char* buffer );
/* Image_alloc is used by Image_create to allocate the memory for
* a struct Image and the image data contains in it.
*/
struct Image* Image_alloc( int w, int h );
/* Image_free releases the memory of a struct Image and the data
* that contains the image pixels.
*/
void Image_free( struct Image* img );
/* Image_compare takes to struct Image pointers and compares them.
* It returns 0 if the images are different, and 1 if they are identical.
* It prints a warning before returning 0 if they have different width
* or height, or if of the pointers is NULL.
*/
int Image_compare( struct Image* img1, struct Image* img2 );
#endif /* PGM_READ_H */