diff options
| author | raysan5 <[email protected]> | 2020-06-02 23:08:34 +0200 |
|---|---|---|
| committer | raysan5 <[email protected]> | 2020-06-02 23:08:34 +0200 |
| commit | 3792951023a39765957fd53757b8c6ca45803093 (patch) | |
| tree | 61179cae2a61fb4dbf0830e2cce17723f7f435ce | |
| parent | a4333035c7c3993c3da5f50e3859d40db853dd20 (diff) | |
| download | raylib-3792951023a39765957fd53757b8c6ca45803093.tar.gz raylib-3792951023a39765957fd53757b8c6ca45803093.zip | |
REVIEWED: GetPixelDataSize() to consider compressed data properly
| -rw-r--r-- | src/textures.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/textures.c b/src/textures.c index d73cc1c6..aee5ad97 100644 --- a/src/textures.c +++ b/src/textures.c @@ -3222,6 +3222,14 @@ int GetPixelDataSize(int width, int height, int format) } dataSize = width*height*bpp/8; // Total data size in bytes + + // Most compressed formats works on 4x4 blocks, + // if texture is smaller, minimum dataSize is 8 or 16 + if ((width < 4) && (height < 4)) + { + if ((format >= COMPRESSED_DXT1_RGB) && (format < COMPRESSED_DXT3_RGBA)) dataSize = 8; + else if ((format >= COMPRESSED_DXT3_RGBA) && (format < COMPRESSED_ASTC_8x8_RGBA)) dataSize = 16; + } return dataSize; } |
