From 2357093bc80b4899af62dbedcc68707c3cf01d6f Mon Sep 17 00:00:00 2001 From: tildearrow Date: Mon, 28 Aug 2023 05:58:46 -0500 Subject: [PATCH] GUI: fix image loading (big endian) --- src/gui/gui.cpp | 4 ---- src/gui/image.cpp | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index db3d4311f..07be9fefb 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -6361,11 +6361,7 @@ bool FurnaceGUI::init() { const FurnaceGUIImage* furIcon=getImage(GUI_IMAGE_ICON); SDL_Surface* icon=NULL; if (furIcon!=NULL) { -#ifdef TA_BIG_ENDIAN - icon=SDL_CreateRGBSurfaceFrom(furIcon->data,furIcon->width,furIcon->height,32,256*4,0xff000000,0xff0000,0xff00,0xff); -#else icon=SDL_CreateRGBSurfaceFrom(furIcon->data,furIcon->width,furIcon->height,32,256*4,0xff,0xff00,0xff0000,0xff000000); -#endif } else { logE("furIcon is NULL!"); } diff --git a/src/gui/image.cpp b/src/gui/image.cpp index 493b5a57f..a5c7baec3 100644 --- a/src/gui/image.cpp +++ b/src/gui/image.cpp @@ -87,6 +87,20 @@ FurnaceGUIImage* FurnaceGUI::getImage(FurnaceGUIImages image) { logV("%dx%d",ret->width,ret->height); +#ifdef TA_BIG_ENDIAN + if (ret->ch==4) { + size_t total=ret->width*ret->height*ret->ch; + for (size_t i=0; idata[i]^=ret->data[i|3]; + ret->data[i|3]^=ret->data[i]; + ret->data[i]^=ret->data[i|3]; + ret->data[i|1]^=ret->data[i|2]; + ret->data[i|2]^=ret->data[i|1]; + ret->data[i|1]^=ret->data[i|2]; + } + } +#endif + images[image]=ret; }