Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / [SOLVED] SaveImage gives a different resolution png file ?

Author
Message
eejit
7
Years of Service
User Offline
Joined: 25th Mar 2017
Location:
Posted: 10th Sep 2018 14:38
Where am I going wrong here ?

SetWindowSize( 256, 342, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
SetVirtualResolution( 256, 342 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
DrawBox(10, 10, 246, 332, 100, 100, 100, 100, 1)
GetImage(1, 0, 0, 256, 342)
CreateSprite(1, 1)
SetSpriteSize(1, 256, 342)
SetSpritePosition(1, 0, 0)
SaveImage(1,"box.png")

do
Print( ScreenFPS() )
Sync()

loop

I can save this box.png here like so - but the resulting image is 574 x 768, not 256 x 342 in size ?
(It's just a red box with a bit of a gap around the edges, almost full window size)

The author of this post has marked a post as an answer.

Go to answer

blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 10th Sep 2018 22:33 Edited at: 10th Sep 2018 22:33
This works ok for me. Your code will put the box.png in the c:/Users/yourid/BlahBlah directory.
Add this code before you save the box
SetRawWritePath(GetReadPath())

Then your image will be written to your media folder. Make sure there is no box.png in your media folder before hand
Icerion
6
Years of Service
User Offline
Joined: 3rd Aug 2018
Location:
Posted: 10th Sep 2018 23:40
or use : 'SetRawWritePath ( '/' ) to save to the same directory as your EXE.
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 13th Sep 2018 18:29 Edited at: 13th Sep 2018 18:33
This post has been marked by the post author as the answer.
from the GetImage help file:
Quote: "Note that the image produced by this command is not guaranteed to have the same width and height as those given to the command, this is because the image is created from a portion of the screen which has a different size on different devices"


So, perhaps, ResizeImage() before saving, or modify GetImage() width & height to account for virtual resolution/device resolution scaling.

Login to post a reply

Server time is: 2024-11-23 15:00:54
Your offset time is: 2024-11-23 15:00:54