fixed png bytebuffer: needed to memset png struct to zeros
This commit is contained in:
BIN
build/__pycache__/amsbuildlib4.cpython-311.pyc
Normal file
BIN
build/__pycache__/amsbuildlib4.cpython-311.pyc
Normal file
Binary file not shown.
@ -19,7 +19,7 @@ cc = "gcc" #compiler
|
|||||||
# -fvisibility=hidden -- stripping symbols to avoid namespace pollution doesn't seem to work on Linux
|
# -fvisibility=hidden -- stripping symbols to avoid namespace pollution doesn't seem to work on Linux
|
||||||
cflags = "-fPIC -O3 -DEXPORT_AMSCIMGLIB4"
|
cflags = "-fPIC -O3 -DEXPORT_AMSCIMGLIB4"
|
||||||
libraries = "-l{} -ljpeg -lpng -lz -lm".format(libname)
|
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)
|
linkerflags = "-shared -Wl,-rpath=. -Wl,--out-implib={}/lib{}.a".format(builddir,libname)
|
||||||
srcexts = [".c",".cpp"]
|
srcexts = [".c",".cpp"]
|
||||||
binsrc = ["main.c","main.cpp"] #ignore these files when compiling the static library
|
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.
@ -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);
|
AMSCIMGLIB4_API void amscimglib4_writeimage_jpeg(const char *fname, amscimglib4_image *img, int quality);
|
||||||
|
|
||||||
//Read and write PNG files from memory buffers
|
//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
|
//returns length required for a bytebuffer to store img as a png
|
||||||
AMSCIMGLIB4_API long amscimglib4_pngbytebufferlen(amscimglib4_image *img);
|
AMSCIMGLIB4_API long amscimglib4_pngbytebufferlen(amscimglib4_image *img);
|
||||||
|
@ -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)
|
//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 ret = amscimglib4_success;
|
||||||
int res;
|
int res;
|
||||||
@ -227,6 +227,7 @@ AMSCIMGLIB4_API long amscimglib4_pngbytebufferlen(amscimglib4_image *img)
|
|||||||
|
|
||||||
png_image pngimage;
|
png_image pngimage;
|
||||||
|
|
||||||
|
memset(&pngimage,0,sizeof(pngimage)); //fills memory with zeros
|
||||||
pngimage.version = PNG_IMAGE_VERSION;
|
pngimage.version = PNG_IMAGE_VERSION;
|
||||||
pngimage.format = PNG_FORMAT_RGBA;
|
pngimage.format = PNG_FORMAT_RGBA;
|
||||||
pngimage.width = img->sizex;
|
pngimage.width = img->sizex;
|
||||||
@ -260,6 +261,7 @@ AMSCIMGLIB4_API int amscimglib4_pngbytebuffer_from_img(amscimglib4_image *img, u
|
|||||||
png_image pngimage;
|
png_image pngimage;
|
||||||
png_alloc_size_t bufflen2 = bufflen;
|
png_alloc_size_t bufflen2 = bufflen;
|
||||||
|
|
||||||
|
memset(&pngimage,0,sizeof(pngimage)); //fills memory with zeros
|
||||||
pngimage.version = PNG_IMAGE_VERSION;
|
pngimage.version = PNG_IMAGE_VERSION;
|
||||||
pngimage.format = PNG_FORMAT_RGBA;
|
pngimage.format = PNG_FORMAT_RGBA;
|
||||||
pngimage.width = img->sizex;
|
pngimage.width = img->sizex;
|
||||||
|
Reference in New Issue
Block a user