in image forEach, use Ox.nonblockingForEach

This commit is contained in:
rolux 2012-05-23 17:44:02 +02:00
parent 9137607045
commit de30af0656

View file

@ -525,13 +525,15 @@ Ox.load.Image = function(options, callback) {
i <n> Pixel index
callback <f> Callback function (if present, forEach is async)
@*/
that.forEach = function(fn, callback) {
var data = self.data;
Ox._loop(0, data.length, 4, function(i) {
return fn([
data[i], data[i + 1], data[i + 2], data[i + 3]
], getXY(i), i);
}, 10000, callback);
that.forEach = function(iterator, callback) {
var data = self.data,
forEach = callback ? Ox.nonblockingForEach : Ox.forEach;
forEach(Ox.range(0, data.length, 4), function(i) {
return iterator([
data[i], data[i + 1], data[i + 2], data[i + 3]
], getXY(i), i);
}, callback);
}
return that;
};