NSUNI/NSLAR Library a250670
Loading...
Searching...
No Matches
Auxiliary

Functions

Texture nnl::texture::Convert (STexture &&image, const ConvertParam &tex_param={})
 Converts a texture from a simplified representation to the in-game format.
STexture nnl::texture::Convert (const Texture &texture, unsigned int level=0)
 Converts a texture from the in-game format to a simplified representation.
Buffer nnl::texture::ConvertRGB565ToRGBA8888 (BufferView bitmap565)
 Converts an image buffer from RGB565 format to RGBA8888 format.
Buffer nnl::texture::ConvertRGBA5551ToRGBA8888 (BufferView bitmap5551)
 Converts an image buffer from RGBA5551 format to RGBA8888 format.
Buffer nnl::texture::ConvertRGBA4444ToRGBA8888 (BufferView bitmap4444)
 Converts an image buffer from RGBA4444 format to RGBA8888 format.
Buffer nnl::texture::ConvertRGBA8888ToRGBA4444 (BufferView bitmap8888)
 Converts an image buffer from RGBA8888 format to RGBA4444 format.
Buffer nnl::texture::ConvertRGBA8888ToRGBA5551 (BufferView bitmap8888)
 Converts an image buffer from RGBA8888 format to RGBA5551 format.
Buffer nnl::texture::ConvertRGBA8888ToRGB565 (BufferView bitmap8888)
 Converts an image buffer from RGBA8888 format to RGB565 format.
Buffer nnl::texture::UnswizzleFromMem (BufferView texptr, u32 bufw, u32 height, u32 bytes_per_pixel)
 Unswizzles texture data.
Buffer nnl::texture::SwizzleFromMem (Buffer &texptr, u32 bufw, u32 height, u32 bytes_per_pixel)
 Swizzles texture data.
u32 nnl::texture::QuickTexHash (BufferView data)
 Computes a quick hash for a texture.
Buffer nnl::texture::ConvertIndexed4To8 (BufferView clut4, u32 width)
 Converts a 4-bit indexed texture to an 8-bit indexed texture.
Buffer nnl::texture::ConvertIndexed8To4 (BufferView clut8, u32 width)
 Converts an 8-bit indexed texture to a 4-bit indexed texture.
std::vector< SPixelnnl::texture::GeneratePaletteMedian (const STexture &source_image, std::size_t num_colors=256)
 Creates a color palette using the median cut algorithm.
std::vector< SPixelnnl::texture::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.
std::vector< u8nnl::texture::ApplyPalette (const STexture &image, const std::vector< SPixel > &palette, bool dither=true)
 Applies a color palette to the image.
Buffer nnl::texture::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 nnl::texture::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 nnl::texture::DeindexClut8ToRGBA8888 (BufferView indexed_image, BufferView palette)
 Converts an 8-bit indexed image buffer to an RGBA8888 buffer.
ConvertParam nnl::texture::GenerateConvertParam (const Texture &texture)
 Generates conversion parameters from a given texture.
std::vector< ConvertParamnnl::texture::GenerateConvertParam (const TextureContainer &texture_container)
 Generates conversion parameters from a given texture container.

Detailed Description

Function Documentation

◆ AlignBufferWidth()

Buffer nnl::texture::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.

This function takes an image buffer and adjusts its width to ensure it's aligned to a minimum of 16 bytes, which is a requirement for the GE.

Parameters
image_bufferA vector containing the original image data.
widthThe width of the image in pixels.
heightThe height of the image in pixels.
bppThe number of bytes per pixel. 0 for less than a byte.
buffer_widthThe desired width of the buffer in pixels.
Returns
A vector containing the aligned buffer data.
See also
nnl::texture::DealignBufferWidth

◆ ApplyPalette()

std::vector< u8 > nnl::texture::ApplyPalette ( const STexture & image,
const std::vector< SPixel > & palette,
bool dither = true )

Applies a color palette to the image.

This function converts the image to an indexed color format using the specified palette. Replaces each pixel's color with the closest matching color from the palette.

Parameters
imageThe source texture to which the palette will be applied.
paletteA vector of SPixel representing the color palette to be applied to the texture.
ditherA flag indicating whether dithering should be used during the palette application. It can help reduce color banding artifacts.
Returns
A vector containing an 8-bit indexed image data.

