Browse Source

qoi: Added support for image of channels 3 (#4384)

R-YaTian 11 months ago
parent
commit
8d267aaf23
1 changed files with 2 additions and 2 deletions
  1. 2 2
      src/rtextures.c

+ 2 - 2
src/rtextures.c

@@ -506,10 +506,10 @@ Image LoadImageFromMemory(const char *fileType, const unsigned char *fileData, i
         if (fileData != NULL)
         if (fileData != NULL)
         {
         {
             qoi_desc desc = { 0 };
             qoi_desc desc = { 0 };
-            image.data = qoi_decode(fileData, dataSize, &desc, 4);
+            image.data = qoi_decode(fileData, dataSize, &desc, (int) fileData[12]);
             image.width = desc.width;
             image.width = desc.width;
             image.height = desc.height;
             image.height = desc.height;
-            image.format = PIXELFORMAT_UNCOMPRESSED_R8G8B8A8;
+            image.format = desc.channels == 4 ? PIXELFORMAT_UNCOMPRESSED_R8G8B8A8 : PIXELFORMAT_UNCOMPRESSED_R8G8B8;
             image.mipmaps = 1;
             image.mipmaps = 1;
         }
         }
     }
     }