118 lines
3.6 KiB
C
118 lines
3.6 KiB
C
#ifndef _CAMMY_IMAGE_H
|
|
#define _CAMMY_IMAGE_H
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <cammy/tile.h>
|
|
|
|
#define CAMMY_IMAGE_Y_COEFFICIENT_R 0.2126
|
|
#define CAMMY_IMAGE_Y_COEFFICIENT_G 0.7152
|
|
#define CAMMY_IMAGE_Y_COEFFICIENT_B 0.0722
|
|
|
|
#define CAMMY_IMAGE_CHUNK_SIZE 4096
|
|
|
|
typedef enum {
|
|
CAMMY_IMAGE_NONE,
|
|
CAMMY_IMAGE_TILE,
|
|
CAMMY_IMAGE_RGB,
|
|
CAMMY_IMAGE_RGBA
|
|
} cammy_image_format;
|
|
|
|
typedef struct _cammy_image {
|
|
cammy_image_format format;
|
|
|
|
size_t size,
|
|
width,
|
|
height;
|
|
|
|
union {
|
|
uint8_t *buf;
|
|
cammy_tile *tiles;
|
|
};
|
|
} cammy_image;
|
|
|
|
typedef struct _cammy_image_point {
|
|
size_t x, y;
|
|
} cammy_image_point;
|
|
|
|
typedef struct _cammy_image_region {
|
|
size_t x, y, width, height;
|
|
} cammy_image_region;
|
|
|
|
cammy_image *cammy_image_new(cammy_image_format format,
|
|
size_t width,
|
|
size_t height);
|
|
|
|
cammy_image *cammy_image_open_tile(const char *filename,
|
|
size_t width,
|
|
size_t height);
|
|
|
|
int cammy_image_save_tile(cammy_image *image, const char *filename);
|
|
|
|
void cammy_image_close(cammy_image *image);
|
|
|
|
void cammy_image_destroy(cammy_image *image);
|
|
|
|
int cammy_image_save(cammy_image *image, const char *filename);
|
|
|
|
void cammy_image_dither(uint8_t *dest,
|
|
uint8_t *src,
|
|
size_t width,
|
|
size_t height,
|
|
int depth,
|
|
cammy_tile_palette *palette);
|
|
|
|
void cammy_image_dither_to_tile(cammy_tile *dest,
|
|
uint8_t *src,
|
|
size_t x_dest,
|
|
size_t y_dest,
|
|
size_t x_src,
|
|
size_t y_src,
|
|
size_t width,
|
|
size_t height,
|
|
size_t dest_width,
|
|
size_t dest_height,
|
|
size_t src_width,
|
|
size_t src_height,
|
|
int depth);
|
|
|
|
void cammy_image_split_to_tiles(cammy_tile *destr,
|
|
cammy_tile *destg,
|
|
cammy_tile *destb,
|
|
uint8_t *src,
|
|
size_t width,
|
|
size_t height,
|
|
int depth);
|
|
|
|
void cammy_image_copy_from_tile(uint8_t *dest,
|
|
cammy_tile *src,
|
|
size_t width,
|
|
size_t height,
|
|
int depth,
|
|
cammy_tile_palette *palette);
|
|
|
|
void cammy_image_merge_tiles(uint8_t *dest,
|
|
cammy_tile *srcr,
|
|
cammy_tile *srcg,
|
|
cammy_tile *srcb,
|
|
size_t width,
|
|
size_t height,
|
|
int depth);
|
|
|
|
void cammy_image_copy(cammy_image *dest,
|
|
cammy_image *src,
|
|
size_t x_dest,
|
|
size_t y_dest,
|
|
size_t x_src,
|
|
size_t y_src,
|
|
size_t width,
|
|
size_t height);
|
|
|
|
int cammy_image_slice(uint8_t *buf,
|
|
size_t width,
|
|
size_t height,
|
|
size_t x_pad,
|
|
size_t y_pad,
|
|
int depth);
|
|
|
|
#endif /* _CAMMY_IMAGE_H */
|