3#include <ntr/gfx/gfx_Conversion.hpp>
7 constexpr size_t IconWidth = 32;
8 constexpr size_t IconHeight = 32;
10 constexpr size_t IconCharSize = 0x200;
11 constexpr size_t IconPaletteSize = 0x20;
12 constexpr size_t IconPaletteColorCount = IconPaletteSize /
sizeof(xbgr1555::Color);
14 constexpr PixelFormat IconPixelFormat = PixelFormat::Palette16;
15 constexpr CharacterFormat IconCharacterFormat = CharacterFormat::Char;
17 inline Result ConvertBannerIconToRgba(
const u8 *icon_char,
const u8 *icon_plt, abgr8888::Color *&out_rgba) {
18 GraphicsToRgbaContext ctx = {
19 .gfx_data = icon_char,
20 .gfx_data_size = IconCharSize,
22 .plt_data_size = IconPaletteSize,
24 .def_width = IconWidth,
25 .def_height = IconHeight,
26 .pix_fmt = IconPixelFormat,
27 .char_fmt = IconCharacterFormat,
28 .first_color_transparent =
true
30 NTR_R_TRY(ConvertGraphicsToRgba(ctx));
32 if((ctx.out_width != IconWidth) || (ctx.out_height != IconHeight)) {
33 NTR_R_FAIL(ResultUnexpectedBannerIconDimensions);
36 out_rgba = ctx.out_rgba;
40 inline Result ConvertBannerIconFromRgba(
const abgr8888::Color *icon, u8 *&out_icon_char, u8 *&out_icon_plt) {
41 RgbaToGraphicsContext ctx = {
45 .pix_fmt = IconPixelFormat,
46 .char_fmt = IconCharacterFormat,
49 NTR_R_TRY(ConvertRgbaToGraphics(ctx));
51 if((ctx.out_gfx_data_size != IconCharSize) || (ctx.out_plt_data_size != IconPaletteSize)) {
52 NTR_R_FAIL(ResultUnexpectedBannerIconDimensions);
55 out_icon_char = ctx.out_gfx_data;
56 out_icon_plt = ctx.out_plt_data;