Pixi.js: WebGL extract giving empty image

Created on 25 Mar 2017  路  5Comments  路  Source: pixijs/pixi.js

I'm trying to use the WebGLExtract class to create screenshots, but am getting a black image instead (of the correct dimensions).

    var sourceCanvas = renderer.extract.canvas();
    var sourceContext = sourceCanvas.getContext('2d');
    var extractCanvas = document.createElement('canvas');
    var extractContext = extractCanvas.getContext('2d');
    var imageData = sourceContext.getImageData(x, y, width, height);

    extractCanvas.width = width;
    extractCanvas.height = height;
    extractContext.putImageData(imageData, 0, 0);
    return extractCanvas.toDataURL();

I've also tried just accessing sourceCanvas.toDataURL() directly, but with the same results. Any chance I've forgotten something obvious?

馃 Question

Most helpful comment

It can happen in some cases, but if you pass your stage there, and it gets imageData just after rendering it - I'm sure it'll work.

renderer.extract.canvas(stage);

And if you are friday-night-drunk and forgot where is your stage

renderer.extract.canvas(renderer._lastObjectRendered);

All 5 comments

It can happen in some cases, but if you pass your stage there, and it gets imageData just after rendering it - I'm sure it'll work.

renderer.extract.canvas(stage);

And if you are friday-night-drunk and forgot where is your stage

renderer.extract.canvas(renderer._lastObjectRendered);

Hey @noffle is this still an issue?

@ivanpopelyshev That did it! Thank you so much. :heart: And thanks @englercj for poking me on this.

@ivanpopelyshev 小锌邪褋懈斜芯 褌械斜械 芯谐褉芯屑薪芯械!

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Darker picture Darker  路  3Comments

finscn picture finscn  路  3Comments

samueller picture samueller  路  3Comments

YuryKuvetski picture YuryKuvetski  路  3Comments

neciszhang picture neciszhang  路  3Comments