NSUNI/NSLAR Library a250670
Loading...
Searching...
No Matches
nnl::texture Namespace Reference

Contains structures and functions for working with in-game textures. More...

Classes

struct  ConvertParam
 Structure to hold parameters for texture conversion. More...
struct  Texture
 Structure representing a texture. More...
struct  TextureData
 Structure representing image data of a texture. More...

Typedefs

using TextureContainer = std::vector<Texture>
 Type alias for a container of textures.

Enumerations

enum class  TextureFormat : u16 {
  TextureFormat::kCLUT8 = 5 , TextureFormat::kCLUT4 = 4 , TextureFormat::kRGBA8888 = 3 , TextureFormat::kRGBA4444 = 2 ,
  TextureFormat::kRGBA5551 = 1 , TextureFormat::kRGB565 = 0
}
 Enumeration of texture formats. More...
enum class  ClutFormat : u8 { ClutFormat::kRGBA8888 = 3 , ClutFormat::kRGBA4444 = 2 , ClutFormat::kRGBA5551 = 1 , ClutFormat::kRGB565 = 0 }
 Enumeration of color formats used in Color Lookup Tables (CLUT). More...
enum class  TextureFilter : u8 {
  TextureFilter::kNearest = 0 , TextureFilter::kLinear = 1 , TextureFilter::kNearestMipmapNearest = 4 , TextureFilter::kLinearMipmapNearest = 5 ,
  TextureFilter::kNearestMipmapLinear = 6 , TextureFilter::kLinearMipmapLinear = 7
}
 Enumeration of texture filtering methods. More...

Functions

std::vector< STextureConvert (const TextureContainer &texture_container, bool mipmaps=false)
 Converts a container of textures to a simplified representation.
TextureContainer Convert (std::vector< STexture > &&images, const ConvertParam &texture_params={})
 Converts a vector of simplified textures into the in-game format.
bool IsOfType (BufferView buffer)
 Tests if the provided file is a texture container.
TextureContainer Import (BufferView buffer)
 Parses a binary file and converts it to a structured texture container.
Buffer Export (const TextureContainer &texture_container)
 Converts a texture container to its binary file representation.
Texture Convert (STexture &&image, const ConvertParam &tex_param={})
 Converts a texture from a simplified representation to the in-game format.
STexture Convert (const Texture &texture, unsigned int level=0)
 Converts a texture from the in-game format to a simplified representation.
Buffer ConvertRGB565ToRGBA8888 (BufferView bitmap565)
 Converts an image buffer from RGB565 format to RGBA8888 format.
Buffer ConvertRGBA5551ToRGBA8888 (BufferView bitmap5551)
 Converts an image buffer from RGBA5551 format to RGBA8888 format.
Buffer ConvertRGBA4444ToRGBA8888 (BufferView bitmap4444)
 Converts an image buffer from RGBA4444 format to RGBA8888 format.
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 UnswizzleFromMem (BufferView texptr, u32 bufw, u32 height, u32 bytes_per_pixel)
 Unswizzles texture data.
Buffer SwizzleFromMem (Buffer &texptr, u32 bufw, u32 height, u32 bytes_per_pixel)
 Swizzles texture data.
u32 QuickTexHash (BufferView data)
 Computes a quick hash for a texture.
Buffer ConvertIndexed4To8 (BufferView clut4, u32 width)
 Converts a 4-bit indexed texture to an 8-bit indexed texture.
Buffer ConvertIndexed8To4 (BufferView clut8, u32 width)
 Converts an 8-bit indexed texture to a 4-bit indexed texture.
std::vector< SPixelGeneratePaletteMedian (const STexture &source_image, std::size_t num_colors=256)
 Creates a color palette using the median cut algorithm.
std::vector< SPixelGeneratePaletteNaive (const STexture &source_image, std::size_t num_colors=256)
 Creates a color palette by extracting the first N unique colors from the image.
std::vector< u8ApplyPalette (const STexture &image, const std::vector< SPixel > &palette, bool dither=true)
 Applies a color palette to the image.
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.
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.
Buffer DeindexClut8ToRGBA8888 (BufferView indexed_image, BufferView palette)
 Converts an 8-bit indexed image buffer to an RGBA8888 buffer.
ConvertParam GenerateConvertParam (const Texture &texture)
 Generates conversion parameters from a given texture.
std::vector< ConvertParamGenerateConvertParam (const TextureContainer &texture_container)
 Generates conversion parameters from a given texture container.

Variables

constexpr unsigned int kMinDimension = 1
 Minimum allowed width and height of a texture in pixels.
constexpr unsigned int kMinByteBufferWidth = 16
 Minimum width of a texture buffer in bytes (as expected by the GE). The actual pixel width can be smaller than this.
constexpr unsigned int kMaxDimension = 1024
 Maximum allowed width and height of a texture in pixels.
constexpr std::size_t kMaxMipMapLvl = 7
 The maximum number of mipmap levels that can be used.
constexpr std::size_t kMaxTextureLvl = 1 + kMaxMipMapLvl
 The maximum number of texture levels.

Detailed Description

Contains structures and functions for working with in-game textures.

See also
nnl::texture::TextureContainer
nnl::texture::IsOfType
nnl::texture::Import
nnl::texture::Export
nnl::texture::Convert