pngToData(function callback)

Decoding PNG image to the palette.
@param callback - call function after decoding.
426333
function(callback) {
		
		if(!this.ifLoad) {
			this.stack(this.pngToData, callback);
			return;
		}
		
		this.history.push('png decode');
		
		var that = this;
		
		var png = new this.png_node(this.data);
		png.decode(function (pixels) {
			
			that.width = png.width;
			that.height = png.height;
			that.data = pixels;
			that.bpp = 4;
			callback.call(that);
		});
		
		return;		
	}
573274
public String toJsonP(final String callback, final Object data) {
        synchronized (lock) {
            try {
                return callback + "(" + stringify((JsonNode) mapper.valueToTree(data)) + ");";
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
    }
506326
function(file, $canvas, callback) {
            this.newImage();
            if (!file)
                return;

            var reader = new FileReader();
            reader.onload = function (fileReaderEvent) {
                image.onload = function () { readImageToCanvasOnLoad(this, $canvas, callback); };
                image.src = fileReaderEvent.target.result;      // The URL from FileReader

            };
            reader.readAsDataURL(file);
        }
602759
public void setImage(final GVRImage imageData)
    {
        mImage = imageData;
        if (imageData != null)
            NativeTexture.setImage(getNative(), imageData, imageData.getNative());
        else
            NativeTexture.setImage(getNative(), null, 0);
    }
1141074
function (url, callback) { // TODO (kangax): test callback
      fabric.util.loadImage(url, function(img) {
        this.overlayImage = img;
        callback && callback();
      }, this);
      return this;
    }
53200
@Override
	public final void setCaptureCallback(CaptureCallback callback) {
		if (callback == null)
			throw new NullPointerException("The callback object cannot be null");

		synchronized (state){
			// make sure we are in the right state.
			if (state.isStarted())
				throw new StateException("This frame grabber is already started");

			// create the push source object
			pushSource = new PushSource(this, callback, threadFactory);
		}
	}
592794
function readPNG(file) {
    const deferred = Q.defer();
    const onerror = deferred.reject.bind(deferred);
    const stream = fs.createReadStream(file);
    stream.on("error", onerror);
    pngparse.parseStream(stream, function(err, image) {
        if (err) {
            console.log("Failed to load " + file);
            onerror(err);
            return;
        }
        deferred.resolve(image);
    });
    return deferred.promise;
}
201413
function(callback)
    {
        if (this._limit != null && this.offset >= this._limit)
        {
            return callback(null, null);
        }

        var self = this;
        var _next = function(err)
        {       
            if (err)
            {
                return callback(err);
            }
        
            if (self.pos < self.data.length)
            {
                var itemData = self.data[self.pos];
                self.pos++;
                self.offset++;
                var cls = self.itemCls;
                callback(null, new cls(self.api, itemData, true));
            }
            else
            {
                callback(null, null);
            }
        };
        
        if (this.data == null || this.pos >= this.data.length && this.truncated)
        {
            this.loadNextPage(_next);
        }
        else
        {
            process.nextTick(_next);
        }
    }
734290
function convertInlinePNG(source, dest) {
    if (!/^data\:image\/png/.test(source)) return Promise.reject(new Error('Source is not a PNG data-uri'));

    var base64data = source.split('data:image/png;base64,')[1];
    var buf = new Buffer(base64data, 'base64');

    return fs.writeFile(dest, buf)
    .then(function() {
        if (fs.existsSync(dest)) return;

        throw new Error('Error converting '+source+' into '+dest);
    });
}
182070
function(file, callback, quality) {
		quality = !quality?85:quality;
		
		var data = this.jpeg_encode.encode(this, quality);
		
		var fd =  this.fs.openSync(file, 'w');
		var bf = new Buffer(data);
		
		this.fs.writeSync(fd, bf, 0, bf.length);
		this.fs.closeSync(fd);
		
		if(callback) {
			callback.call(this);
		}
	}
611271
function toDataURL (image, options) {
  var src = '';
  var async, callback;

  options = options || {};

  async = typeof options.callback === 'function';

  callback = async ? options.callback : function (err, data) {
    if (err) {
      throw err;
    }
    return data;
  };

  function _convert (err, img) {
    if (err) {
      return callback(err);
    }
    var result;
    cors(img);
    result = convert(img, options.width, options.height);
    return callback(null, (options.purify ? purify(result) : result));
  }

  if (isImage(image)) {
    src = image.src || '';
  } else if (typeof image === 'string') {
    if (!async) {
      return callback(new Error('the url mode should be called with a callback'));
    }
    src = image;
  } else {
    return callback(new Error('image should be an Image Object or a string'));
  }

  return async ? createImage(src, _convert) : _convert(null, image);
}
1003241
public void addCustomEventCallback(
            final CrawlEvent event,
            final PatternMatchingCallback callback) {
        customCallbacks.computeIfAbsent(event, key -> new ArrayList<>()).add(callback);
    }
456372
function(config,callback){
        spritesmith(config,function(error,result){
            if(error){
                gutil.log("[Error]",new gutil.PluginError(PLUGIN_NAME, error))
            }else{
                if(callback !== undefined){
                    var _resultPosition = result.coordinates;
                    fs.writeFileSync(_outSpriteName,result.image,"binary");
                    fs.move(_outSpriteName,_outSpritePath +"/"+ _outSpriteName,{clobber: true},function(err){
                        if(err){
                            gutil.log(gutil.colors.red("[Error]"),new gutil.PluginError(PLUGIN_NAME, err))
                        }else{
                            gutil.log(gutil.colors.green("[Successful]"),gutil.colors.yellow("[Done]:"+ _outSpriteName +" Create Successful"))
                        }
                    });
                    callback(_resultPosition);
                }else{
                    gutil.log("[Error] Create Sprite callback is required!");
                }
            }
        })
    }
730753
public static BitmapTextureCallback wrapCallback(
            ResourceCache<GVRImage> cache, BitmapTextureCallback callback) {
        return new BitmapTextureCallbackWrapper(cache, callback);
    }
208272
function(callback) {
		
		if(!this.ifLoad) {
			this.history.push('add to stack task: bmpToData');
			this.stack(this.bmpToData, callback);
			return;
		} 
		
		this.history.push('bmp decode');
		
		var fileSize, headerLength, i, magic, offset, b, data, g, r, w, x, y, _ref;
		this.pos = 0;
		this.bpp = 24;
		
		magic = ((function() {
			var _results;
			_results = [];
			for (i = 0; i < 2; i++) {
				_results.push(String.fromCharCode(this.data[this.pos++]));
			}
			return _results;
		}).call(this)).join('');
		
		if (magic !== 'BM') {
			throw 'Invalid BMP file.';
		}
		
		fileSize = this._readUInt32Bmp();
		this.pos += 4;
		offset = this._readUInt32Bmp();
		headerLength = this._readUInt32Bmp();
		this.width = this._readUInt32Bmp();
		this.height = this._readUInt32Bmp();
		this.colorPlaneCount = this._readUInt16Bmp();
		this.bitsPerPixel = this._readUInt16Bmp();
		this.compressionMethod = this._readUInt32Bmp();
		this.rawSize = this._readUInt32Bmp();
		this.hResolution = this._readUInt32Bmp();
		this.vResolution = this._readUInt32Bmp();
		this.paletteColors = this._readUInt32Bmp();
		this.importantColors = this._readUInt32Bmp();


		var Ndata = [];

		for(y = this.height; y > 0; y--) {
			i = 4 * y * this.width;
			
			for (var x = 0; x < this.width; x++) {
				
				b = this.data[this.pos++];
				g = this.data[this.pos++];
				r = this.data[this.pos++];
				
				Ndata[i++] = r;
				Ndata[i++] = g;
				Ndata[i++] = b;
				Ndata[i++] = 255;
			}
			
			if(this.width%2) {
				this.pos++;
			}
			
			if(this.width%4) {
				this.pos++;
				this.pos++;
			}
		}
	
		for(var i=0, null_elems=0; i < Ndata.length; i ++) {
			if(Ndata[i] != null) {
				break;
			}
			null_elems++;
		}
		
		Ndata.splice(0, this.width*4);
		
		this.data = Ndata;
		callback.call(this);
		
		return;
	}
960808
function(path, callback) {
            this.update();
            var out = fs.createWriteStream(path),
                stream = this._element.createPNGStream();
            // Pipe the png stream to the write stream:
            stream.pipe(out);
            if (callback) {
                out.on('close', callback);
            }
            return out;
        }
1155296
function(callback) {
              async.forEachSeries(file.crops || [], function(crop, callback) {
                console.log('RECROPPING');
                var originalFile = '/attachments/' + file._id + '-' + file.name + '.' + crop.left + '.' + crop.top + '.' + crop.width + '.' + crop.height + '.' + file.extension;
                console.log("Cropping " + tempFile + " to " + originalFile);
                return self.uploadfs.copyImageIn(tempFile, originalFile, { crop: crop }, function(err) {
                  if (err) {
                    console.error('WARNING: problem copying image back into uploadfs:');
                    console.error(err);
                    return fileCallback(null);
                  }
                  return callback(null);
                });
              }, callback);
            }