Validate unit sprite PNG color mode
This commit is contained in:
@@ -208,6 +208,9 @@ function validatePngDimensions(errors, key, path, expected) {
|
|||||||
if (dimensions.width !== expected.width || dimensions.height !== expected.height) {
|
if (dimensions.width !== expected.width || dimensions.height !== expected.height) {
|
||||||
errors.push(`${key}: expected ${expected.width}x${expected.height}, got ${dimensions.width}x${dimensions.height}`);
|
errors.push(`${key}: expected ${expected.width}x${expected.height}, got ${dimensions.width}x${dimensions.height}`);
|
||||||
}
|
}
|
||||||
|
if (dimensions.bitDepth !== 8 || dimensions.colorType !== 6) {
|
||||||
|
errors.push(`${key}: expected 8-bit RGBA PNG color type 6, got bitDepth=${dimensions.bitDepth} colorType=${dimensions.colorType}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function readPngDimensions(path) {
|
function readPngDimensions(path) {
|
||||||
@@ -224,6 +227,8 @@ function readPngDimensions(path) {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
width: bytes.readUInt32BE(16),
|
width: bytes.readUInt32BE(16),
|
||||||
height: bytes.readUInt32BE(20)
|
height: bytes.readUInt32BE(20),
|
||||||
|
bitDepth: bytes[24],
|
||||||
|
colorType: bytes[25]
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user