From 0db0e6acd8980d3790b96a17c407289e3e237371 Mon Sep 17 00:00:00 2001 From: raysan5 Date: Fri, 10 Jul 2020 19:18:29 +0200 Subject: [PATCH] WARNING: REMOVED: LoadImageEx() Reason for removal: This function forces a specific Image data format, it copies data internally (it could be confusing and lead to memory leaks), it's redundant, there is a simpler alternative and raylib promotes using structures directly --- src/raylib.h | 1 - src/textures.c | 27 --------------------------- 2 files changed, 28 deletions(-) diff --git a/src/raylib.h b/src/raylib.h index 49c7ba6a0..d38d53a04 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -1097,7 +1097,6 @@ RLAPI bool CheckCollisionPointTriangle(Vector2 point, Vector2 p1, Vector2 p2, Ve // Image loading functions // NOTE: This functions do not require GPU access RLAPI Image LoadImage(const char *fileName); // Load image from file into CPU memory (RAM) -RLAPI Image LoadImageEx(Color *pixels, int width, int height); // Load image from Color array data (RGBA - 32bit) RLAPI Image LoadImageRaw(const char *fileName, int width, int height, int format, int headerSize); // Load image from RAW file data RLAPI Image LoadImageAnim(const char *fileName, int *frames); // Load image sequence from file (frames appended to image.data) RLAPI void UnloadImage(Image image); // Unload image from CPU memory (RAM) diff --git a/src/textures.c b/src/textures.c index 5dd54b5a0..1889fdd09 100644 --- a/src/textures.c +++ b/src/textures.c @@ -305,33 +305,6 @@ Image LoadImage(const char *fileName) return image; } -// Load image from Color array data (RGBA - 32bit) -// NOTE: Creates a copy of pixels data array -Image LoadImageEx(Color *pixels, int width, int height) -{ - Image image = { 0 }; - image.data = NULL; - image.width = width; - image.height = height; - image.mipmaps = 1; - image.format = UNCOMPRESSED_R8G8B8A8; - - int k = 0; - - image.data = (unsigned char *)RL_MALLOC(image.width*image.height*4*sizeof(unsigned char)); - - for (int i = 0; i < image.width*image.height*4; i += 4) - { - ((unsigned char *)image.data)[i] = pixels[k].r; - ((unsigned char *)image.data)[i + 1] = pixels[k].g; - ((unsigned char *)image.data)[i + 2] = pixels[k].b; - ((unsigned char *)image.data)[i + 3] = pixels[k].a; - k++; - } - - return image; -} - // Load an image from RAW file data Image LoadImageRaw(const char *fileName, int width, int height, int format, int headerSize) {