ReadPixel for layers?

Maybe by using extract from PixiJS we could. I don’t have time for now to implement it in the extension.

The raw idea is:

  • Get the PixiJS container of a layer, this get all the instances living on a layer.
// "" is the "Base Layer" in GDevelop.
// you can replace it by a layer name like "background".
runtimeScene._layers.items[""]._renderer._pixiContainer
  • Then extract an image of the PixiJS container by calling the PixiJS renderer and their methods, here extract.
runtimeScene.getRenderer().getPIXIRenderer().extract.image()

So, to generate an image of the base layer in base64:

runtimeScene.getRenderer().getPIXIRenderer().extract.image(runtimeScene._layers.items[""]._renderer._pixiContainer)

A result of it with the platformer example:

I don’t have the time to code this in the extension, but in theory it’s possible.

2 Likes