mirror of
https://github.com/d0k3/GodMode9.git
synced 2025-06-26 13:42:47 +00:00
Initial PNG support (courtesy of lodepng).
This commit is contained in:
parent
823f3b6d60
commit
03014a72ee
@ -6,7 +6,7 @@ SOURCE := source
|
|||||||
BUILD := build
|
BUILD := build
|
||||||
|
|
||||||
SUBARCH := -D$(PROCESSOR) -mcpu=arm946e-s -mtune=arm946e-s -mfloat-abi=soft -mthumb
|
SUBARCH := -D$(PROCESSOR) -mcpu=arm946e-s -mtune=arm946e-s -mfloat-abi=soft -mthumb
|
||||||
INCDIRS := source source/common source/filesys source/crypto source/fatfs source/nand source/virtual source/game source/gamecart source/quicklz source/qrcodegen source/system source/utils
|
INCDIRS := source source/common source/filesys source/crypto source/fatfs source/nand source/virtual source/game source/gamecart source/lodepng source/quicklz source/qrcodegen source/system source/utils
|
||||||
INCLUDE := $(foreach dir,$(INCDIRS),-I"$(shell pwd)/$(dir)")
|
INCLUDE := $(foreach dir,$(INCDIRS),-I"$(shell pwd)/$(dir)")
|
||||||
|
|
||||||
ASFLAGS += $(SUBARCH) $(INCLUDE)
|
ASFLAGS += $(SUBARCH) $(INCLUDE)
|
||||||
|
6249
arm9/source/lodepng/lodepng.c
Normal file
6249
arm9/source/lodepng/lodepng.c
Normal file
File diff suppressed because it is too large
Load Diff
1769
arm9/source/lodepng/lodepng.h
Normal file
1769
arm9/source/lodepng/lodepng.h
Normal file
File diff suppressed because it is too large
Load Diff
32
arm9/source/system/png.c
Normal file
32
arm9/source/system/png.c
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#include <stddef.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "lodepng.h"
|
||||||
|
#include "png.h"
|
||||||
|
|
||||||
|
#include "ui.h"
|
||||||
|
|
||||||
|
u8 *PNG_Decompress(const u8 *png, size_t png_len, size_t *w, size_t *h)
|
||||||
|
{
|
||||||
|
u8 *img;
|
||||||
|
u32 res;
|
||||||
|
size_t w_, h_;
|
||||||
|
|
||||||
|
res = lodepng_decode24(&img, &w_, &h_, png, png_len);
|
||||||
|
if (res) {
|
||||||
|
ShowPrompt(false, "PNG error: %s", lodepng_error_text(res));
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// maybe process in batches of 3 pixels / 12 bytes at a time?
|
||||||
|
for (size_t i = 0; i < (w_ * h_ * 3); i += 3) {
|
||||||
|
u8 c = img[i];
|
||||||
|
img[i] = img[i + 2];
|
||||||
|
img[i + 2] = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (w) *w = w_;
|
||||||
|
if (h) *h = h_;
|
||||||
|
|
||||||
|
return img;
|
||||||
|
}
|
7
arm9/source/system/png.h
Normal file
7
arm9/source/system/png.h
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include "common.h"
|
||||||
|
#include "lodepng/lodepng.h"
|
||||||
|
|
||||||
|
u8 *PNG_Decompress(const u8 *png, size_t png_len, size_t *w, size_t *h);
|
Loading…
x
Reference in New Issue
Block a user