implemented image exporting
This commit is contained in:
parent
07bd5be830
commit
e14a3f0669
11
src/main.c
11
src/main.c
|
@ -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);
|
||||||
|
|
Loading…
Reference in New Issue