Skip to content

Commit

Permalink
feat(vtfpp): add function to determine if a given image format can co…
Browse files Browse the repository at this point in the history
…ntain transparency
  • Loading branch information
craftablescience committed Jul 18, 2024
1 parent 77ee22e commit a7fc5b8
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions include/vtfpp/ImageFormats.h
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,30 @@ namespace ImageFormatDetails {
return red(format) > 8 || bpp(format) > 32;
}

[[nodiscard]] constexpr bool transparent(ImageFormat format) {
const auto a = alpha(format);
if (a < 0) {
switch (format) {
using enum ImageFormat;
case DXT1_ONE_BIT_ALPHA:
case ATI2N:
case ATI1N:
case BC7:
case BC6H:
return true;
default:
break;
}
return false;
} else {
return a != 0;
}
}

[[nodiscard]] constexpr bool opaque(ImageFormat format) {
return !transparent(format);
}

[[nodiscard]] constexpr uint32_t getDataLength(ImageFormat format, uint16_t width, uint16_t height, uint16_t sliceCount = 1) {
switch(format) {
using enum ImageFormat;
Expand Down

0 comments on commit a7fc5b8

Please sign in to comment.