赞
踩
- //获取指定图片地址的base64值,
- function getBase64Image(url, callback){
- var canvas = document.createElement("CANVAS");
- var ctx = canvas.getContext('2d');
- var img = new Image;
- img.crossOrigin = 'Anonymous';
- img.src = 'res/raw-assets/' + url;//如:'res/raw-assets/' + "public/skin/frame_1.png"
- img.onload = function(){
- canvas.height = img.height;
- canvas.width = img.width;
- ctx.drawImage(img, 0, 0);
- var dataURL = canvas.toDataURL('image/png');
- canvas = null;
- if( callback ) callback(dataURL);
- }
- }
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。