// Encode pixels and verify the PNG structure. function encodeAndVerify(pixels, format, options, expectedColorType) { var encoder = Cc[ "@mozilla.org/image/encoder;2?type=image/png"
].createInstance(Ci.imgIEncoder);
encoder.initFromData(
pixels,
pixels.length,
WIDTH,
HEIGHT,
strideForFormat(format),
format,
options, null
);
var bytes = getPngBytes(encoder);
verifyPngSignature(bytes); Assert.equal(getPngBitDepth(bytes), 16, "bit depth should be 16"); Assert.equal(getPngColorType(bytes), expectedColorType, "color type"); return bytes;
}
// Encode, decode, and verify the decoded image dimensions. function encodeDecodeVerify(pixels, format) { var encoder = Cc[ "@mozilla.org/image/encoder;2?type=image/png"
].createInstance(Ci.imgIEncoder);
encoder.initFromData(
pixels,
pixels.length,
WIDTH,
HEIGHT,
strideForFormat(format),
format, "", null
);
var pngBytes = getPngBytes(encoder); var imgTools = Cc["@mozilla.org/image/tools;1"].getService(Ci.imgITools); var container = imgTools.decodeImageFromArrayBuffer( new Uint8Array(pngBytes).buffer, "image/png"
); Assert.equal(container.width, WIDTH, "decoded width"); Assert.equal(container.height, HEIGHT, "decoded height");
}
function test_cicp_chunk() {
dump("test_cicp_chunk\n"); var encoder = Cc[ "@mozilla.org/image/encoder;2?type=image/png"
].createInstance(Ci.imgIEncoder);
var bytes = getPngBytes(encoder);
verifyPngSignature(bytes);
// Find the cICP chunk. var cicpOffset = findPngChunk(bytes, "cICP"); Assert.notEqual(cicpOffset, -1, "cICP chunk should be present");
// cICP chunk is 4 bytes: primaries, transfer, matrix, full_range Assert.equal(bytes[cicpOffset], 9, "primaries should be BT.2020 (9)"); Assert.equal(
bytes[cicpOffset + 1], 16, "transfer should be SMPTE2084/PQ (16)"
); Assert.equal(bytes[cicpOffset + 2], 0, "matrix should be Identity (0)"); Assert.equal(bytes[cicpOffset + 3], 1, "full range should be 1");
}
function test_setColorSpaceInfo_on_all_encoders() {
dump("test_setColorSpaceInfo_on_all_encoders\n"); var types = [ "image/png", "image/jpeg", "image/webp", "image/bmp", "image/vnd.microsoft.icon",
]; for (var type of types) { var encoder = Cc[ "@mozilla.org/image/encoder;2?type=" + type
].createInstance(Ci.imgIEncoder); // Should not throw on any encoder.
encoder.setColorSpaceInfo(
Ci.imgIEncoder.CP_BT709,
Ci.imgIEncoder.TC_SRGB,
Ci.imgIEncoder.MC_IDENTITY, true
);
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.12 Sekunden
(vorverarbeitet am 2026-09-28)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.