Skip to main content

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) &#123;

   var xhr = new XMLHttpRequest();
   xhr.onload = function() \&#123;
       var reader = new FileReader();
       reader.onloadend = function() \&#123;
           callback(reader.result);
       \&#125;
       reader.readAsDataURL(xhr.response);
   \&#125;;

   xhr.open('GET', url);
   xhr.responseType = 'blob';
   xhr.send();

&#125; ```

  • Usage:

```js toDataUrl(url, (dataURL) =&gt; &#123;

   alert(`DataURL IS: $\&#123;dataURL\&#125;`)

&#125;) ```

See also