Browse Source

Support PIC image format loading

pull/703/head
Ray 6 years ago
parent
commit
965a91cebb
1 changed files with 25 additions and 10 deletions
  1. +25
    -10
      src/textures.c

+ 25
- 10
src/textures.c View File

@ -10,13 +10,14 @@
* #define SUPPORT_FILEFORMAT_JPG * #define SUPPORT_FILEFORMAT_JPG
* #define SUPPORT_FILEFORMAT_GIF * #define SUPPORT_FILEFORMAT_GIF
* #define SUPPORT_FILEFORMAT_PSD * #define SUPPORT_FILEFORMAT_PSD
* #define SUPPORT_FILEFORMAT_PIC
* #define SUPPORT_FILEFORMAT_HDR * #define SUPPORT_FILEFORMAT_HDR
* #define SUPPORT_FILEFORMAT_DDS * #define SUPPORT_FILEFORMAT_DDS
* #define SUPPORT_FILEFORMAT_PKM * #define SUPPORT_FILEFORMAT_PKM
* #define SUPPORT_FILEFORMAT_KTX * #define SUPPORT_FILEFORMAT_KTX
* #define SUPPORT_FILEFORMAT_PVR * #define SUPPORT_FILEFORMAT_PVR
* #define SUPPORT_FILEFORMAT_ASTC * #define SUPPORT_FILEFORMAT_ASTC
* Selecte desired fileformats to be supported for image data loading. Some of those formats are
* Select desired fileformats to be supported for image data loading. Some of those formats are
* supported by default, to remove support, just comment unrequired #define in this module * supported by default, to remove support, just comment unrequired #define in this module
* *
* #define SUPPORT_IMAGE_EXPORT * #define SUPPORT_IMAGE_EXPORT
@ -65,16 +66,14 @@
#include <stdlib.h> // Required for: malloc(), free() #include <stdlib.h> // Required for: malloc(), free()
#include <string.h> // Required for: strlen() #include <string.h> // Required for: strlen()
#include <stdio.h> // Required for: FILE, fopen(), fclose(), fread()
#include "utils.h" // Required for: fopen() Android mapping
#include "rlgl.h" // raylib OpenGL abstraction layer to OpenGL 1.1, 3.3 or ES2 #include "rlgl.h" // raylib OpenGL abstraction layer to OpenGL 1.1, 3.3 or ES2
// Required for: rlLoadTexture() rlDeleteTextures(), // Required for: rlLoadTexture() rlDeleteTextures(),
// rlGenerateMipmaps(), some funcs for DrawTexturePro() // rlGenerateMipmaps(), some funcs for DrawTexturePro()
#include "utils.h" // Required for: fopen() Android mapping
#define STB_PERLIN_IMPLEMENTATION
#include "external/stb_perlin.h"// Required for: stb_perlin_fbm_noise3
// Support only desired texture formats on stb_image // Support only desired texture formats on stb_image
#if !defined(SUPPORT_FILEFORMAT_BMP) #if !defined(SUPPORT_FILEFORMAT_BMP)
#define STBI_NO_BMP #define STBI_NO_BMP
@ -94,6 +93,9 @@
#if !defined(SUPPORT_FILEFORMAT_GIF) #if !defined(SUPPORT_FILEFORMAT_GIF)
#define STBI_NO_GIF #define STBI_NO_GIF
#endif #endif
#if !defined(SUPPORT_FILEFORMAT_PIC)
#define STBI_NO_PIC
#endif
#if !defined(SUPPORT_FILEFORMAT_HDR) #if !defined(SUPPORT_FILEFORMAT_HDR)
#define STBI_NO_HDR #define STBI_NO_HDR
#endif #endif
@ -102,8 +104,13 @@
#define STBI_NO_PIC #define STBI_NO_PIC
#define STBI_NO_PNM // Image format .ppm and .pgm #define STBI_NO_PNM // Image format .ppm and .pgm
#if (defined(SUPPORT_FILEFORMAT_BMP) || defined(SUPPORT_FILEFORMAT_PNG) || defined(SUPPORT_FILEFORMAT_TGA) || \
defined(SUPPORT_FILEFORMAT_JPG) || defined(SUPPORT_FILEFORMAT_PSD) || defined(SUPPORT_FILEFORMAT_GIF) || \
#if (defined(SUPPORT_FILEFORMAT_BMP) || \
defined(SUPPORT_FILEFORMAT_PNG) || \
defined(SUPPORT_FILEFORMAT_TGA) || \
defined(SUPPORT_FILEFORMAT_JPG) || \
defined(SUPPORT_FILEFORMAT_PSD) || \
defined(SUPPORT_FILEFORMAT_GIF) || \
defined(SUPPORT_FILEFORMAT_PIC) || \
defined(SUPPORT_FILEFORMAT_HDR)) defined(SUPPORT_FILEFORMAT_HDR))
#define STB_IMAGE_IMPLEMENTATION #define STB_IMAGE_IMPLEMENTATION
#include "external/stb_image.h" // Required for: stbi_load_from_file() #include "external/stb_image.h" // Required for: stbi_load_from_file()
@ -121,6 +128,11 @@
// NOTE: Used for image scaling on ImageResize() // NOTE: Used for image scaling on ImageResize()
#endif #endif
#if defined(SUPPORT_IMAGE_GENERATION)
#define STB_PERLIN_IMPLEMENTATION
#include "external/stb_perlin.h" // Required for: stb_perlin_fbm_noise3
#endif
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Defines and Macros // Defines and Macros
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
@ -180,9 +192,12 @@ Image LoadImage(const char *fileName)
#if defined(SUPPORT_FILEFORMAT_JPG) #if defined(SUPPORT_FILEFORMAT_JPG)
|| (IsFileExtension(fileName, ".jpg")) || (IsFileExtension(fileName, ".jpg"))
#endif #endif
#if defined(SUPPORT_FILEFORMAT_DDS)
#if defined(SUPPORT_FILEFORMAT_GIF)
|| (IsFileExtension(fileName, ".gif")) || (IsFileExtension(fileName, ".gif"))
#endif #endif
#if defined(SUPPORT_FILEFORMAT_PIC)
|| (IsFileExtension(fileName, ".pic"))
#endif
#if defined(SUPPORT_FILEFORMAT_PSD) #if defined(SUPPORT_FILEFORMAT_PSD)
|| (IsFileExtension(fileName, ".psd")) || (IsFileExtension(fileName, ".psd"))
#endif #endif
@ -196,7 +211,7 @@ Image LoadImage(const char *fileName)
if (imFile != NULL) if (imFile != NULL)
{ {
// NOTE: Using stb_image to load images (l">Supports: BMP, TGA, PNG, JPG, ...)
// NOTE: Using stb_image to load images (">Supports multiple image formats)
image.data = stbi_load_from_file(imFile, &imgWidth, &imgHeight, &imgBpp, 0); image.data = stbi_load_from_file(imFile, &imgWidth, &imgHeight, &imgBpp, 0);
fclose(imFile); fclose(imFile);

Loading…
Cancel
Save