Export only part of a screen as png

  • I have a game where you can draw pixels on the screen, like a simple pixel paint program. I want to make it so the player can export their created artwork.

    A couple of possible solutions I can think of:

    * Export the image using browser invoke download and use base64 image data. The problem with this is I don't know how to convert pixels (or pixel data, could be an array representing pixels) on the screen to base64 data.

    * Capture a snapshot. However the problem with this is I think the image size ratio would have to match the game viewport, because you can only take a screenshot of the entire viewport :(

    Any ideas?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You need to resize the canvas size to that area only and snapshot the screen, then resize canvas back to original ... then download your snapshot... however you might want that drawing area to be either in middle... or towards the left side of screen. or upper left.

    Edited:

    You can read this tutorial i made quickly or download this example for C3 from here and open it in the C3 editor here

  • This is great! Thank you! I only wish it would work with scale outer, but I may just have to make my project letterbox.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)