javascript - Canvas.toDataUrl sometimes truncated in Chrome/Firefox -
in html5 version of libgdx game, sometimes canvas.todataurl("image/png")
returns truncated string yielding black image.
canvaselement canvas = ((gwtapplication)gdx.app).getcanvaselement(); string dataurl = canvas.todataurl("image/png"); window.open(dataurl, "_blank", "");
the odd part works. when work ~100kib image expected, , new window opens address bar saying "data:". can send webservice , translate base64 bytes of proper png , osx preview shows fine too.
when doesn't work new window shows black image of correct dimensions, , address bar base64-encoded data in (starting data:image/png;base64,ivborw0kggoaaaan
...), ending in elipsis appears rendered browser ui rather 3 periods in actual data string. data in case ~31kib. when try transcoding via webservice, same black rectangle.
i see happen in both chome , firefox.
any ideas? code canvas contents simple, can't see how can doing wrong. i'm thinking either bug in browsers, or kind of timing issue libgdx , rendering?
this caused libgdx not preserving drawing buffer. libgdx guys kindly fixed in nightly build available.
updating latest build of 1.0-snapshot
, setting below flag works reliably:
@override public gwtapplicationconfiguration getconfig () { if(config == null) { config = new gwtapplicationconfiguration(1280, 960); config.preservedrawingbuffer = true; } return config; }
Comments
Post a Comment