◆ Convert() [1/2]

STexture nnl::texture::Convert ( const Texture & texture,
unsigned int level = 0 )

Converts a texture from the in-game format to a simplified representation.

This function takes an in-game texture in various formats and converts it into a simplified representation.

Parameters
textureThe input texture to be converted.
levelThe texture level to convert. The default value is 0, which corresponds to the base level. Higher values correspond to mipmaps.
Returns
A STexture object representing the converted texture.
See also
nnl::STexture

◆ Convert() [2/2]

Texture nnl::texture::Convert ( STexture && image,
const ConvertParam & tex_param = {} )

Converts a texture from a simplified representation to the in-game format.

This function takes a simple texture and converts it to the in-game format using the provided settings.

Parameters
imageThe input texture to be converted.
tex_paramA ConvertParam structure containing the conversion settings.
Returns
A Texture object representing the converted texture.
Note
Use std::move when passing an existing object.
See also
nnl::texture::TextureContainer

◆ ConvertIndexed4To8()

Buffer nnl::texture::ConvertIndexed4To8 ( BufferView clut4,
u32 width )

Converts a 4-bit indexed texture to an 8-bit indexed texture.

Parameters
clut4A vector containing the texture data in 4-bit indexed format.
widthTexture width
Returns
A vector containing the converted data in 8-bit indexed format.

◆ ConvertIndexed8To4()

Buffer nnl::texture::ConvertIndexed8To4 ( BufferView clut8,
u32 width )

Converts an 8-bit indexed texture to a 4-bit indexed texture.

Parameters
clut8A vector containing the texture data in 8-bit indexed format.
widthTexture width
Returns
A vector containing the converted data in 4-bit indexed format.

◆ ConvertRGB565ToRGBA8888()

Buffer nnl::texture::ConvertRGB565ToRGBA8888 ( BufferView bitmap565)

Converts an image buffer from RGB565 format to RGBA8888 format.

Parameters
bitmap565A vector containing the image data in RGB565 format.
Returns
A vector containing the converted image data in RGBA8888 format.

◆ ConvertRGBA4444ToRGBA8888()

Buffer nnl::texture::ConvertRGBA4444ToRGBA8888 ( BufferView bitmap4444)

Converts an image buffer from RGBA4444 format to RGBA8888 format.

Parameters
bitmap4444A vector containing the image data in RGBA4444 format.
Returns
A vector containing the converted image data in RGBA8888 format.

◆ ConvertRGBA5551ToRGBA8888()

Buffer nnl::texture::ConvertRGBA5551ToRGBA8888 ( BufferView bitmap5551)

Converts an image buffer from RGBA5551 format to RGBA8888 format.

Parameters
bitmap5551A vector containing the image data in RGBA5551 format.
Returns
A vector containing the converted image data in RGBA8888 format.

◆ ConvertRGBA8888ToRGB565()

Buffer nnl::texture::ConvertRGBA8888ToRGB565 ( BufferView bitmap8888)

Converts an image buffer from RGBA8888 format to RGB565 format.

Parameters
bitmap8888A vector containing the image data in RGBA8888 format.
Returns
A vector containing the converted image data in RGB565 format.

◆ ConvertRGBA8888ToRGBA4444()

Buffer nnl::texture::ConvertRGBA8888ToRGBA4444 ( BufferView bitmap8888)

Converts an image buffer from RGBA8888 format to RGBA4444 format.

Parameters
bitmap8888A vector containing the image data in RGBA8888 format.
Returns
A vector containing the converted image data in RGBA4444 format.

◆ ConvertRGBA8888ToRGBA5551()

Buffer nnl::texture::ConvertRGBA8888ToRGBA5551 ( BufferView bitmap8888)

Converts an image buffer from RGBA8888 format to RGBA5551 format.

Parameters
bitmap8888A vector containing the image data in RGBA8888 format.
Returns
A vector containing the converted image data in RGBA5551 format.

◆ DealignBufferWidth()

Buffer nnl::texture::DealignBufferWidth ( BufferView image_buffer,
unsigned int width,
unsigned int height,
unsigned int bpp,
unsigned int buffer_width )

Removes padding from an aligned image buffer.

