rename ImageFormat enum items

This commit is contained in:
MihailRis 2025-12-21 19:05:14 +03:00
parent 1940fa7fa4
commit 163a0a8c93
18 changed files with 58 additions and 58 deletions

View file

@ -11,8 +11,8 @@ ImageData::ImageData(ImageFormat format, uint width, uint height)
: format(format), width(width), height(height) {
size_t pixsize;
switch (format) {
case ImageFormat::rgb888: pixsize = 3; break;
case ImageFormat::rgba8888: pixsize = 4; break;
case ImageFormat::RGB888: pixsize = 3; break;
case ImageFormat::RGBA8888: pixsize = 4; break;
default:
throw std::runtime_error("format is not supported");
}
@ -27,8 +27,8 @@ ImageData::ImageData(ImageFormat format, uint width, uint height, const ubyte* d
: format(format), width(width), height(height) {
size_t pixsize;
switch (format) {
case ImageFormat::rgb888: pixsize = 3; break;
case ImageFormat::rgba8888: pixsize = 4; break;
case ImageFormat::RGB888: pixsize = 3; break;
case ImageFormat::RGBA8888: pixsize = 4; break;
default:
throw std::runtime_error("format is not supported");
}
@ -40,9 +40,9 @@ ImageData::~ImageData() = default;
void ImageData::flipX() {
switch (format) {
case ImageFormat::rgb888:
case ImageFormat::rgba8888: {
uint size = (format == ImageFormat::rgba8888) ? 4 : 3;
case ImageFormat::RGB888:
case ImageFormat::RGBA8888: {
uint size = (format == ImageFormat::RGBA8888) ? 4 : 3;
for (uint y = 0; y < height; y++) {
for (uint x = 0; x < width / 2; x++) {
for (uint c = 0; c < size; c++) {
@ -62,9 +62,9 @@ void ImageData::flipX() {
void ImageData::flipY() {
switch (format) {
case ImageFormat::rgb888:
case ImageFormat::rgba8888: {
uint size = (format == ImageFormat::rgba8888) ? 4 : 3;
case ImageFormat::RGB888:
case ImageFormat::RGBA8888: {
uint size = (format == ImageFormat::RGBA8888) ? 4 : 3;
for (uint y = 0; y < height/2; y++) {
for (uint x = 0; x < width; x++) {
for (uint c = 0; c < size; c++) {
@ -87,8 +87,8 @@ void ImageData::blit(const ImageData& image, int x, int y) {
blitMatchingFormat(image, x, y);
return;
}
if (format == ImageFormat::rgba8888 &&
image.format == ImageFormat::rgb888) {
if (format == ImageFormat::RGBA8888 &&
image.format == ImageFormat::RGB888) {
blitRGB_on_RGBA(image, x, y);
return;
}
@ -188,10 +188,10 @@ static void draw_line(ImageData& image, int x1, int y1, int x2, int y2, const gl
void ImageData::drawLine(int x1, int y1, int x2, int y2, const glm::ivec4& color) {
switch (format) {
case ImageFormat::rgb888:
case ImageFormat::RGB888:
draw_line<3>(*this, x1, y1, x2, y2, color);
break;
case ImageFormat::rgba8888:
case ImageFormat::RGBA8888:
draw_line<4>(*this, x1, y1, x2, y2, color);
break;
default:
@ -223,10 +223,10 @@ static void draw_rect(ImageData& image, int dstX, int dstY, int width, int heigh
void ImageData::drawRect(int x, int y, int width, int height, const glm::ivec4& color) {
switch (format) {
case ImageFormat::rgb888:
case ImageFormat::RGB888:
draw_rect<3>(*this, x, y, width, height, color);
break;
case ImageFormat::rgba8888:
case ImageFormat::RGBA8888:
draw_rect<4>(*this, x, y, width, height, color);
break;
default:
@ -260,8 +260,8 @@ void ImageData::blitRGB_on_RGBA(const ImageData& image, int x, int y) {
void ImageData::blitMatchingFormat(const ImageData& image, int x, int y) {
uint comps;
switch (format) {
case ImageFormat::rgb888: comps = 3; break;
case ImageFormat::rgba8888: comps = 4; break;
case ImageFormat::RGB888: comps = 3; break;
case ImageFormat::RGBA8888: comps = 4; break;
default:
throw std::runtime_error("only unsigned byte formats supported");
}
@ -295,8 +295,8 @@ void ImageData::blitMatchingFormat(const ImageData& image, int x, int y) {
void ImageData::extrude(int x, int y, int w, int h) {
uint comps;
switch (format) {
case ImageFormat::rgb888: comps = 3; break;
case ImageFormat::rgba8888: comps = 4; break;
case ImageFormat::RGB888: comps = 3; break;
case ImageFormat::RGBA8888: comps = 4; break;
default:
throw std::runtime_error("only unsigned byte formats supported");
}
@ -431,8 +431,8 @@ static void check_matching(const ImageData& a, const ImageData& b) {
void ImageData::mulColor(const glm::ivec4& color) {
uint comps;
switch (format) {
case ImageFormat::rgb888: comps = 3; break;
case ImageFormat::rgba8888: comps = 4; break;
case ImageFormat::RGB888: comps = 3; break;
case ImageFormat::RGBA8888: comps = 4; break;
default:
throw std::runtime_error("only unsigned byte formats supported");
}
@ -453,8 +453,8 @@ void ImageData::addColor(const ImageData& other, int multiplier) {
uint comps;
switch (format) {
case ImageFormat::rgb888: comps = 3; break;
case ImageFormat::rgba8888: comps = 4; break;
case ImageFormat::RGB888: comps = 3; break;
case ImageFormat::RGBA8888: comps = 4; break;
default:
throw std::runtime_error("only unsigned byte formats supported");
}
@ -473,8 +473,8 @@ void ImageData::addColor(const ImageData& other, int multiplier) {
void ImageData::extend(int newWidth, int newHeight) {
size_t comps;
switch (format) {
case ImageFormat::rgb888: comps = 3; break;
case ImageFormat::rgba8888: comps = 4; break;
case ImageFormat::RGB888: comps = 3; break;
case ImageFormat::RGBA8888: comps = 4; break;
default:
throw std::runtime_error("only unsigned byte formats supported");
}
@ -499,8 +499,8 @@ void ImageData::extend(int newWidth, int newHeight) {
void ImageData::addColor(const glm::ivec4& color, int multiplier) {
uint comps;
switch (format) {
case ImageFormat::rgb888: comps = 3; break;
case ImageFormat::rgba8888: comps = 4; break;
case ImageFormat::RGB888: comps = 3; break;
case ImageFormat::RGBA8888: comps = 4; break;
default:
throw std::runtime_error("only unsigned byte formats supported");
}
@ -521,8 +521,8 @@ void ImageData::mulColor(const ImageData& other) {
uint comps;
switch (format) {
case ImageFormat::rgb888: comps = 3; break;
case ImageFormat::rgba8888: comps = 4; break;
case ImageFormat::RGB888: comps = 3; break;
case ImageFormat::RGBA8888: comps = 4; break;
default:
throw std::runtime_error("only unsigned byte formats supported");
}
@ -541,7 +541,7 @@ void ImageData::mulColor(const ImageData& other) {
std::unique_ptr<ImageData> add_atlas_margins(ImageData* image, int grid_size) {
// RGBA is only supported
assert(image->getFormat() == ImageFormat::rgba8888);
assert(image->getFormat() == ImageFormat::RGBA8888);
assert(image->getWidth() == image->getHeight());
int srcwidth = image->getWidth();