mirror of
https://github.com/gbdev/rgbds.git
synced 2026-09-16 02:37:06 +00:00
Halt processing when any ambiguous-transparency colors exist (#2093)
This commit is contained in:
+12
-3
@@ -218,6 +218,13 @@ struct Image {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (size_t nbAmbiguousColors = ambiguous.size(); nbAmbiguousColors > 0) {
|
||||
fatal(
|
||||
"Image contains %zu ambiguous color%s (neither transparent nor opaque)",
|
||||
nbAmbiguousColors,
|
||||
nbAmbiguousColors == 1 ? "" : "s"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class TilesVisitor {
|
||||
@@ -1056,12 +1063,14 @@ void process() {
|
||||
for (auto tile : image.visitAsTiles()) {
|
||||
AttrmapEntry &attrs = attrmap.emplace_back();
|
||||
|
||||
// Count the unique non-transparent colors for packing
|
||||
// Count the unique opaque colors for packing
|
||||
std::unordered_set<uint16_t> tileColors;
|
||||
for (uint32_t y = 0; y < 8; ++y) {
|
||||
for (uint32_t x = 0; x < 8; ++x) {
|
||||
if (Rgba color = tile.pixel(x, y);
|
||||
color.isOpaque() || !options.hasTransparentPixels) {
|
||||
Rgba color = tile.pixel(x, y);
|
||||
// Ambiguous colors should not be in `tileColors`
|
||||
assume(color.isOpaque() != color.isTransparent());
|
||||
if (color.isOpaque() || !options.hasTransparentPixels) {
|
||||
tileColors.insert(color.cgbColor());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
error: Color #ff800080 is neither transparent (alpha < 16) nor opaque (alpha >= 240) (first seen at (0, 8))
|
||||
Conversion aborted after 1 error
|
||||
FATAL: Image contains 1 ambiguous color (neither transparent nor opaque)
|
||||
Conversion aborted after 2 errors
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
error: Color #ff000080 is neither transparent (alpha < 16) nor opaque (alpha >= 240) (first seen at (0, 0))
|
||||
error: Color #0000ff80 is neither transparent (alpha < 16) nor opaque (alpha >= 240) (first seen at (0, 4))
|
||||
FATAL: Image contains 2 ambiguous colors (neither transparent nor opaque)
|
||||
Conversion aborted after 3 errors
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 377 B |
Reference in New Issue
Block a user