Jump to content

[SOLVED] Screenshot/video_grab from viewport


photo

Recommended Posts

Posted

Hello,

 

I want to take a screenshot but just from one WidgetSpriteViewport, not the whole screen. Ideally, I would also like this screenshot-viewport to run in the background and not be visible on screen at all, is this possible?

 

Thanks,

Taylor

Posted

Hi Taylor,

 

You can use WidgetSpriteViewport::renderImage to render into image and then save it in needed format.

Posted

Hi Maxi, thanks for the tip.

 

I have tried renderImage but unfortunately the saved image is always flipped along the x and y axes. I made the viewport visible to verify the image and everything looks fine there, it's just the image that is saved to disk. I can use Image::rotate to correct part of the problem, but the image is still mirrored along the y-axis which is no good.

 

I can't get Image::flipX or Image::flipY to do anything, do I need to do anything special like saving on a different frame from the Image operations?

 

More important is why the saved Image is flipped on x & y when the WidgetSpriteViewport shows everything looking normal and good. Any ideas?

 

Thanks,

Taylor

Posted

Hi Taylor,

 

Is it possible to check a simple test scene? I've just tried to use renderImage() in objects/gui_02 sample and indeed the image was flipped along Y axis. Adding image.flipY() solved this issue for me:

Image image;

image = new Image();
image.create2D(512,512,"Image::FORMAT_RGB8");

sprite_viewport.renderImage(image);
image.flipY();

image.save("test.png");

Thanks!

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Posted

Ah, yes I have that now, I think the problem I had was that I was saving the image to disk on the same frame as the flip. When I put a simple flag in there to hold saving until the next frame it works fine. Thanks!

×
×
  • Create New...