-
Notifications
You must be signed in to change notification settings - Fork 0
/
Image.h
53 lines (38 loc) · 1.85 KB
/
Image.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
/* Image.h: header file for basic image manipulations */
/* Do not modify it */
#ifndef IMAGE_H
#define IMAGE_H
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
typedef struct {
unsigned int W; /* image width */
unsigned int H; /* image height */
unsigned char *R; /* pointer to the memory storing all the R intensity values */
unsigned char *G; /* pointer to the memory storing all the G intensity values */
unsigned char *B; /* pointer to the memory storing all the B intensity values */
} IMAGE;
/* Get the R intensity of pixel (x, y) in image */
unsigned char GetPixelR(const IMAGE *image, unsigned int x, unsigned int y);
/* Get the G intensity of pixel (x, y) in image */
unsigned char GetPixelG(const IMAGE *image, unsigned int x, unsigned int y);
/* Get the B intensity of pixel (x, y) in image */
unsigned char GetPixelB(const IMAGE *image, unsigned int x, unsigned int y);
/* Set the R intensity of pixel (x, y) in image to r */
void SetPixelR(IMAGE *image, unsigned int x, unsigned int y, unsigned char r);
/* Set the G intensity of pixel (x, y) in image to g */
void SetPixelG(IMAGE *image, unsigned int x, unsigned int y, unsigned char g);
/* Set the B intensity of pixel (x, y) in image to b */
void SetPixelB(IMAGE *image, unsigned int x, unsigned int y, unsigned char b);
/* Allocate dynamic memory for the image structure and its R/G/B values */
/* Return the pointer to the image, or NULL in case of error */
IMAGE *CreateImage(unsigned int Width, unsigned int Height);
/* Free the memory for the R/G/B values and IMAGE structure */
void DeleteImage(IMAGE *image);
/* Return the image's width in pixels */
unsigned int ImageWidth(const IMAGE *image);
/* Return the image's height in pixels */
unsigned int ImageHeight(const IMAGE *image);
IMAGE *CopyImage(IMAGE *image, IMAGE *tempImage);
int CheckBounds(int value);
#endif