mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-09 21:33:43 +00:00
Bug 386651 - Need regression tests for image decoding. rs=stuart. [This is part 1 -- framework and initial tests. More to come.]
This commit is contained in:
parent
8ea12699c3
commit
f69264fe57
@ -5,6 +5,9 @@
|
|||||||
# verify the tests work
|
# verify the tests work
|
||||||
include reftest-sanity/reftest.list
|
include reftest-sanity/reftest.list
|
||||||
|
|
||||||
|
#images
|
||||||
|
include ../../modules/libpr0n/test/reftest/reftest.list
|
||||||
|
|
||||||
# printing
|
# printing
|
||||||
include printing/reftest.list
|
include printing/reftest.list
|
||||||
include pagination/reftest.list
|
include pagination/reftest.list
|
||||||
|
114
modules/libpr0n/test/reftest/img2html.html
Normal file
114
modules/libpr0n/test/reftest/img2html.html
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Image-to-html converter</title>
|
||||||
|
<style>
|
||||||
|
#img, #canvas, #span {
|
||||||
|
display: none;
|
||||||
|
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAL0lEQVQ4jWP09vZ+xoAHuLi44JNmYMIrSwQYNWAwGMBCKJ737NlDWxeMGjAYDAAAak4FtfgpsBoAAAAASUVORK5CYII=);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h2>Image-to-html converter</h2>
|
||||||
|
<p>Enter the relative path to an image file, and this will convert it
|
||||||
|
to a pure HTML representation (no images).</p>
|
||||||
|
|
||||||
|
|
||||||
|
<form onsubmit="start_convert(); return false;">
|
||||||
|
Path to image: <input type="text" id="filepath" size="60"><br>
|
||||||
|
<button type='submit'>Convert!</button>
|
||||||
|
<br><br>
|
||||||
|
<img id="img" onload="run_convert();"><canvas id="canvas"></canvas><span id="span"></span><br>
|
||||||
|
(img / canvas/ imghtml)
|
||||||
|
<br><br>
|
||||||
|
Result:<br>
|
||||||
|
<textarea id="textarea" rows="10" cols="80"></textarea>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
|
||||||
|
<script>
|
||||||
|
var img = document.getElementById("img");
|
||||||
|
var canvas = document.getElementById("canvas");
|
||||||
|
var span = document.getElementById("span");
|
||||||
|
var textarea = document.getElementById("textarea");
|
||||||
|
|
||||||
|
function start_convert() {
|
||||||
|
try {
|
||||||
|
|
||||||
|
// Unhide stuff. They're initially hidden because the image shows a
|
||||||
|
// broken-image icon on first page load, and the canvas defaults to a
|
||||||
|
// large empty area.
|
||||||
|
img.style.display = "inline";
|
||||||
|
canvas.style.display = "inline";
|
||||||
|
span.style.display = "inline-block";
|
||||||
|
|
||||||
|
// Clear out any previous values.
|
||||||
|
textarea.value = "(loading image)"
|
||||||
|
span.innerHTML = "";
|
||||||
|
|
||||||
|
// Get the image filename
|
||||||
|
var input = document.getElementById("filepath");
|
||||||
|
img.src = input.value;
|
||||||
|
|
||||||
|
// We're done, let the onload handler do the real work.
|
||||||
|
} catch (e) {
|
||||||
|
alert("Crap, start_convert failed: " + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function run_convert() {
|
||||||
|
try {
|
||||||
|
textarea.value = "(rendering canvas)";
|
||||||
|
|
||||||
|
canvas.width = img.width;
|
||||||
|
canvas.height = img.height;
|
||||||
|
var ctx = canvas.getContext("2d");
|
||||||
|
ctx.clearRect(0, 0, img.width, img.height);
|
||||||
|
ctx.drawImage(img, 0, 0);
|
||||||
|
|
||||||
|
// [r, g, b, a, r, g, b, a, ...]
|
||||||
|
var pixels = ctx.getImageData(0, 0, img.width, img.height).data;
|
||||||
|
|
||||||
|
var imghtml = "<table cellpadding='0' cellspacing='0' width='" +
|
||||||
|
img.width + "' height='" + img.height + "'>\n";
|
||||||
|
|
||||||
|
for (var y = 0; y < img.height; y++) {
|
||||||
|
imghtml += "<tr height='1'>\n";
|
||||||
|
|
||||||
|
textarea.value = "(converting row " + y + ")";
|
||||||
|
|
||||||
|
for (var x = 0; x < img.width; x++) {
|
||||||
|
var p = img.width * y * 4 + x * 4;
|
||||||
|
|
||||||
|
var r = pixels[p + 0];
|
||||||
|
var g = pixels[p + 1];
|
||||||
|
var b = pixels[p + 2];
|
||||||
|
var a = pixels[p + 3];
|
||||||
|
|
||||||
|
var alpha = (a / 255).toString();
|
||||||
|
alpha = alpha.substring(0, 6); // "0.12345678 --> 0.1234"
|
||||||
|
imghtml += " <td width='1' style='background-color: " +
|
||||||
|
"rgba(" +
|
||||||
|
r + "," +
|
||||||
|
g + "," +
|
||||||
|
b + "," +
|
||||||
|
alpha +
|
||||||
|
")'></td>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
imghtml += "</tr>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
imghtml += "</table>\n";
|
||||||
|
|
||||||
|
span.innerHTML = imghtml;
|
||||||
|
textarea.value = "<html><body>\n" + imghtml + "</body></html>";
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
alert("Crap, run_convert failed: " + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
18
modules/libpr0n/test/reftest/pngsuite-zlib/reftest.list
Normal file
18
modules/libpr0n/test/reftest/pngsuite-zlib/reftest.list
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# If you mark a test as failing or random, you MUST file a bug report in
|
||||||
|
# bugzilla and note the bug number as a comment on the line with the
|
||||||
|
# failing test.
|
||||||
|
#
|
||||||
|
# For example:
|
||||||
|
# ...
|
||||||
|
# fails == foo bar # bug 12345
|
||||||
|
#
|
||||||
|
# See /mozilla/layout/tools/reftest/README.txt for more information.
|
||||||
|
|
||||||
|
# z00n2c08 - color, no interlacing, compression level 0 (none)
|
||||||
|
== z00n2c08.png z00n2c08.html
|
||||||
|
# z03n2c08 - color, no interlacing, compression level 3
|
||||||
|
== z03n2c08.png z03n2c08.html
|
||||||
|
# z06n2c08 - color, no interlacing, compression level 6 (default)
|
||||||
|
== z06n2c08.png z06n2c08.html
|
||||||
|
# z09n2c08 - color, no interlacing, compression level 9 (maximum)
|
||||||
|
== z09n2c08.png z09n2c08.html
|
1092
modules/libpr0n/test/reftest/pngsuite-zlib/z00n2c08.html
Normal file
1092
modules/libpr0n/test/reftest/pngsuite-zlib/z00n2c08.html
Normal file
File diff suppressed because it is too large
Load Diff
BIN
modules/libpr0n/test/reftest/pngsuite-zlib/z00n2c08.png
Normal file
BIN
modules/libpr0n/test/reftest/pngsuite-zlib/z00n2c08.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.1 KiB |
1092
modules/libpr0n/test/reftest/pngsuite-zlib/z03n2c08.html
Normal file
1092
modules/libpr0n/test/reftest/pngsuite-zlib/z03n2c08.html
Normal file
File diff suppressed because it is too large
Load Diff
BIN
modules/libpr0n/test/reftest/pngsuite-zlib/z03n2c08.png
Normal file
BIN
modules/libpr0n/test/reftest/pngsuite-zlib/z03n2c08.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 232 B |
1092
modules/libpr0n/test/reftest/pngsuite-zlib/z06n2c08.html
Normal file
1092
modules/libpr0n/test/reftest/pngsuite-zlib/z06n2c08.html
Normal file
File diff suppressed because it is too large
Load Diff
BIN
modules/libpr0n/test/reftest/pngsuite-zlib/z06n2c08.png
Normal file
BIN
modules/libpr0n/test/reftest/pngsuite-zlib/z06n2c08.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 224 B |
1092
modules/libpr0n/test/reftest/pngsuite-zlib/z09n2c08.html
Normal file
1092
modules/libpr0n/test/reftest/pngsuite-zlib/z09n2c08.html
Normal file
File diff suppressed because it is too large
Load Diff
BIN
modules/libpr0n/test/reftest/pngsuite-zlib/z09n2c08.png
Normal file
BIN
modules/libpr0n/test/reftest/pngsuite-zlib/z09n2c08.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 224 B |
20
modules/libpr0n/test/reftest/reftest.list
Normal file
20
modules/libpr0n/test/reftest/reftest.list
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#
|
||||||
|
# "PngSuite, the official set of PNG test images"
|
||||||
|
# Images by Willem van Schaik
|
||||||
|
#
|
||||||
|
# http://www.schaik.com/pngsuite/pngsuite.html
|
||||||
|
# http://www.libpng.org/pub/png/pngsuite.html
|
||||||
|
#
|
||||||
|
|
||||||
|
#include pngsuite-basic-n/reftest.list
|
||||||
|
#include pngsuite-basic-i/reftest.list
|
||||||
|
#include pngsuite-ancillary/reftest.list
|
||||||
|
#include pngsuite-background/reftest.list
|
||||||
|
#include pngsuite-chunkorder/reftest.list
|
||||||
|
#include pngsuite-corrupted/reftest.list
|
||||||
|
#include pngsuite-filtering/reftest.list
|
||||||
|
#include pngsuite-gamma/reftest.list
|
||||||
|
#include pngsuite-oddsizes/reftest.list
|
||||||
|
#include pngsuite-palettes/reftest.list
|
||||||
|
#include pngsuite-transparency/reftest.list
|
||||||
|
include pngsuite-zlib/reftest.list
|
Loading…
Reference in New Issue
Block a user