From e14a3f06693576291b7db5057889f52929c1adcd Mon Sep 17 00:00:00 2001 From: antifallobst Date: Tue, 21 Mar 2023 13:28:01 +0100 Subject: [PATCH] implemented image exporting --- src/main.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index 13b597a..c4cff7c 100644 --- a/src/main.c +++ b/src/main.c @@ -192,13 +192,22 @@ void image_export(image_T* image, const char* filename) { printf("exporting image to '%s'\n", filename); struct img_pixmap img; img_init(&img); + img_set_pixels(&img, image->new_width, image->new_height, IMG_FMT_RGBA32, NULL); + + uint32_t* out_buffer = (uint32_t*)img.pixels; + + for (int y = 0; y < image->new_height; y++) { + memcpy(&out_buffer[y * image->new_width], &image->buffer[y * image->width], image->new_width * sizeof(uint32_t)); + } + + img_save(&img, filename); } int main(int argc, char* argv[]) { printf("Line Cutter - Juniorcamp Informatik\n"); - image_T* image = image_load("../bench.png", "../bench_mask.png"); + image_T* image = image_load("../images/paris.png", "../images/paris_mask.png"); gfx_open(800, 600, "Juniorcamp Informatik - Line Cutter"); image_dump(image);