75namespace ImageFormatDetails {
253 return green(format);
433 return alpha(format);
580 return red(format) == -1;
584 const auto a =
alpha(format);
648namespace ImageDimensions {
650[[nodiscard]]
constexpr uint32_t
getMipDim(uint8_t mip, uint16_t dim) {
651 for (
int i = 0; i < mip; i++) {
660 const auto log2 = std::bit_width(width > height ? height : width);
665 return log2 - 2 > 1 ? log2 - 2 : 1;
668 uint8_t maxMipCount = 1;
670 while (width > 0 && height > 0 && width % 4 == 0 && height % 4 == 0) {
676 while (width > 0 && height > 0 && width % 2 == 0 && height % 2 == 0) {
686 if (width == 0 || height == 0) {
689 uint8_t numMipLevels = 1;
691 if (width == 1 && height == 1) {
709namespace ImageFormatDetails {
722 return ((((width + 3) / 4) < 1) ? 1 : ((width + 3) / 4)) * ((((height + 3) / 4) < 1) ? 1 : ((height + 3) / 4)) * sliceCount *
bpp(format) * 2;
726 return width * height * sliceCount * (
bpp(format) / 8);
729[[nodiscard]]
constexpr uint32_t
getDataLength(
ImageFormat format, uint8_t mipCount, uint16_t frameCount, uint8_t faceCount, uint16_t width, uint16_t height, uint16_t sliceCount = 1) {
731 for (
int mip = mipCount - 1; mip >= 0; mip--) {
737[[nodiscard]]
constexpr bool getDataPosition(uint32_t& offset, uint32_t& length,
ImageFormat format, uint8_t mip, uint8_t mipCount, uint16_t frame, uint16_t frameCount, uint8_t face, uint8_t faceCount, uint16_t width, uint16_t height, uint16_t slice = 0, uint16_t sliceCount = 1) {
740 for (
int i = mipCount - 1; i >= 0; i--) {
741 for (
int j = 0; j < frameCount; j++) {
742 for (
int k = 0; k < faceCount; k++) {
743 for (
int l = 0; l < sliceCount; l++) {
745 if (i == mip && j == frame && k == face && l == slice) {
constexpr bool isPowerOf2(std::unsigned_integral auto n)
constexpr uint32_t getMipDim(uint8_t mip, uint16_t dim)
constexpr uint8_t getActualMipCountForDimsOnConsole(uint16_t width, uint16_t height)
constexpr uint8_t getRecommendedMipCountForDims(ImageFormat format, uint16_t width, uint16_t height)
@ CONSOLE_ARGB8888_LINEAR
@ CONSOLE_BGRX8888_LINEAR
@ CONSOLE_RGBA8888_LINEAR
@ CONSOLE_ABGR8888_LINEAR
@ CONSOLE_BGRX5551_LINEAR
@ CONSOLE_BGRA8888_LINEAR
@ CONSOLE_RGBA16161616_LINEAR