-
-
Save haruair/6110045 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sshow_load_img1(src, loaded) { | |
/* NOT possible to document.createElement('canvas').getContext('2D').drawImage( img or img.get() ) */ | |
var img = $("<img />").attr('src', src ) | |
.load(function() { | |
if (!this.complete || typeof this.naturalWidth == "undefined" || this.naturalWidth == 0) { | |
alert('broken image!'); | |
} else { | |
if (loaded) loaded(img); | |
} | |
}); | |
} | |
function sshow_load_img2(src, loaded) { | |
/* Possible to document.createElement('canvas').getContext('2D').drawImage( img ) */ | |
var img = new Image(); | |
img.onload = function() { | |
if ( loaded ) loaded (img); | |
}; | |
img.src = src; | |
} | |
function sshow_load_img3(src, loaded) { | |
var img = $("<img />").attr('src', src) | |
.load(function() { | |
var img = new Image(); | |
img.src = src; | |
if (loaded) loaded(img); | |
}); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment