75namespace ImageFormatDetails {
253 return green(format);
433 return alpha(format);
580 return red(format) == -1;
584 const auto a =
alpha(format);
626namespace ImageDimensions {
628[[nodiscard]]
constexpr uint32_t
getMipDim(uint8_t mip, uint16_t dim) {
629 for (
int i = 0; i < mip; i++) {
638 const auto log2 = std::bit_width(width > height ? height : width);
643 return log2 - 2 > 1 ? log2 - 2 : 1;
646 uint8_t maxMipCount = 1;
648 while (width > 0 && height > 0 && width % 4 == 0 && height % 4 == 0) {
654 while (width > 0 && height > 0 && width % 2 == 0 && height % 2 == 0) {
664 if (width == 0 || height == 0) {
667 uint8_t numMipLevels = 1;
669 if (width == 1 && height == 1) {
687namespace ImageFormatDetails {
700 return ((((width + 3) / 4) < 1) ? 1 : ((width + 3) / 4)) * ((((height + 3) / 4) < 1) ? 1 : ((height + 3) / 4)) * sliceCount *
bpp(format) * 2;
704 return width * height * sliceCount * (
bpp(format) / 8);
707[[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) {
709 for (
int mip = mipCount - 1; mip >= 0; mip--) {
715[[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) {
718 for (
int i = mipCount - 1; i >= 0; i--) {
719 for (
int j = 0; j < frameCount; j++) {
720 for (
int k = 0; k < faceCount; k++) {
721 for (
int l = 0; l < sliceCount; l++) {
723 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