Add color and transparency support to rgbgfx

In addition, fix various bugs.
Among them are minor memory issues and edge cases with certain inputs.

Signed-off-by: obskyr <powpowd@gmail.com>
This commit is contained in:
obskyr
2018-02-13 10:22:27 +01:00
parent 305512a2b7
commit 3075945367
6 changed files with 626 additions and 281 deletions

View File

@@ -12,14 +12,14 @@
#include <stdint.h>
#include "gfx/main.h"
void png_to_gb(const struct PNGImage png, struct GBImage *gb);
void output_file(const struct Options opts, const struct GBImage gb);
void raw_to_gb(const struct RawIndexedImage *raw_image, struct GBImage *gb);
void output_file(const struct Options *opts, const struct GBImage *gb);
int get_tile_index(uint8_t *tile, uint8_t **tiles, int num_tiles,
int tile_size);
void create_tilemap(const struct Options opts, struct GBImage *gb,
struct Tilemap *tilemap);
void output_tilemap_file(const struct Options opts,
const struct Tilemap tilemap);
void output_palette_file(const struct Options opts, const struct PNGImage png);
int tile_size);
void create_tilemap(const struct Options *opts, struct GBImage *gb,
struct Tilemap *tilemap);
void output_tilemap_file(const struct Options *opts,
const struct Tilemap *tilemap);
void output_palette_file(const struct Options *opts,
const struct RawIndexedImage *raw_image);
#endif

View File

@@ -31,6 +31,21 @@ struct Options {
char *infile;
};
struct RGBColor {
uint8_t red;
uint8_t green;
uint8_t blue;
};
struct ImageOptions {
bool horizontal;
int trim;
char *mapfile;
bool mapout;
char *palfile;
bool palout;
};
struct PNGImage {
png_struct *png;
png_info *info;
@@ -39,12 +54,14 @@ struct PNGImage {
int height;
png_byte depth;
png_byte type;
bool horizontal;
int trim;
char *mapfile;
bool mapout;
char *palfile;
bool palout;
};
struct RawIndexedImage {
uint8_t **data;
struct RGBColor *palette;
int num_colors;
int width;
int height;
};
struct GBImage {

View File

@@ -11,10 +11,11 @@
#include "gfx/main.h"
void input_png_file(const struct Options opts, struct PNGImage *img);
void get_text(struct PNGImage *png);
void set_text(const struct PNGImage *png);
void output_png_file(const struct Options opts, const struct PNGImage *png);
void free_png_data(const struct PNGImage *png);
struct RawIndexedImage *input_png_file(const struct Options *opts,
struct ImageOptions *png_options);
void output_png_file(const struct Options *opts,
const struct ImageOptions *png_options,
const struct RawIndexedImage *raw_image);
void destroy_raw_image(struct RawIndexedImage **raw_image_ptr_ptr);
#endif /* RGBDS_GFX_PNG_H */