FileTakeScreenshot - Showing screenshot back to player

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Message
Author
User avatar
Kinmoku
Miko-Class Veteran
Posts: 509
Joined: Mon Aug 11, 2014 9:39 am
Completed: One Night Stand
Projects: Love IRL, Memories
Tumblr: gamesbykinmoku
itch: kinmoku
Location: Germany
Contact:

Re: FileTakeScreenshot - Showing screenshot back to player

#16 Post by Kinmoku » Thu Apr 23, 2020 3:39 am

qirien wrote:
Wed Apr 22, 2020 1:57 pm
Ugh... you're right. It works fine at the default window size, but in full screen it doesn't work at all...
BUT, I think once again transforms will be our friend! I changed the thumbnail transform and added another one for full screen:

Code: Select all

    # A thumbnail version of a full screen image
    transform thumbnail:
        #zoom 0.22 #doesn't work if full screen
        size (282,159)

    # Display something the size of our screen
    transform full_screen:
        size (1280,720)  #Change to whatever the resolution of your game is
When we display the images, use "at full_screen" like this:

Code: Select all

screen show_photo(photo):
    imagebutton:
        idle photo
        hover photo
        action Hide("show_photo", irisin)
        at full_screen
Even though when you run at full screen it's larger than 1280x720, Ren'Py still considers whatever resolution your game is at to be "full screen". So you can tell it to use absolute pixel sizes and it will just scale them up if people are running it at a higher resolution.
Awesome! :D I guess I've been worried about players scaling the window to whatever size they want, but maybe I'll look into locking it to either Window or Fullscreen. Thanks!

User avatar
qirien
Miko-Class Veteran
Posts: 507
Joined: Thu Jul 31, 2003 10:06 pm
Organization: Metasepia Games
Deviantart: qirien
Github: qirien
itch: qirien
Location: New Mexico, USA
Contact:

Re: [SOLVED] FileTakeScreenshot - Showing screenshot back to player

#17 Post by qirien » Thu Apr 23, 2020 11:05 am

OK, this code should work even if they switch back and forth between window and fullscreen, but try it for yourself. :-)
Finished games:
Image
Image
Image
In progress: Our Personal Space 2: Space to Grow

User avatar
Kinmoku
Miko-Class Veteran
Posts: 509
Joined: Mon Aug 11, 2014 9:39 am
Completed: One Night Stand
Projects: Love IRL, Memories
Tumblr: gamesbykinmoku
itch: kinmoku
Location: Germany
Contact:

Re: [SOLVED] FileTakeScreenshot - Showing screenshot back to player

#18 Post by Kinmoku » Tue May 12, 2020 6:08 am

qirien wrote:
Thu Apr 23, 2020 11:05 am
OK, this code should work even if they switch back and forth between window and fullscreen, but try it for yourself. :-)
I'm back! I tried it but, whilst it works for displaying, I can't get it to work on capturing the screenshot itself. No matter the size of the window, it always saves out a screenshot of the window at its current size, not 100% resolution as I want :(

I planned to lock the game between window and fullscreen, but even fullscreen is different case by case. Also, my window is 1920x1080 - It's quite big for older computers so I understand if players would want to scale the window down. Locking it doesn't seem like a good idea.

I'm thinking of sadly dropping the drawing feature.

User avatar
qirien
Miko-Class Veteran
Posts: 507
Joined: Thu Jul 31, 2003 10:06 pm
Organization: Metasepia Games
Deviantart: qirien
Github: qirien
itch: qirien
Location: New Mexico, USA
Contact:

Re: FileTakeScreenshot - Showing screenshot back to player

#19 Post by qirien » Tue May 12, 2020 11:09 am

Nooo! It's such a cool feature; I'd love for you to get it working! :-)

The way I showed doesn't change the resolution of the screenshot, just the resolution the screenshot displays at.

If you really want to change the resolution the screenshot is taken at, I think you can do it with renpy.take_screenshot and renpy.game.interface.get_screenshot(). This is the method the cell phone emulator I linked to previously uses. These functions are intended to be used with saved game screenshots, so you have to write the screenshot out to disk manually afterwards, but should work for this as well.

Code: Select all

            renpy.take_screenshot((1280,720)) # Full screen, but use whatever resolution you want            
            photo = renpy.game.interface.get_screenshot()
            photoname = str(persistent.sv) # They use a persistent variable to increment a screenshot counter by 1 each time, but you could name it something else
            persistent.sv += 1
            photodir = config.basedir + "/game/photos/"
            if(os.path.isdir(photodir) == False):
                os.mkdir(photodir)
            f = open(photodir + photoname + ".png", "wb") # You can also use .jpg to save space
            f.write(photo)
            f.close()
Finished games:
Image
Image
Image
In progress: Our Personal Space 2: Space to Grow

Post Reply

Who is online

Users browsing this forum: Ace94, Google [Bot]