265bool IsOfType(
const std::filesystem::path& path);
529 unsigned int buffer_width);
546 unsigned int buffer_width);
617constexpr u32 kColorEntriesInBlock = 16;
621 u32 offset_textures = 0;
622 u32 offset_texture_data = 0;
623 u32 offset_clut_offsets = 0;
624 u16 num_textures = 0;
625 u16 num_texture_data = 0;
626 u16 num_clut_offsets = 0;
630static_assert(
sizeof(RHeader) == 0x18);
633 u16 texture_format = 0;
634 u16 index_texture_data = 0;
635 u8 num_texture_data_mipmaps = 0;
637 u8 filter_minifying = 0;
638 u8 filter_magnifying = 0;
640 u8 clut_load_size = 0;
644static_assert(
sizeof(RTexture) == 0xC);
647 u32 offset_bitmap = 0;
650 u16 buffer_width = 0;
651 u16 height_rounded = 0;
656static_assert(
sizeof(RTextureData) == 0x14);
658struct RTextureContainer {
660 std::vector<RTexture> textures;
661 std::vector<RTextureData> texture_data;
662 std::vector<u32> clut_offsets;
664 std::map<u32, Buffer> bitmaps;
665 std::map<u32, Buffer> cluts;
670RTextureContainer Parse(Reader& f);
Contains macros and definitions for fixed-width types.
std::uint16_t u16
16-bit unsigned integer
Definition fixed_type.hpp:62
std::uint32_t u32
32-bit unsigned integer
Definition fixed_type.hpp:60
std::uint8_t u8
8-bit unsigned integer
Definition fixed_type.hpp:64
#define NNL_PACK(...)
A structure packing directive.
Definition fixed_type.hpp:41
Represents a simple texture.
Definition stexture.hpp:77
std::vector< u8 > ApplyPalette(const STexture &image, const std::vector< SPixel > &palette, bool dither=true)
Applies a color palette to the image.
Buffer ConvertRGBA4444ToRGBA8888(BufferView bitmap4444)
Converts an image buffer from RGBA4444 format to RGBA8888 format.
Buffer ConvertRGB565ToRGBA8888(BufferView bitmap565)
Converts an image buffer from RGB565 format to RGBA8888 format.
Buffer UnswizzleFromMem(BufferView texptr, u32 bufw, u32 height, u32 bytes_per_pixel)
Unswizzles texture data.
Buffer ConvertRGBA5551ToRGBA8888(BufferView bitmap5551)
Converts an image buffer from RGBA5551 format to RGBA8888 format.
ConvertParam GenerateConvertParam(const Texture &texture)
Generates conversion parameters from a given texture.
Buffer AlignBufferWidth(BufferView image_buffer, unsigned int width, unsigned int height, unsigned int bpp, unsigned int buffer_width)
Aligns the buffer width to a desired buffer width.
u32 QuickTexHash(BufferView data)
Computes a quick hash for a texture.
Buffer DealignBufferWidth(BufferView image_buffer, unsigned int width, unsigned int height, unsigned int bpp, unsigned int buffer_width)
Removes padding from an aligned image buffer.
std::vector< SPixel > GeneratePaletteMedian(const STexture &source_image, std::size_t num_colors=256)
Creates a color palette using the median cut algorithm.
Buffer SwizzleFromMem(Buffer &texptr, u32 bufw, u32 height, u32 bytes_per_pixel)
Swizzles texture data.
Buffer ConvertIndexed8To4(BufferView clut8, u32 width)
Converts an 8-bit indexed texture to a 4-bit indexed texture.
std::vector< SPixel > GeneratePaletteNaive(const STexture &source_image, std::size_t num_colors=256)
Creates a color palette by extracting the first N unique colors from the image.
Buffer ConvertRGBA8888ToRGBA4444(BufferView bitmap8888)
Converts an image buffer from RGBA8888 format to RGBA4444 format.
Buffer ConvertRGBA8888ToRGBA5551(BufferView bitmap8888)
Converts an image buffer from RGBA8888 format to RGBA5551 format.
Buffer ConvertRGBA8888ToRGB565(BufferView bitmap8888)
Converts an image buffer from RGBA8888 format to RGB565 format.
Buffer DeindexClut8ToRGBA8888(BufferView indexed_image, BufferView palette)
Converts an 8-bit indexed image buffer to an RGBA8888 buffer.
Buffer ConvertIndexed4To8(BufferView clut4, u32 width)
Converts a 4-bit indexed texture to an 8-bit indexed texture.
utl::static_vector< TextureData, kMaxTextureLvl > texture_data
Definition texture.hpp:166
bool swizzled
Definition texture.hpp:171
TextureFilter mag_filter
Definition texture.hpp:174
bool clut_dither
Definition texture.hpp:205
u16 buffer_width
Definition texture.hpp:150
ClutFormat clut_format
Definition texture.hpp:203
Buffer bitmap_buffer
Raw bitmap data. Its interpretation depends on the texture_format.
Definition texture.hpp:153
ClutFormat clut_format
Format of the CLUT data.
Definition texture.hpp:176
u16 height
Definition texture.hpp:148
bool swizzle
Definition texture.hpp:213
Buffer clut_buffer
Definition texture.hpp:164
unsigned int max_mipmap_lvl
The maximum number of mipmap levels to generate.
Definition texture.hpp:208
TextureFormat texture_format
The format the texture will be converted to.
Definition texture.hpp:202
TextureFilter min_filter
Minification filter method for texture sampling.
Definition texture.hpp:173
TextureFormat texture_format
Format of the texture data.
Definition texture.hpp:170
u16 width
Width of the texture in pixels. It must be a power of 2.
Definition texture.hpp:147
bool gen_small_mipmap
Definition texture.hpp:209
unsigned int max_width_height
Definition texture.hpp:211
Structure representing a texture.
Definition texture.hpp:163
Structure representing image data of a texture.
Definition texture.hpp:146
Structure to hold parameters for texture conversion.
Definition texture.hpp:201
TextureFormat
Enumeration of texture formats.
Definition texture.hpp:84
std::vector< STexture > Convert(const TextureContainer &texture_container, bool mipmaps=false)
Converts a container of textures to a simplified representation.
constexpr unsigned int kMaxDimension
Maximum allowed width and height of a texture in pixels.
Definition texture.hpp:60
constexpr std::size_t kMaxMipMapLvl
The maximum number of mipmap levels that can be used.
Definition texture.hpp:66
TextureFilter
Enumeration of texture filtering methods.
Definition texture.hpp:122
constexpr std::size_t kMaxTextureLvl
The maximum number of texture levels.
Definition texture.hpp:72
std::vector< Texture > TextureContainer
Type alias for a container of textures.
Definition texture.hpp:191
bool IsOfType(BufferView buffer)
Tests if the provided file is a texture container.
ClutFormat
Enumeration of color formats used in Color Lookup Tables (CLUT).
Definition texture.hpp:101
Buffer Export(const TextureContainer &texture_container)
Converts a texture container to its binary file representation.
constexpr unsigned int kMinDimension
Minimum allowed width and height of a texture in pixels.
Definition texture.hpp:47
constexpr unsigned int kMinByteBufferWidth
Minimum width of a texture buffer in bytes (as expected by the GE). The actual pixel width can be sma...
Definition texture.hpp:53
TextureContainer Import(BufferView buffer)
Parses a binary file and converts it to a structured texture container.
@ kCLUT4
Definition texture.hpp:87
@ kRGB565
16-bit color format. No CLUT.
Definition texture.hpp:92
@ kRGBA8888
32-bit color format with 8 bits per channel. No CLUT.
Definition texture.hpp:89
@ kCLUT8
Definition texture.hpp:85
@ kRGBA4444
16-bit color format with 4 bits per channel. No CLUT.
Definition texture.hpp:90
@ kRGBA5551
16-bit color format. No CLUT.
Definition texture.hpp:91
@ kLinear
Linear filtering.
Definition texture.hpp:124
@ kLinearMipmapLinear
Linear filtering with mipmap selection.
Definition texture.hpp:129
@ kNearestMipmapNearest
Nearest filtering with mipmap selection.
Definition texture.hpp:126
@ kNearest
Nearest-neighbor filtering.
Definition texture.hpp:123
@ kLinearMipmapNearest
Linear filtering with mipmap selection.
Definition texture.hpp:127
@ kNearestMipmapLinear
Nearest filtering with mipmap selection.
Definition texture.hpp:128
@ kRGBA8888
32-bit color format. 8 bits per channel.
Definition texture.hpp:102
constexpr u32 kMagicBytes
Magic bytes used to identify the texture format.
Definition texture.hpp:615
std::vector like class with a fixed-size inline storage (aka std::inplace_vector)
Definition static_vector.hpp:52
Provides classes for reading and writing binary data to and from various sources.
Contains structures and functions for working with in-game textures.
Definition texture.hpp:36
Definition exception.hpp:56
Defines the static_vector class that functions like std::vector but stores its elements within the ob...
Provides data structures for representing essential components of a texture.