shithub: cstory

Download patch

ref: 6a0005746978070c86dcac7681db8389c98fd172
parent: abdd7fc771cfed3f45a1354162e66cab90b5b1cf
author: Clownacy <Clownacy@users.noreply.github.com>
date: Tue Apr 21 19:57:07 EDT 2020

Do not stream bitmaps

Again - Wii U SD card IO is terrible, so load the whole file at
once instead.

--- a/src/Bitmap.cpp
+++ b/src/Bitmap.cpp
@@ -6,8 +6,11 @@
 #define STB_IMAGE_STATIC
 #define STBI_ONLY_BMP
 #define STBI_NO_LINEAR
+#define STBI_NO_STDIO
 #include "../external/stb_image.h"
 
+#include "File.h"
+
 unsigned char* DecodeBitmap(const unsigned char *in_buffer, size_t in_buffer_size, unsigned int *width, unsigned int *height)
 {
 	return stbi_load_from_memory(in_buffer, in_buffer_size, (int*)width, (int*)height, NULL, 3);
@@ -15,7 +18,14 @@
 
 unsigned char* DecodeBitmapFromFile(const char *path, unsigned int *width, unsigned int *height)
 {
-	return stbi_load(path, (int*)width, (int*)height, NULL, 3);
+	size_t file_size;
+	unsigned char *file_buffer = LoadFileToMemory(path, &file_size);
+
+	unsigned char *pixel_buffer = stbi_load_from_memory(file_buffer, file_size, (int*)width, (int*)height, NULL, 3);
+
+	free(file_buffer);
+
+	return pixel_buffer;
 }
 
 void FreeBitmap(unsigned char *buffer)