From c68a2bcaa9fd16b9eaf4f4d124e3948faecf137e Mon Sep 17 00:00:00 2001 From: kub Date: Thu, 9 Jan 2025 23:57:17 +0100 Subject: [PATCH] add pitched writepng function --- readpng.c | 7 ++++++- readpng.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/readpng.c b/readpng.c index 5f36d6a..500e81c 100644 --- a/readpng.c +++ b/readpng.c @@ -234,7 +234,7 @@ done: return ret; } -int writepng(const char *fname, unsigned short *src, int w, int h) +int writepngpp(const char *fname, unsigned short *src, int w, int h, int pitch) { png_structp png_ptr = NULL; png_infop info_ptr = NULL; @@ -262,6 +262,7 @@ int writepng(const char *fname, unsigned short *src, int w, int h) dst[1] = PXGETG(*src); dst[2] = PXGETB(*src); } + src += pitch-w; } /* initialize stuff */ @@ -307,3 +308,7 @@ end1: return ret; } +int writepng(const char *fname, unsigned short *src, int w, int h) +{ + return writepngpp(fname, src, w, h, w); +} diff --git a/readpng.h b/readpng.h index c3d58a7..93846b5 100644 --- a/readpng.h +++ b/readpng.h @@ -16,6 +16,7 @@ extern "C" { #endif int readpng(void *dest, const char *fname, readpng_what what, int w, int h); +int writepngpp(const char *fname, unsigned short *src, int w, int h, int pitch); int writepng(const char *fname, unsigned short *src, int w, int h); #ifdef __cplusplus -- 2.39.5