-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimage.h
30 lines (27 loc) · 826 Bytes
/
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
#ifndef IMAGE_H
#define IMAGE_H
#include <stdio.h>
#include <stdlib.h>
typedef struct Pixel {
unsigned char r;
unsigned char g;
unsigned char b;
} Pixel;
typedef struct Image {
Pixel *pixels;
size_t width;
size_t height;
} Image;
void set_random_pixel(Pixel *pixel);
void print_pixel(const Pixel *pixel);
void write_pixel(FILE *file, const Pixel *pixel);
Pixel *pixel_at(const Image *image, size_t x, size_t y);
void set_random_row(Pixel *row, size_t width);
void print_image(const Image *image);
void write_image_P3(FILE *file, const Image *image);
void write_image_P6(FILE *file, const Image *image);
void set_random_image(Image *image);
Image *malloc_image(size_t width, size_t height);
Image *malloc_random_image(size_t width, size_t height);
void free_image(Image *image);
#endif /* IMAGE_H */