Gui.takeScreenshot
Внешний вид
Takes screenshot of game screen and puts at /screenshots/ip_port folder. Accessible in CEF via screenshots:// scheme. (Will be available in 0.4)
Edit: You can also use http://screenshots/name.png as a fetcher for your screen shot in CEF
Syntax
<syntaxhighlight lang="javascript">gui.takeScreenshot(name, type, quality, compQuality);</syntaxhighlight>
Required Arguments
- name: String
- type: Type of screenshot (0 - JPG, 1 - PNG, 2 - BMP)
- quality: Quality (0 - 100)
- compressionQuality: Compression quality (0 - 100)
Example
<syntaxhighlight lang="javascript"> mp.gui.takeScreenshot("random.png", 1, 100, 0); </syntaxhighlight>
Screenshot to Base64
Use this code in CEF to get your image as base64 code and transfer it to server-side to save for future usage
- URL must be http based format as i mentioned above
<syntaxhighlight lang="javascript"> function toDataUrl(url, callback) {
var xhr = new XMLHttpRequest();
xhr.onload = function() {
var reader = new FileReader();
reader.onloadend = function() {
callback(reader.result);
}
reader.readAsDataURL(xhr.response);
};
xhr.open('GET', url);
xhr.responseType = 'blob';
xhr.send();
}
</syntaxhighlight>
- Usage:
<syntaxhighlight lang="javascript"> toDataUrl(url, (dataURL) => {
alert(`DataURL IS: ${dataURL}`)
}) </syntaxhighlight>