From 807706f08f4ddff2c66f4592c0db0cd261dd6227 Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Wed, 17 Jul 2019 16:03:11 -0400 Subject: image_render(): Get dimensions from text --- (limited to 'src') diff --git a/src/image.c b/src/image.c index b2cefc9..c96ffcd 100644 --- a/src/image.c +++ b/src/image.c @@ -27,6 +27,7 @@ #include #include "i18n.h" +#include "text.h" #define BIT_DEPTH 4 #define PALETTE_SIZE (1 << BIT_DEPTH) @@ -73,13 +74,16 @@ image_new(const char *file_name) } void -image_render(struct image *image) +image_render(struct image *image, struct text *text) { - size_t width = 32; - size_t height = 32; + size_t width; + size_t height; png_bytepp rows; size_t i; + width = text_get_width(text); + height = text_get_height(text); + png_set_IHDR(image->png_ptr, image->info_ptr, width, height, BIT_DEPTH, PNG_COLOR_TYPE_PALETTE, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); diff --git a/src/image.h b/src/image.h index 513280c..c9ab567 100644 --- a/src/image.h +++ b/src/image.h @@ -22,13 +22,15 @@ #ifndef IMAGE_H #define IMAGE_H +#include "text.h" + struct image; struct image * image_new(const char *file_name); void -image_render(struct image *image); +image_render(struct image *image, struct text *text); struct image * image_destroy(struct image **image); diff --git a/src/main.c b/src/main.c index cce97e9..0731f7b 100644 --- a/src/main.c +++ b/src/main.c @@ -19,15 +19,22 @@ * along with fbcon2png. If not, see . */ +#include "text.h" #include "image.h" int -main(int __attribute__((unused)) argc, char __attribute__((unused)) **argv) +main(int argc, char **argv) { + struct text *text; struct image *image; + if (argc != 2) { + return 1; + } + + text = text_new(argv[1]); image = image_new("test.png"); - image_render(image); + image_render(image, text); image_destroy(&image); return 0; -- cgit v0.9.1