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 / Saving image files

Author
Message
george++
AGK Tool Maker
17
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 22nd Aug 2017 09:40 Edited at: 22nd Aug 2017 09:41
Hi guys,
Is it possible to save a portion of a sprite as an image (ex: a .png file) to the hard disk?
If yes, a code snippet will be much appreciated.
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 22nd Aug 2017 10:26 Edited at: 22nd Aug 2017 10:28
Yes.

Check the Image Functions in my signature.
Initially you can use GetSpriteImageID() to get the image ID from the sprite then from my functions, the function you want is CopyImageAreaToImage() which will create an image from a section of another image.
Then use SaveImage() to save it to disc.
george++
AGK Tool Maker
17
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 22nd Aug 2017 10:50
Thank you very much for your help.
george++
AGK Tool Maker
17
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 27th Aug 2017 22:49 Edited at: 27th Aug 2017 22:51
I noticed that in the function
Quote: "CopyImageAreaToImage"
the target image must exist. How can I create the target image?
I have the source image and I want to create new images from the source.
What I have as input it is the rectangle areas that I want to extract. I suppose that I have to create blank images but I don't know how.

[EDIT]: I think the built in function
Quote: "integer CopyImage( fromImage, x, y, width, height ) "
does my job

Login to post a reply

Server time is: 2024-11-24 09:35:30
Your offset time is: 2024-11-24 09:35:30