From: Daniel Maslowski <i...@orangecms.org>

Signed-off-by: Daniel Maslowski <i...@orangecms.org>
---
 src/lodepng.c | 30 ++++++++++++++++++++++++++++++
 src/lodepng.h | 13 ++++++++-----
 2 files changed, 38 insertions(+), 5 deletions(-)

diff --git a/src/lodepng.c b/src/lodepng.c
index 490fc8e..8d416c7 100644
--- a/src/lodepng.c
+++ b/src/lodepng.c
@@ -81,6 +81,36 @@ static void lodepng_free(void* ptr) {
   free(ptr);
 }
 
+// from bmp.c, adjustments
+static void raw_data_format_adjust_32bpp(u8 *src, u8 *dest, int width,
+                                        int height, int bytes_per_line_dest)
+{
+    int bytes_per_line_src = 4 * width;
+    int i, j;
+    for (i = 0 ; i < height ; i++) {
+
+        for (j = 0 ; j < width ; j++) {
+              dest[i * bytes_per_line_dest + j*4+0] = src[i * 
bytes_per_line_src + j*4+2];
+              dest[i * bytes_per_line_dest + j*4+1] = src[i * 
bytes_per_line_src + j*4+1];
+              dest[i * bytes_per_line_dest + j*4+2] = src[i * 
bytes_per_line_src + j*4+0];
+              dest[i * bytes_per_line_dest + j*4+3] = src[i * 
bytes_per_line_src + j*4+3];
+        }
+    }
+}
+
+int png_show(unsigned char *png, unsigned char *pic,
+             int width, int height, int depth,
+            int bytes_per_line_dest)
+{
+    /* now only support 32bpp */
+    if (depth == 32) {
+        raw_data_format_adjust_32bpp(png, pic, width, height,
+                                        bytes_per_line_dest);
+        return 0;
+    }
+    return 1;
+}
+
 /* ////////////////////////////////////////////////////////////////////////// 
*/
 /* ////////////////////////////////////////////////////////////////////////// 
*/
 /* // Tools for C, and common code for PNG and Zlib.                       // 
*/
diff --git a/src/lodepng.h b/src/lodepng.h
index 8c157b8..632bd86 100644
--- a/src/lodepng.h
+++ b/src/lodepng.h
@@ -112,18 +112,21 @@ colortype: the desired color type for the raw output 
image. See explanation on P
 bitdepth: the desired bit depth for the raw output image. See explanation on 
PNG color types.
 Return value: LodePNG error code (0 means no error).
 */
-unsigned lodepng_decode_memory(unsigned char** out, unsigned* w, unsigned* h,
+unsigned lodepng_decode_memory(unsigned char** out, int* w, int* h,
                                const unsigned char* in, size_t insize,
                                LodePNGColorType colortype, unsigned bitdepth);
 
 /*Same as lodepng_decode_memory, but always decodes to 32-bit RGBA raw image*/
-unsigned lodepng_decode32(unsigned char** out, unsigned* w, unsigned* h,
+unsigned lodepng_decode32(unsigned char** out, int* w, int* h,
                           const unsigned char* in, size_t insize);
 
 /*Same as lodepng_decode_memory, but always decodes to 24-bit RGB raw image*/
-unsigned lodepng_decode24(unsigned char** out, unsigned* w, unsigned* h,
+unsigned lodepng_decode24(unsigned char** out, int* w, int* h,
                           const unsigned char* in, size_t insize);
 
+int png_show(unsigned char *png, unsigned char *pic,
+             int width, int height, int depth,
+            int bytes_per_line_dest);
 #ifdef LODEPNG_COMPILE_DISK
 /*
 Load PNG from disk, from file with given name.
@@ -746,7 +749,7 @@ void lodepng_state_copy(LodePNGState* dest, const 
LodePNGState* source);
 Same as lodepng_decode_memory, but uses a LodePNGState to allow custom 
settings and
 getting much more information about the PNG image and color mode.
 */
-unsigned lodepng_decode(unsigned char** out, unsigned* w, unsigned* h,
+unsigned lodepng_decode(unsigned char** out, int* w, int* h,
                         LodePNGState* state,
                         const unsigned char* in, size_t insize);
 
@@ -755,7 +758,7 @@ Read the PNG header, but not the actual data. This returns 
only the information
 that is in the IHDR chunk of the PNG, such as width, height and color type. The
 information is placed in the info_png field of the LodePNGState.
 */
-unsigned lodepng_inspect(unsigned* w, unsigned* h,
+unsigned lodepng_inspect(int* w, int* h,
                          LodePNGState* state,
                          const unsigned char* in, size_t insize);
 #endif /*LODEPNG_COMPILE_DECODER*/
-- 
2.23.0
_______________________________________________
SeaBIOS mailing list -- seabios@seabios.org
To unsubscribe send an email to seabios-le...@seabios.org

Reply via email to