#pragma once #include "BKImage.h" #include "utils/TextureUtils.h" #include #include #include #include namespace BK64 { // A texel format sprites or models use, by the name Torch's texture yaml gives it. struct TexelFormat { const char* name; int bits; TextureType texture; }; const TexelFormat* FindTexelFormat(const std::string& name); // A BKTextureInfo type, by its lowest bit set. const TexelFormat* ModelTextureFormat(uint16_t type); bool IsIndexed(const TexelFormat& format); size_t TlutColors(const TexelFormat& format); size_t TexelBytes(const TexelFormat& format, int width, int height); uint32_t ReadTexel(const TexelFormat& format, const std::vector& texels, size_t i); void WriteTexel(const TexelFormat& format, std::vector& texels, size_t i, uint32_t value); void TexelRgba(const TexelFormat& format, uint32_t value, const std::vector& tlut, uint8_t* out); bool OpaqueTexel(const TexelFormat& format, uint32_t value, const std::vector& tlut); // For CI it also fills the TLUT, from the image's own palette when that fits. std::vector ImageTexels(const TexelFormat& format, const RgbaImage& image, const IndexedImage* source, std::vector& tlut); RgbaImage TexelsImage(const TexelFormat& format, int width, int height, const std::vector& texels, const std::vector& tlut); // CI keeps its TLUT as the palette, I goes gray and IA gray with alpha. A value under 0 is a pixel left clear. std::vector TexelsPng(const TexelFormat& format, const std::vector& values, int width, int height, const std::vector& tlut); std::vector TextureResource(const TexelFormat& format, uint32_t width, uint32_t height, const std::vector& data); // RGBA16, its colors wide and one high. std::vector TlutResource(const std::vector& tlut); // format is null for a type no sprite or model uses. bool ReadTextureResource(const std::vector& resource, const TexelFormat*& format, uint32_t& width, uint32_t& height, std::vector& data); } // namespace BK64