From ac148296c2b39816122924dda32afec4ed08735d Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Wed, 17 Jul 2019 18:03:01 -0400 Subject: src/image.c: Move macros to src/image.h --- (limited to 'src') diff --git a/src/image.c b/src/image.c index 45c3352..04dca72 100644 --- a/src/image.c +++ b/src/image.c @@ -30,10 +30,6 @@ #include "i18n.h" #include "text.h" -#define BIT_DEPTH 8 -#define CHANNELS 3 -#define PIXEL_SIZE ((BIT_DEPTH + 7) / 8) * CHANNELS - struct image { png_structp png_ptr; png_infop info_ptr; @@ -84,12 +80,12 @@ image_render(struct image *image, struct text *text, struct font *font) height = text_get_height(text) * font_get_height(font); png_set_IHDR(image->png_ptr, image->info_ptr, width, height, - BIT_DEPTH, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, + IMAGE_BIT_DEPTH, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); rows = png_malloc(image->png_ptr, height * sizeof(*rows)); for (i = 0; i < height; ++i) { - rows[i] = png_malloc(image->png_ptr, width * PIXEL_SIZE); + rows[i] = png_malloc(image->png_ptr, width * IMAGE_PIXEL_SIZE); } png_set_rows(image->png_ptr, image->info_ptr, rows); diff --git a/src/image.h b/src/image.h index 361296e..1177cd0 100644 --- a/src/image.h +++ b/src/image.h @@ -26,6 +26,10 @@ #include "font.h" +#define IMAGE_BIT_DEPTH 8 +#define IMAGE_CHANNELS 3 +#define IMAGE_PIXEL_SIZE ((IMAGE_BIT_DEPTH + 7) / 8) * IMAGE_CHANNELS + struct image; struct image * -- cgit v0.9.1