Add support for Buffers to utils.loadImage

If the user has preloaded image data in a Buffer, allow that user to use
that data to load into a Fabric.js image.

This is possible because node-canvas supports setting 'src' to a Buffer.
This commit is contained in:
Cedric Wienold 2013-02-15 16:32:07 -08:00 committed by Daniel Beardsley
parent 471dfed3c6
commit 5fc960aa56

View file

@ -77,7 +77,7 @@
callback && callback.call(context, img);
};
var img = new Image();
if (url && url.indexOf('data') === 0) {
if (url && (url instanceof Buffer || url.indexOf('data') === 0)) {
img.src = img._src = url;
callback && callback.call(context, img);
}