oxjs/tests/png.html

61 lines
2.5 KiB
HTML
Raw Normal View History

2010-01-07 20:21:07 +00:00
<!DOCTYPE html>
<html>
<head>
<title>Ox.js PNG Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<style>
div {
font-family: Consolas;
font-size: 12px;
}
</style>
2011-04-25 12:14:03 +00:00
<script type="text/javascript" src="../build/js/Ox.js"></script>
2010-01-07 20:21:07 +00:00
<script>
2011-02-09 17:56:35 +00:00
$(function() {
var $body = $('body'),
src = 'v78.png'
//src = 'http://khm0.google.com/kh/v=46&x=0&y=0&z=0',
//src = 'http://www.google.com/intl/en_ALL/images/logo.gif',
//src = 'http://www.google.com/favicon.ico',
//src = 'http://images.apple.com/global/nav/images/globalnavbg.png',
//src = 'http://a1.twimg.com/a/1257210731/images/logo.png',
//src = 'http://l.yimg.com/g/images/logo_home.png',
//src = 'http://www.libpng.org/pub/png/img_png/png-9passes.png'
//src = 'http://www.libpng.org/pub/png/img_png/libpng-88x31.png'
//str = '¥€$',
str = 'H€₤₤O ₩OR₤D';
$('<img/>')
.attr({
src: src
})
.load(function() {
var that = this;
Ox.print('encoding');
$('<img/>')
2010-01-07 20:21:07 +00:00
.attr({
2011-02-09 17:56:35 +00:00
src: Ox.encodePNG(that, str)
2010-01-07 20:21:07 +00:00
})
.load(function() {
2011-02-09 17:56:35 +00:00
Ox.print('decoding');
$('<div/>')
.html('[decoding original, should throw an error] ' + (function() {
var ret;
try {
ret = Ox.decodePNG(that);
ret = '[' + ret.length + ' bytes] ' + Ox.encodeHTML(ret);
} catch (e) {
ret = e.toString()
}
return ret;
}()) + '<br/>[decoding encoded, should return a string] ' + Ox.encodeHTML(Ox.decodePNG(this)))
.prependTo($body);
})
.appendTo($body);
2010-01-07 20:21:07 +00:00
});
2011-02-09 17:56:35 +00:00
});
2010-01-07 20:21:07 +00:00
</script>
</head>
<body></body>
2011-04-25 12:14:03 +00:00
</html>