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
```js gui.takeScreenshot(name, type, quality, compQuality); ```
Required Arguments
- name: String
- type: Type of screenshot (0 - JPG, 1 - PNG, 2 - BMP)
- quality: Quality (0 - 100)
- compressionQuality: Compression quality (0 - 100)
Example
```js mp.gui.takeScreenshot("random.png", 1, 100, 0); ```
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
```js 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();
} ```
- Usage:
```js toDataUrl(url, (dataURL) => {
alert(`DataURL IS: $\{dataURL\}`)
}) ```