summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPatrick McDermott <patrick.mcdermott@libiquity.com>2019-07-17 16:03:11 (EDT)
committer Patrick McDermott <patrick.mcdermott@libiquity.com>2019-07-17 16:03:11 (EDT)
commit807706f08f4ddff2c66f4592c0db0cd261dd6227 (patch)
tree35672cc23c8daa9a9eb82ec7d855199ec78e1934 /src
parente6cba83cb3c92d623030fbe9e2ff058c84700b7c (diff)
image_render(): Get dimensions from text
Diffstat (limited to 'src')
-rw-r--r--src/image.c10
-rw-r--r--src/image.h4
-rw-r--r--src/main.c11
3 files changed, 19 insertions, 6 deletions
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 <png.h>
#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 <http://www.gnu.org/licenses/>.
*/
+#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;