Bläddra i källkod

Updated to stb image 2.30. Resolves #34.

Brucey 11 månader sedan
förälder
incheckning
7572eee874
5 ändrade filer med 321 tillägg och 123 borttagningar
  1. 1 1
      stb.mod/common.bmx
  2. 17 3
      stb.mod/glue.c
  3. 9 3
      stb.mod/stb.bmx
  4. 8 5
      stb.mod/stb/stb_image.h
  5. 286 111
      stb.mod/stb/stb_image_resize2.h

+ 1 - 1
stb.mod/common.bmx

@@ -1,4 +1,4 @@
-' Copyright (c) 2022-2023 Bruce A Henderson
+' Copyright (c) 2022-2024 Bruce A Henderson
 ' 
 ' 
 ' This software is provided 'as-is', without any express or implied
 ' This software is provided 'as-is', without any express or implied
 ' warranty. In no event will the authors be held liable for any damages
 ' warranty. In no event will the authors be held liable for any damages

+ 17 - 3
stb.mod/glue.c

@@ -1,5 +1,5 @@
 /*
 /*
-  Copyright (c) 2022-2023 Bruce A Henderson
+  Copyright (c) 2022-2024 Bruce A Henderson
   
   
   This software is provided 'as-is', without any express or implied
   This software is provided 'as-is', without any express or implied
   warranty. In no event will the authors be held liable for any damages
   warranty. In no event will the authors be held liable for any damages
@@ -33,6 +33,8 @@ extern int image_stb_TStbioCallbacks__Read(BBObject * cb, char * data,int size);
 extern void image_stb_TStbioCallbacks__Skip(BBObject * cb, int n);
 extern void image_stb_TStbioCallbacks__Skip(BBObject * cb, int n);
 extern int image_stb_TStbioCallbacks__Eof(BBObject * cb);
 extern int image_stb_TStbioCallbacks__Eof(BBObject * cb);
 
 
+stbi_uc *bmx_stbi_load_gif_from_callbacks(stbi_io_callbacks const *clbk, void *user, int **delays, int *x, int *y, int *z, int *comp, int req_comp);
+
 stbi_uc * bmx_stbi_load_image(BBObject * cb, int * width, int * height, int * channels) {
 stbi_uc * bmx_stbi_load_image(BBObject * cb, int * width, int * height, int * channels) {
 
 
 	stbi_io_callbacks callbacks;
 	stbi_io_callbacks callbacks;
@@ -50,9 +52,21 @@ stbi_uc * bmx_stbi_load_gif(BBObject * cb, int **delays, int *x, int *y, int *z,
 	callbacks.skip = image_stb_TStbioCallbacks__Skip;
 	callbacks.skip = image_stb_TStbioCallbacks__Skip;
 	callbacks.eof = image_stb_TStbioCallbacks__Eof;
 	callbacks.eof = image_stb_TStbioCallbacks__Eof;
 
 
-	return stbi_load_gif_from_callbacks(&callbacks, cb, delays, x, y, z, comp, req_comp);
+	return bmx_stbi_load_gif_from_callbacks(&callbacks, cb, delays, x, y, z, comp, req_comp);
 }
 }
 
 
 void bmx_stbi_free_delays(int ** delays) {
 void bmx_stbi_free_delays(int ** delays) {
    if (delays && *delays) STBI_FREE(*delays);
    if (delays && *delays) STBI_FREE(*delays);
-}
+}
+
+stbi_uc * bmx_stbi_load_gif_from_callbacks(stbi_io_callbacks const *clbk, void *user, int **delays, int *x, int *y, int *z, int *comp, int req_comp)
+{
+   unsigned char *result;
+   stbi__context s;
+   stbi__start_callbacks(&s, (stbi_io_callbacks *) clbk, user);
+   result = (unsigned char*) stbi__load_gif_main(&s, delays, x, y, z, comp, req_comp);
+   if (stbi__vertically_flip_on_load) {
+      stbi__vertical_flip_slices( result, *x, *y, *z, *comp );
+   }
+   return result;
+}

+ 9 - 3
stb.mod/stb.bmx

@@ -1,4 +1,4 @@
-' Copyright (c) 2022-2023 Bruce A Henderson
+' Copyright (c) 2022-2024 Bruce A Henderson
 ' 
 ' 
 ' This software is provided 'as-is', without any express or implied
 ' This software is provided 'as-is', without any express or implied
 ' warranty. In no event will the authors be held liable for any damages
 ' warranty. In no event will the authors be held liable for any damages
@@ -20,12 +20,16 @@ SuperStrict
 
 
 Module Image.STB
 Module Image.STB
 
 
-ModuleInfo "Version: 1.05"
+ModuleInfo "Version: 1.06"
 ModuleInfo "Author: Sean Barrett and contributers (see stb_image.h)"
 ModuleInfo "Author: Sean Barrett and contributers (see stb_image.h)"
 ModuleInfo "License: ZLib/PNG License"
 ModuleInfo "License: ZLib/PNG License"
 ModuleInfo "Credit: Adapted for BlitzMax by Bruce A Henderson"
 ModuleInfo "Credit: Adapted for BlitzMax by Bruce A Henderson"
 
 
-ModuleInfo "History: 1.04"
+ModuleInfo "History: 1.06"
+ModuleInfo "History: Update to stb_image 2.30"
+ModuleInfo "History: Update to stb_image_resize2 2.10"
+ModuleInfo "History: Fixed gif build."
+ModuleInfo "History: 1.05"
 ModuleInfo "History: Update to stb_image 2.29"
 ModuleInfo "History: Update to stb_image 2.29"
 ModuleInfo "History: 1.04"
 ModuleInfo "History: 1.04"
 ModuleInfo "History: Update to stb_image 2.28"
 ModuleInfo "History: Update to stb_image 2.28"
@@ -42,6 +46,8 @@ Import BRL.Pixmap
 
 
 Import "common.bmx"
 Import "common.bmx"
 
 
+' Notes
+' stbi__compute_y_16() and stbi__convert_format16() need aditional  "&& defined(STBI_NO_PNM)"
 
 
 Private
 Private
 
 

+ 8 - 5
stb.mod/stb/stb_image.h

@@ -1,4 +1,4 @@
-/* stb_image - v2.29 - public domain image loader - http://nothings.org/stb
+/* stb_image - v2.30 - public domain image loader - http://nothings.org/stb
                                   no warranty implied; use at your own risk
                                   no warranty implied; use at your own risk
 
 
    Do this:
    Do this:
@@ -48,6 +48,7 @@ LICENSE
 
 
 RECENT REVISION HISTORY:
 RECENT REVISION HISTORY:
 
 
+      2.30  (2024-05-31) avoid erroneous gcc warning
       2.29  (2023-05-xx) optimizations
       2.29  (2023-05-xx) optimizations
       2.28  (2023-01-29) many error fixes, security errors, just tons of stuff
       2.28  (2023-01-29) many error fixes, security errors, just tons of stuff
       2.27  (2021-07-11) document stbi_info better, 16-bit PNM support, bug fixes
       2.27  (2021-07-11) document stbi_info better, 16-bit PNM support, bug fixes
@@ -1796,7 +1797,7 @@ static unsigned char *stbi__convert_format(unsigned char *data, int img_n, int r
 }
 }
 #endif
 #endif
 
 
-#if defined(STBI_NO_PNG) && defined(STBI_NO_PSD)
+#if defined(STBI_NO_PNG) && defined(STBI_NO_PSD) && defined(STBI_NO_PNM)
 // nothing
 // nothing
 #else
 #else
 static stbi__uint16 stbi__compute_y_16(int r, int g, int b)
 static stbi__uint16 stbi__compute_y_16(int r, int g, int b)
@@ -1805,7 +1806,7 @@ static stbi__uint16 stbi__compute_y_16(int r, int g, int b)
 }
 }
 #endif
 #endif
 
 
-#if defined(STBI_NO_PNG) && defined(STBI_NO_PSD)
+#if defined(STBI_NO_PNG) && defined(STBI_NO_PSD) && defined(STBI_NO_PNM)
 // nothing
 // nothing
 #else
 #else
 static stbi__uint16 *stbi__convert_format16(stbi__uint16 *data, int img_n, int req_comp, unsigned int x, unsigned int y)
 static stbi__uint16 *stbi__convert_format16(stbi__uint16 *data, int img_n, int req_comp, unsigned int x, unsigned int y)
@@ -5159,9 +5160,11 @@ static int stbi__parse_png_file(stbi__png *z, int scan, int req_comp)
                // non-paletted with tRNS = constant alpha. if header-scanning, we can stop now.
                // non-paletted with tRNS = constant alpha. if header-scanning, we can stop now.
                if (scan == STBI__SCAN_header) { ++s->img_n; return 1; }
                if (scan == STBI__SCAN_header) { ++s->img_n; return 1; }
                if (z->depth == 16) {
                if (z->depth == 16) {
-                  for (k = 0; k < s->img_n; ++k) tc16[k] = (stbi__uint16)stbi__get16be(s); // copy the values as-is
+                  for (k = 0; k < s->img_n && k < 3; ++k) // extra loop test to suppress false GCC warning
+                     tc16[k] = (stbi__uint16)stbi__get16be(s); // copy the values as-is
                } else {
                } else {
-                  for (k = 0; k < s->img_n; ++k) tc[k] = (stbi_uc)(stbi__get16be(s) & 255) * stbi__depth_scale_table[z->depth]; // non 8-bit images will be larger
+                  for (k = 0; k < s->img_n && k < 3; ++k)
+                     tc[k] = (stbi_uc)(stbi__get16be(s) & 255) * stbi__depth_scale_table[z->depth]; // non 8-bit images will be larger
                }
                }
             }
             }
             break;
             break;

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 286 - 111
stb.mod/stb/stb_image_resize2.h


Vissa filer visades inte eftersom för många filer har ändrats