@@ -255,8 +255,26 @@ var TextureManager = new Class({
255255 }
256256 } ,
257257
258- getBase64 : function ( key , frame )
258+ /**
259+ * Gets an existing texture frame and converts it into a base64 encoded image and returns the base64 data.
260+ *
261+ * You can also provide the image type and encoder options.
262+ *
263+ * @method Phaser.Textures.TextureManager#getBase64
264+ * @since 3.12.0
265+ *
266+ * @param {string } key - The unique string-based key of the Texture.
267+ * @param {(string|integer) } [frame] - The string-based name, or integer based index, of the Frame to get from the Texture.
268+ * @param {string } [type='image/png'] - [description]
269+ * @param {number } [encoderOptions=0.92] - [description]
270+ *
271+ * @return {string } The base64 encoded data, or an empty string if the texture frame could not be found.
272+ */
273+ getBase64 : function ( key , frame , type , encoderOptions )
259274 {
275+ if ( type === undefined ) { type = 'image/png' ; }
276+ if ( encoderOptions === undefined ) { encoderOptions = 0.92 ; }
277+
260278 var data = '' ;
261279
262280 var textureFrame = this . getFrame ( key , frame ) ;
@@ -280,7 +298,7 @@ var TextureManager = new Class({
280298 cd . height
281299 ) ;
282300
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 , / , '' ) ;
301+ data = canvas . toDataURL ( type , encoderOptions ) ;
284302
285303 CanvasPool . remove ( canvas ) ;
286304 }
0 commit comments