File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -255,6 +255,39 @@ var TextureManager = new Class({
255255 }
256256 } ,
257257
258+ getBase64 : function ( key , frame )
259+ {
260+ var data = '' ;
261+
262+ var textureFrame = this . getFrame ( key , frame ) ;
263+
264+ if ( textureFrame )
265+ {
266+ var cd = textureFrame . canvasData ;
267+
268+ var canvas = CanvasPool . create2D ( this , cd . width , cd . height ) ;
269+ var ctx = canvas . getContext ( '2d' ) ;
270+
271+ ctx . drawImage (
272+ textureFrame . source . image ,
273+ cd . x ,
274+ cd . y ,
275+ cd . width ,
276+ cd . height ,
277+ 0 ,
278+ 0 ,
279+ cd . width ,
280+ cd . height
281+ ) ;
282+
283+ data = canvas . toDataURL ( 'image/png' ) . replace ( / ^ d a t a : i m a g e \/ ( p n g | j p g ) ; b a s e 6 4 , / , '' ) ;
284+
285+ CanvasPool . remove ( canvas ) ;
286+ }
287+
288+ return data ;
289+ } ,
290+
258291 /**
259292 * Adds a new Texture to the Texture Manager created from the given Image element.
260293 *
You can’t perform that action at this time.
0 commit comments