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 / LoadImage Takes Too Much Time

Author
Message
Shokkul
9
Years of Service
User Offline
Joined: 30th Oct 2015
Location:
Posted: 7th May 2016 20:00 Edited at: 7th May 2016 23:23
Hi guys,
I made a game (nearly finished whole thing) about choosing favorite character where it stores the votes in the database and shows it when user wants. The game looks very good thanks to agk and photoshop but I have a major problem. I have nearly 500 images and in total their size is 20 mb. Before the game starts, the game shows disclaimer and it starts to load all the images. On my pc, loading images takes 3 seconds but when I try on my phone it takes nearly 25 seconds. So when I load image when I need instead of all at once, the game gets frozen for 2 second in my phone and tablet, but it takes no time on my pc. I know that pc's hardware is much better than phone, but I need to load 500 images at least in 7-8 second.
What can I do for it? Loading whole thing( I reduced images' size with different applications already) takes 25 seconds, loading images one by one takes 2 seconds after certain time. Is there a fucntion for it? Is it about size or is it about loading too many images? I am really confused.
Thanks.
Qube_
10
Years of Service
User Offline
Joined: 21st Oct 2014
Location: Omnipresent
Posted: 7th May 2016 22:19
You would find it much quicker if you put all your images into an atlas sheet and used LoadSubImages for each required image.
Shokkul
9
Years of Service
User Offline
Joined: 30th Oct 2015
Location:
Posted: 8th May 2016 01:15 Edited at: 8th May 2016 01:15
Hi guys,
After I created this thread I searched a lot about this problem.
Firstly, I compressed 25mb file into 7 mb file(?!) and still It takes 25 seconds to load whole thing. I think the problem is using LoadImage() too much time, takes a lot of memory. There are few relatively similar topics about LoadImage(). Using atlas images suggested in these topics. So maybe it will increase performance. Still any info can help me a lot
Thanks
Qube_
10
Years of Service
User Offline
Joined: 21st Oct 2014
Location: Omnipresent
Posted: 8th May 2016 02:50
@Shokkul - I would happily provide code examples and a detailed explanation on using image atlases and loadsubimage but unfortunately my posts seems to go immediately into a moderator queue. Perhaps a member which doesn't have moderated posts will be able to guide you quicker.
Qube_
10
Years of Service
User Offline
Joined: 21st Oct 2014
Location: Omnipresent
Posted: 8th May 2016 03:40 Edited at: 8th May 2016 03:42
For creating image atlases I use the excellent TexturePacker https://www.codeandweb.com/texturepacker - It has support for AppGameKit but just needs the image coordinates file changed to <filename> subimages.txt

So lets say we create an image atlas called blobSheet.png with blob1.png, blob2.png and blob3.png ( simple 64 x 64 circles in red, green and blue )

Using TexturePacker as our example atlas creator we would end up with an image like :



Our corresponding sub images file would have the following info :

blob1.png:2:2:64:64
blob2.png:2:68:64:64
blob3.png:2:134:64:64

It is ordered in image name, x, y, width, height on the atlas image.

Now our code to use this in AppGameKit would be as simple as :

atlasImage1 = LoadImage( "blobSheet.png" )
atlasBlobRed = LoadSubImage( atlasImage1, "blob1.png" )
atlasBlobGreen = LoadSubImage( atlasImage1, "blob2.png" )
atlasBlobBlue = LoadSubImage( atlasImage1, "blob3.png" )

blobRed = CreateSprite( atlasBlobRed )
blobGreen = CreateSprite( atlasBlobGreen )
blobBlue = CreateSprite( atlasBlobBlue )

Then the usual sprite commands apply as per normal. Hope the above makes sense on how to use the atlas commands. If an example project would help then let me know and I'll whip up one for you.
Shokkul
9
Years of Service
User Offline
Joined: 30th Oct 2015
Location:
Posted: 8th May 2016 10:18
Hello Qube
Thanks you for reply. As you suggested I installed TexturePacker and tried to make atlas image. So I have my atlas image and txt files info about info about coordinates of pictures as you said.
I'll inform you after I try to use it.
thanks again.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 8th May 2016 12:09
Nice intro to Texture Packer, thanks I need to use this for my projects.

Bear in mind that the compression of the file will not help. Once in memory, everything is essentially an uncompressed bitmap. You should consider reducing images sizes (width/height) for mobile as well. Even if the phone is HD, the size of the screen means that your images don't need to be HD to look good. If you are scaling down your images, then consider making them the correct scale from the outset.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Shokkul
9
Years of Service
User Offline
Joined: 30th Oct 2015
Location:
Posted: 9th May 2016 08:45
Thank you so much Qube and BatVink, with TexturePacker and some resize tools, now I can load my game in 5 seconds instead of 25 seconds.
I have 3 4096x4096 atlas image, I was afraid because TexturePacker warns me about some phones cant handle this much resolution but I tried on 10 different phones and it works totally fine. And Texturepacker give you also the txt file and in the txt file all your images' name is still same. So I didnt have to change values and names of my images.
hakan
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 9th May 2016 11:29
You'll have better mobile compatibility if you try to keep your atlas images to 2048x2048 or below.
V2 T1 (Mostly)
Phone Tap!
Uzmadesign

Login to post a reply

Server time is: 2024-11-25 08:38:36
Your offset time is: 2024-11-25 08:38:36