fix a bug in image.encode

This commit is contained in:
rolux 2012-05-24 08:56:42 +02:00
parent dc1f486967
commit 36d0162b8b

View file

@ -358,11 +358,11 @@ Ox.load.Image = function(options, callback) {
} }
str = str.substr(0, Math.ceil(cap)); str = str.substr(0, Math.ceil(cap));
// Create an array of bit values // Create an array of bit values
bin = Ox.flatten(Ox.map(str, function(chr) { bin = Ox.flatten(Ox.map(str.split(''), function(chr) {
return Ox.range(8).map(function(i) { return Ox.range(8).map(function(i) {
return chr.charCodeAt(0) >> 7 - i & 1; return chr.charCodeAt(0) >> 7 - i & 1;
}); });
}).split(',')); }));
b = 0; b = 0;
that.forEach(function(rgba, xy, index) { that.forEach(function(rgba, xy, index) {
// If alpha is not 255, the RGB values may not be preserved // If alpha is not 255, the RGB values may not be preserved
@ -529,7 +529,7 @@ Ox.load.Image = function(options, callback) {
var data = self.data, var data = self.data,
forEach = callback ? Ox.nonblockingForEach : Ox.forEach; forEach = callback ? Ox.nonblockingForEach : Ox.forEach;
forEach(Ox.range(0, data.length, 4), function(i) { forEach(Ox.range(0, data.length, 4), function(i) {
return iterator([ iterator([
data[i], data[i + 1], data[i + 2], data[i + 3] data[i], data[i + 1], data[i + 2], data[i + 3]
], getXY(i), i); ], getXY(i), i);
}, callback); }, callback);