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 / [Bug] GetChosenImage

Author
Message
george++
AGK Tool Maker
17
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 12th Sep 2016 05:41
Please, run the code below:

If you select an image, lets say 640x480, then the program will print the size of the image.
and run the code slightly altered:


if you select the same image the program will print 0
I think this is a bug
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 12th Sep 2016 07:48
It's probably something to do with ShowChooseImageScreen being in a separate function to your GetChosenImage() calls in the main loop on the 2nd code block. The result may be local to that function perhaps?
V2 T1 (Mostly)
Phone Tap!
Uzmadesign
george++
AGK Tool Maker
17
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 12th Sep 2016 15:06 Edited at: 12th Sep 2016 15:06
I am afraid that 'GetChosenImage' function deallocates the image resources
Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 13th Sep 2016 12:32
That is as expected. After you have got the image AppGameKit releases its hold on the ID as it has handed it over to you. So when you call GetChosenImage again AppGameKit no longer has a reference to it.
george++
AGK Tool Maker
17
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 15th Sep 2016 07:17
Quote: "After you have got the image AppGameKit releases ..."

Now I am confused.
What should I do if I want to use the image later? Shall I have to copy the image returned by the 'GetChosenImage' function or not?
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 15th Sep 2016 09:10
The way I infer that, GetChosenImage() will only return the image number once, so just assign it to a variable. i.e. MyImage = GetChosenImage() ... then use MyImage as much as you want. Your first example works and is the correct way to use GetChosenImage as confirmed by Paul.
V2 T1 (Mostly)
Phone Tap!
Uzmadesign

Login to post a reply

Server time is: 2024-11-25 02:07:30
Your offset time is: 2024-11-25 02:07:30