This function takes an image buffer that has been aligned to a certain buffer width and removes the extra padding.

Parameters
image_bufferA vector containing the aligned image buffer.
widthThe actual width of the image in pixels.
heightThe height of the image in pixels.
bppThe number of bytes per pixel. 0 for less than a byte.
buffer_widthThe width of the buffer in pixels.
Returns
A vector containing the de-aligned buffer data.
See also
nnl::texture::AlignBufferWidthTo16

◆ DeindexClut8ToRGBA8888()

Buffer nnl::texture::DeindexClut8ToRGBA8888 ( BufferView indexed_image,
BufferView palette )

Converts an 8-bit indexed image buffer to an RGBA8888 buffer.

This function takes an 8-bit indexed image and applies the provided RGBA8888 color palette to convert it into a standard RGBA8888 format. Each byte in the indexed image is replaced with its corresponding color from the palette, resulting in a simple RGBA8888 image.

Parameters
indexed_imageA vector containing the 8-bit indexed image data.
paletteA vector containing the RGBA8888 color palette.
Returns
A vector containing the converted image data in RGBA8888 format.

◆ GenerateConvertParam() [1/2]

ConvertParam nnl::texture::GenerateConvertParam ( const Texture & texture)

Generates conversion parameters from a given texture.

This function attempts to create a ConvertParam object that would result in a similar in-game texture when converting from a simplified representation back to the in-game format.

Parameters
textureThe source texture from which to generate conversion parameters.
Returns
A ConvertParam object.
See also
nnl::texture::Convert

◆ GenerateConvertParam() [2/2]

std::vector< ConvertParam > nnl::texture::GenerateConvertParam ( const TextureContainer & texture_container)

Generates conversion parameters from a given texture container.

This function attempts to create a vector of ConvertParam objects that would result in similar in-game textures when converting from a simplified texture representation back to the in-game format.

Parameters
texture_containerThe source container holding the textures from which to generate conversion parameters.
Returns
A vector of ConvertParam objects.
See also
nnl::texture::Convert

◆ GeneratePaletteMedian()

std::vector< SPixel > nnl::texture::GeneratePaletteMedian ( const STexture & source_image,
std::size_t num_colors = 256 )

Creates a color palette using the median cut algorithm.

Parameters
source_imageThe source texture from which to generate the color palette.
num_colorsThe maximum number of colors in the generated palette.
Returns
The generated color palette.

◆ GeneratePaletteNaive()

std::vector< SPixel > nnl::texture::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.

Parameters
source_imageThe source texture from which to generate the color palette.
num_colorsThe maximum number of colors in the generated palette.
Returns
The generated color palette.
See also
nnl::texture::GeneratePaletteMedian

◆ QuickTexHash()

u32 nnl::texture::QuickTexHash ( BufferView data)

Computes a quick hash for a texture.

It can generate a part of a hash that is used by PPSSPP for texture caching and replacement.

Parameters
dataThe data to be hashed.
Returns
A 32-bit unsigned integer representing the computed hash value of the data.

◆ SwizzleFromMem()

Buffer nnl::texture::SwizzleFromMem ( Buffer & texptr,
u32 bufw,
u32 height,
u32 bytes_per_pixel )

Swizzles texture data.

This function takes linear texture data and reorders it to make it more adapted to the way the GE reads it. This is only applicable to textures with buffer width bigger than 16 bytes.

Parameters
texptrA vector containing texture data.
bufwThe buffer width of the texture in pixels
heightThe height of the texture in pixels
bytes_per_pixelThe number of bytes used to represent each pixel. 0 for less than a byte.
Returns
A vector containing swizzled texture data.

◆ UnswizzleFromMem()

Buffer nnl::texture::UnswizzleFromMem ( BufferView texptr,
u32 bufw,
u32 height,
u32 bytes_per_pixel )

Unswizzles texture data.

This function takes texture data that was reordered for more efficient use by the GE and converts it back to a linear format.

Parameters
texptrA vector containing the swizzled texture data.
bufwThe buffer width of the texture in pixels
heightThe height of the texture in pixels
bytes_per_pixelThe number of bytes used to represent each pixel. 0 for less than a byte.
Returns
A vector containing the unswizzled texture data in linear format.