#pragma once /** @file Palette.hpp * @brief HDK sdl video header only wrapper pointers to const SDL_PixelFormatDetails & related functions * @note Does note use smartpointers because these are SDL owned constant structs. */ #include #include /** PixelFormatDetails makes getting the details of a pixel format easier. */ namespace hdk::sdl { /** * @brief * */ class PixelFormatDetails : public hdk::grid::PrimitiveWrapper { public: /** Inherit constructors from PrimitiveWrapper */ using hdk::grid::PrimitiveWrapper::PrimitiveWrapper; /*** @see https://wiki.libsdl.org/SDL3/SDL_GetPixelFormatDetails * @returns an PixelFormatDetails instance */ static PixelFormatDetails Get(SDL_PixelFormat format) { return PixelFormatDetails(SDL_GetPixelFormatDetails(format)); } /** @see https://wiki.libsdl.org/SDL3/SDL_GetRGB * @brief Get the RGB values for a pixel value * @param pixel The pixel value to query * @param palette for indexed formats the palette to use, or NULL for non-indexed formats * @param r pointer to Uint8 to store the red component * @param g pointer to Uint8 to store the green component * @param b pointer to Uint8 to store the blue component * @param a pointer to Uint8 to store the alpha component */ void GetRGB(Uint32 pixel, SDL_Palette* palette, Uint8* r, Uint8* g, Uint8* b, Uint8* a) const { SDL_GetRGB(pixel, *this, palette, r, g, b, a); } /** @see https://wiki.libsdl.org/SDL3/SDL_GetRGBA * @brief Get the RGBA values for a pixel value * @param pixel The pixel value to query * @param palette for indexed formats the palette to use, or NULL for non-indexed formats * @param r pointer to Uint8 to store the red component * @param g pointer to Uint8 to store the green component * @param b pointer to Uint8 to store the blue component * @param a pointer to Uint8 to store the alpha component */ void GetRGBA(Uint32 pixel, SDL_Palette* palette, Uint8* r, Uint8* g, Uint8* b, Uint8* a) const { SDL_GetRGBA(pixel, *this, palette, r, g, b, a); } /** @see https://wiki.libsdl.org/SDL3/SDL_MapRGB * @brief Map RGB values to a pixel value for the pixel format * @param palette for indexed formats the palette to use, or NULL for non-indexed formats * @param r The red component of the color * @param g The green component of the color * @param b The blue component of the color * @return The pixel value corresponding to the given RGB values for the pixel format */ Uint32 MapRGB(SDL_Palette* palette, Uint8 r, Uint8 g, Uint8 b) const { return SDL_MapRGB(*this, palette, r, g, b); } /** @see https://wiki.libsdl.org/SDL3/SDL_MapRGBA * @brief Map RGBA values to a pixel value for the pixel format * @param palette for indexed formats the palette to use, or NULL for non-indexed formats * @param r The red component of the color * @param g The green component of the color * @param b The blue component of the color * @param a The alpha component of the color * @return The pixel value corresponding to the given RGBA values for the pixel format */ Uint32 MapRGBA(SDL_Palette* palette, Uint8 r, Uint8 g, Uint8 b, Uint8 a) const { return SDL_MapRGBA(*this, palette, r, g, b, a); } }; }