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 / Best way to resize an image without rendering it to the screen?

Author
Message
Polaraul
9
Years of Service
User Offline
Joined: 13th Dec 2014
Location:
Posted: 22nd Jan 2015 00:56
Is there a command to resize an image without assigning it to a sprite?
paulrobson
9
Years of Service
User Offline
Joined: 22nd Nov 2014
Location: Norfolk, England
Posted: 22nd Jan 2015 09:28
Why would you want to do this ?
Markus
Valued Member
19
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 22nd Jan 2015 10:08 Edited at: 22nd Jan 2015 10:10
not know a command for resize, but should be possible with memblocks.
http://www.appgamekit.com/documentation/Reference/Memblock.htm

AGK 108 (B)19 + AppGameKit V2 Alpha .. : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Polaraul
9
Years of Service
User Offline
Joined: 13th Dec 2014
Location:
Posted: 22nd Jan 2015 10:40
@paulrobson Games and apps have a diverse range of requirements, and this functionality would have saved many lines of code.

@Markus Many thanks, I have considered memblocks, but I was really hoping that the language had this kind of functionality built in. Looks like I will have to code my own solution to this.
BatVink
Moderator
20
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 22nd Jan 2015 11:11
You might be able to use Update() and Render() after creating and resizing your sprite, to get the image without displaying it on the screen.

Quidquid latine dictum sit, altum sonatur
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 22nd Jan 2015 12:32
Could you not add it to an offscreen sprite and resize before moving into the visible zone?

Onwards and sometimes upwards
paulrobson
9
Years of Service
User Offline
Joined: 22nd Nov 2014
Location: Norfolk, England
Posted: 22nd Jan 2015 12:48
@polaraul I take your point, but I think AppGameKit loads in your images into GPU memory and scales and renders it from there.

You could do it with either GetImage() or CreateRenderImage() both of which allow you to create new images by 'drawing' it, so to speak in slightly different ways.
Polaraul
9
Years of Service
User Offline
Joined: 13th Dec 2014
Location:
Posted: 22nd Jan 2015 13:25
Many thanks to all those answered. At the moment I am using a combination of SetSpriteSize and GetImage to resize my image, however, this feels less than robust. The manual states that "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." and sure enough, results vary across resolutions and devices.

Ultimately I need the resized image to be held in a Memblock for further processing. It would be nice if there was an image resize command, or, even a way to access a sprite via a memblock. CreateMemblockFromSprite would be nice
paulrobson
9
Years of Service
User Offline
Joined: 22nd Nov 2014
Location: Norfolk, England
Posted: 22nd Jan 2015 23:06
Did you look at CreateRenderImage() ; this allows you (I think) to set a specific size of the target bitmap.
Polaraul
9
Years of Service
User Offline
Joined: 13th Dec 2014
Location:
Posted: 23rd Jan 2015 12:22
@paulrobson Many thanks Paul. I have looked into this method, and it just seemed to open up another can of worms.

I now have a method of resizing images which seems to work consistent across resolutions and basically just involves manipulating the virtual devicewidth and deviceheight before calling my routine. To me it feels a little cludgy, but will have to do for this project. Hopefully TGC will expand the image commands in future releases.

Login to post a reply

Server time is: 2024-03-28 17:36:28
Your offset time is: 2024-03-28 17:36:28