d5aaccf1b92d5fa3dddf0e5ac7fadacfd9dbc295
[gbajam21] / tools / pngdump / image.h
1 #ifndef IMAGE_H_
2 #define IMAGE_H_
3
4 struct cmapent {
5         unsigned char r, g, b;
6 };
7
8 struct image {
9         int width, height;
10         int bpp;
11         int nchan;
12         int scansz;     /* scanline size in bytes */
13         int pitch;      /* bytes from one scanline to the next */
14         int cmap_ncolors;
15         struct cmapent cmap[256];
16         unsigned char *pixels;
17 };
18
19 int alloc_image(struct image *img, int x, int y, int bpp);
20 int load_image(struct image *img, const char *fname);
21 int save_image(struct image *img, const char *fname);
22
23 int cmp_image(struct image *a, struct image *b);
24
25 void blit(struct image *src, int sx, int sy, int w, int h, struct image *dst, int dx, int dy);
26 void overlay_key(struct image *src, unsigned int key, struct image *dst);
27
28 unsigned int get_pixel(struct image *img, int x, int y);
29 unsigned int get_pixel_rgb(struct image *img, int x, int y, unsigned int *rgb);
30 void put_pixel(struct image *img, int x, int y, unsigned int pix);
31
32 void quantize_image(struct image *img, int maxcol);
33 int gen_shade_lut(struct image *img, int levels, int maxcol, struct cmapent *shade_cmap,
34                 int *shade_lut);
35
36 #endif  /* IMAGE_H_ */