roman.ligocki Posted December 9, 2020 Posted December 9, 2020 Hey everyone, I am currently working on drone sim, where I would like to capture image and save it to jpg or png. Is there any way how to resolve this problem with C# script? I would be fine to create resolution at least 1080p. 4000x6000 would be ideal. Thanks Roman
rohit.gonsalves Posted December 10, 2020 Posted December 10, 2020 Dear @roman.ligocki, Do you intend following? This is from C++. But you get an Idea about how to do it in C#. I see that you want to capture the image of simulated Virtual camera, don't you? ImagePtr imgGrabScreen = Image::create(); m_textureScreenGrab->getImage(imgGrabScreen); string szFilePath = "..\\screengrabs\\finalsave.png"; imgGrabScreen->save(szFilePath.c_str()); If texture format is not 8-bit then after grabbing the image you may convert the format for saving using imgGrabScreen->convertToFormat(FORMAT_RGBA8 ); Beware that this process is texture image transfer from GPU to System memory. Also if the saving happens in main rendering thread it will pause a thread little as file writing is expensive. You may get image in one thread and save it in another if you want smooth FPS for Rendering thread. I hope this is what you need. Regards, Rohit
roman.ligocki Posted December 10, 2020 Author Posted December 10, 2020 Wow, that was very fast. Thanks. What class is m_textureScreenGrab? With knowledge of this class I may find C# alternative. Thanks
devrom Posted December 10, 2020 Posted December 10, 2020 It is the texture your viewport renders to on the GPU. GetImage transfers the texture to system memory. 1
rohit.gonsalves Posted December 10, 2020 Posted December 10, 2020 1 hour ago, roman.ligocki said: What class is m_textureScreenGrab? With knowledge of this class I may find C# alternative. https://developer.unigine.com/en/docs/2.13/api/library/rendering/class.texture?rlang=cs&words=texture%2Ctextur#highlight Rohit
Recommended Posts