New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chrome 12 breaks toDataURL() #264

Closed
felixturner opened this Issue Jun 14, 2011 · 5 comments

Comments

Projects
None yet
4 participants
@felixturner
Contributor

felixturner commented Jun 14, 2011

window.open(renderer.domElement.toDataURL()); works in Chrome 11, not in Chrome 12.

No error thrown. Produces a transparent PNG of the correct dimensions. Confirmed issue exists for canvas and WebGL renderers on OS X and Win 7. Not sure if this is an issue with three.js or with Chrome, so posting here first.

Example URL showing issue: http://airtightinteractive.com/demos/js/ruttetra/

  1. Click 'sample image' at top left
  2. Click 'save image' button below.
  3. Get empty PNG.
@alteredq

This comment has been minimized.

Contributor

alteredq commented Jun 14, 2011

Seems like Chrome issue:

http://code.google.com/p/chromium/issues/detail?id=86040

(the example there doesn't use three.js)

For me it didn't work already since quite some time, don't remember when, it may have been when canary switched to 12.

@alteredq

This comment has been minimized.

Contributor

alteredq commented Jun 14, 2011

Hmmm, I just managed to get my example working simply by rendering one frame immediately before calling toDataURL, in the same callback.

Try something like this:

function saveImage() {
          render();
          window.open(_renderer.domElement.toDataURL());
 }
@mrdoob

This comment has been minimized.

Owner

mrdoob commented Jun 14, 2011

You can also try something along these lines:

var new_window = window.open( 'about:blank' );
var image = new_window.document.createElement( 'img' );
image.src = _renderer.domElement.toDataURL();
new_window.document.body.appendChild( image );
@felixturner

This comment has been minimized.

Contributor

felixturner commented Jun 15, 2011

both of those solutions work in my case. Thanks guys!

@AntonioCoelho

This comment has been minimized.

AntonioCoelho commented Mar 22, 2015

Hi do you know, how can i save with 300dpi, for print?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment