@Evgeni_Popov just tried on mobile and the two numbers i get are: 16384 and 4096, being 4096 the minimum of them,
so mmm then I dont understand why it works with 1920 but not with 2520px of longest side of resolution
You may not have enough GPU RAM for a bigger screenshot at the time you do it because of the other textures used in the scene.
@Evgeni_Popov good point, so to be safe it seems clear that what I should do is that on mobile phones the max should be kept even lower than the minimum of those 2 numbers, to be safe, probably safe to keep it at 1920 for mobiles
This is I think what I need. how are you displaying the imaging in the page after taking the screenshot?
This is just some piece of the code.
BABYLON.Tools.CreateScreenshotUsingRenderTarget(engine, camera, { width: 800, height: 450 }, function (data) {
document.getElementById("scrshotdiv").innerHTML = '<img src="' + data + '" style="width:100%;">';
});
That worked in a vuetify component using the id. Perfect. But I need to store the images in a folder.
You get image as base64 string returned from the CreateScreenshotUsingRenderTarget method. You can send that to Node server for example, and write it to a disk as a file utilizing native fs
module.
Server side code would look something like this
const fs = require('fs');
const base64String = 'your_base64_encoded_string_here';
// Removing the "data:image/png;base64," part if it's present
const base64Image = base64String.split(';base64,').pop();
// Write the image to a file
fs.writeFile('path/to/your/folder/image.png', base64Image, {encoding: 'base64'}, function(err) {
console.log('File created');
});
Sorry, didnât mean to highjack this thread. I did start another thread about this and using the node serverâŚ.but it is not working very well.
I am getting some stability issues with the server.