implemented image exporting

This commit is contained in:
antifallobst 2023-03-21 13:28:01 +01:00
parent 07bd5be830
commit e14a3f0669
1 changed files with 10 additions and 1 deletions

View File

@ -192,13 +192,22 @@ void image_export(image_T* image, const char* filename) {
printf("exporting image to '%s'\n", filename); printf("exporting image to '%s'\n", filename);
struct img_pixmap img; struct img_pixmap img;
img_init(&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[]) { int main(int argc, char* argv[]) {
printf("Line Cutter - Juniorcamp Informatik\n"); 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"); gfx_open(800, 600, "Juniorcamp Informatik - Line Cutter");
image_dump(image); image_dump(image);