fixed png bytebuffer: needed to memset png struct to zeros

This commit is contained in:
2025-10-04 00:47:49 -04:00
parent f442ae2067
commit 2d992360e4
17 changed files with 5 additions and 3 deletions
Binary file not shown.
+1 -1
View File
@@ -19,7 +19,7 @@ cc = "gcc" #compiler
# -fvisibility=hidden -- stripping symbols to avoid namespace pollution doesn't seem to work on Linux
cflags = "-fPIC -O3 -DEXPORT_AMSCIMGLIB4"
libraries = "-l{} -ljpeg -lpng -lz -lm".format(libname)
libdirs = "-L{} -L{}/lib -L{}/lib".format(builddir,commondir,depdir)
libdirs = "-L{} -L{}/lib -L{}/lib".format(builddir,depdir,commondir)
linkerflags = "-shared -Wl,-rpath=. -Wl,--out-implib={}/lib{}.a".format(builddir,libname)
srcexts = [".c",".cpp"]
binsrc = ["main.c","main.cpp"] #ignore these files when compiling the static library
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+1 -1
View File
@@ -119,7 +119,7 @@ AMSCIMGLIB4_API void amscimglib4_readimage_jpeg(const char *fname, amscimglib4_i
AMSCIMGLIB4_API void amscimglib4_writeimage_jpeg(const char *fname, amscimglib4_image *img, int quality);
//Read and write PNG files from memory buffers
AMSCIMGLIB4_API int amscimglib4_pngbytebuffer_to_img(amscimglib4_image *img, unsigned char *bytebuffer, long nbytes);
AMSCIMGLIB4_API int amscimglib4_pngbytebuffer_to_img(amscimglib4_image *img, const unsigned char *bytebuffer, long nbytes);
//returns length required for a bytebuffer to store img as a png
AMSCIMGLIB4_API long amscimglib4_pngbytebufferlen(amscimglib4_image *img);
+3 -1
View File
@@ -147,7 +147,7 @@ AMSCIMGLIB4_API void amscimglib4_writeimage_png(const char *fname, amscimglib4_i
//Reads and writes png data to and from a bytebuffer in memory (for compression)
AMSCIMGLIB4_API int amscimglib4_pngbytebuffer_to_img(amscimglib4_image *img, unsigned char *bytebuffer, long nbytes)
AMSCIMGLIB4_API int amscimglib4_pngbytebuffer_to_img(amscimglib4_image *img, const unsigned char *bytebuffer, long nbytes)
{
int ret = amscimglib4_success;
int res;
@@ -227,6 +227,7 @@ AMSCIMGLIB4_API long amscimglib4_pngbytebufferlen(amscimglib4_image *img)
png_image pngimage;
memset(&pngimage,0,sizeof(pngimage)); //fills memory with zeros
pngimage.version = PNG_IMAGE_VERSION;
pngimage.format = PNG_FORMAT_RGBA;
pngimage.width = img->sizex;
@@ -260,6 +261,7 @@ AMSCIMGLIB4_API int amscimglib4_pngbytebuffer_from_img(amscimglib4_image *img, u
png_image pngimage;
png_alloc_size_t bufflen2 = bufflen;
memset(&pngimage,0,sizeof(pngimage)); //fills memory with zeros
pngimage.version = PNG_IMAGE_VERSION;
pngimage.format = PNG_FORMAT_RGBA;
pngimage.width = img->sizex;