Added screenshot feature (F2 key)

This commit is contained in:
MihailRis
2023-11-13 15:01:41 +03:00
parent d42d2dc294
commit 3723cf491f
9 changed files with 113 additions and 11 deletions
+5 -7
View File
@@ -201,12 +201,12 @@ int _png_write(const char* filename, uint width, uint height, const ubyte* data,
spng_set_ihdr(ctx, &ihdr);
fmt = SPNG_FMT_PNG;
ret = spng_encode_image(ctx, data, width * height , fmt, SPNG_ENCODE_FINALIZE);
ret = spng_encode_image(ctx, data, (size_t)width * (size_t)height * pixsize , fmt, SPNG_ENCODE_FINALIZE);
if (ret) {
printf("spng_encode_image() error: %s\n", spng_strerror(ret));
goto encode_error;
fflush(stdout);
spng_ctx_free(ctx);
return ret;
}
size_t png_size;
@@ -218,9 +218,7 @@ int _png_write(const char* filename, uint width, uint height, const ubyte* data,
else {
files::write_bytes(filename, (const char*)png_buf, png_size);
}
free(png_buf);
encode_error:
fflush(stdout);
spng_ctx_free(ctx);
return ret;
}