enhancement: replaced nanojpeg with turbojpeg library
This commit is contained in:
parent
69e11599f4
commit
61da97a657
@ -53,7 +53,7 @@ CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
|
|||||||
ASFLAGS := -g $(ARCH)
|
ASFLAGS := -g $(ARCH)
|
||||||
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
||||||
|
|
||||||
LIBS := `freetype-config --libs` -lconfig
|
LIBS := `freetype-config --libs` -lconfig -lturbojpeg
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
# list of directories containing libraries, this must be the top level containing
|
# list of directories containing libraries, this must be the top level containing
|
||||||
|
@ -27,7 +27,7 @@ test : pc_main/main.cpp pc_main/pc_launch.c \
|
|||||||
build_pc/hbmenu_logo_light.bin.o build_pc/hbmenu_logo_dark.bin.o \
|
build_pc/hbmenu_logo_light.bin.o build_pc/hbmenu_logo_dark.bin.o \
|
||||||
build_pc/theme_icon_dark.bin.o build_pc/theme_icon_light.bin.o \
|
build_pc/theme_icon_dark.bin.o build_pc/theme_icon_light.bin.o \
|
||||||
#build_pc/tahoma24.o build_pc/tahoma12.o build_pc/interuimedium20.o build_pc/interuimedium30.o build_pc/interuiregular14.o build_pc/interuiregular18.o
|
#build_pc/tahoma24.o build_pc/tahoma12.o build_pc/interuimedium20.o build_pc/interuimedium30.o build_pc/interuiregular14.o build_pc/interuiregular18.o
|
||||||
gcc -Wall -O2 -g -DVERSION=\"v$(APP_VERSION)\" $(EXTRA_CFLAGS) `pkg-config freetype2 --cflags` $^ -lsfml-graphics -lsfml-window -lsfml-system -lstdc++ `pkg-config freetype2 --libs` -lm -lz -lconfig $(EXTRA_LDFLAGS) -I. -iquote $(DEVKITPRO)/libnx/include -Ibuild_pc -g -o $@
|
gcc -Wall -O2 -g -DVERSION=\"v$(APP_VERSION)\" $(EXTRA_CFLAGS) `pkg-config freetype2 --cflags` $^ -lsfml-graphics -lsfml-window -lsfml-system -lstdc++ `pkg-config freetype2 --libs` -lm -lz -lconfig -lturbojpeg $(EXTRA_LDFLAGS) -I. -iquote $(DEVKITPRO)/libnx/include -Ibuild_pc -g -o $@
|
||||||
|
|
||||||
build_pc/tahoma12.o : data/tahoma12.nxfnt
|
build_pc/tahoma12.o : data/tahoma12.nxfnt
|
||||||
mkdir -p $(dir $@)
|
mkdir -p $(dir $@)
|
||||||
|
@ -54,7 +54,7 @@ typedef union {
|
|||||||
#include "text.h"
|
#include "text.h"
|
||||||
#include "ui.h"
|
#include "ui.h"
|
||||||
#include "launch.h"
|
#include "launch.h"
|
||||||
#include "nanojpeg.h"
|
#include <turbojpeg.h>
|
||||||
#include "math.h"
|
#include "math.h"
|
||||||
#include "theme.h"
|
#include "theme.h"
|
||||||
#include "message-box.h"
|
#include "message-box.h"
|
||||||
|
@ -322,42 +322,33 @@ bool menuEntryLoad(menuEntry_s* me, const char* name, bool shortcut) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void menuEntryParseIcon(menuEntry_s* me) {
|
void menuEntryParseIcon(menuEntry_s* me) {
|
||||||
uint8_t *imageptr = NULL;
|
|
||||||
size_t imagesize = 256*256*3;
|
size_t imagesize = 256*256*3;
|
||||||
|
unsigned char imageptr[imagesize];
|
||||||
|
int w,h,samp;
|
||||||
|
|
||||||
if (me->icon_size==0 || me->icon==NULL) return;
|
if (me->icon_size==0 || me->icon==NULL) return;
|
||||||
|
|
||||||
njInit();
|
tjhandle _jpegDecompressor = tjInitDecompress();
|
||||||
|
|
||||||
if (njDecode(me->icon, me->icon_size) != NJ_OK) {
|
if(tjDecompressHeader2(_jpegDecompressor, me->icon, me->icon_size, &w, &h, &samp)==-1) return;
|
||||||
njDone();
|
|
||||||
|
if (w != 256 || h != 256 ) return; //The decoded image must be 256x256.
|
||||||
|
|
||||||
|
if(tjDecompress2(_jpegDecompressor, me->icon, me->icon_size, imageptr, w, 0/*pitch*/, h, TJPF_RGB, TJFLAG_ACCURATEDCT)==-1)//The decoded image must be RGB
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
me->icon_size = 0;
|
me->icon_size = 0;
|
||||||
free(me->icon);
|
free(me->icon);
|
||||||
me->icon = NULL;
|
me->icon = NULL;
|
||||||
|
|
||||||
if ((njGetWidth() != 256 || njGetHeight() != 256 || (size_t)njGetImageSize() != imagesize) || njIsColor() != 1) {//The decoded image must be RGB and 256x256.
|
if (imageptr[0] == 0) return;
|
||||||
njDone();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
imageptr = njGetImage();
|
|
||||||
if (imageptr == NULL) {
|
|
||||||
njDone();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
me->icon_gfx = (uint8_t*)malloc(imagesize);
|
me->icon_gfx = (uint8_t*)malloc(imagesize);
|
||||||
if (me->icon_gfx == NULL) {
|
|
||||||
njDone();
|
if (me->icon_gfx == NULL) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(me->icon_gfx, imageptr, imagesize);
|
memcpy(me->icon_gfx, imageptr, imagesize);
|
||||||
|
tjDestroy(_jpegDecompressor);
|
||||||
njDone();
|
|
||||||
|
|
||||||
me->icon_gfx_small = downscaleImg(me->icon_gfx, 256, 256, 140, 140, IMAGE_MODE_RGB24);
|
me->icon_gfx_small = downscaleImg(me->icon_gfx, 256, 256, 140, 140, IMAGE_MODE_RGB24);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user