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 / What's the quickest type of image to load?

Author
Message
Santman
12
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 12th Sep 2012 01:22
Has anyone found out what the quickest, decent resolution image file to load is? I'm working with jpg files at 640*320, witha quality of 10, however these are EXTREMELY slow to load on my Galaxy S3, but fly up on the PC. The phone has a quad core processor at 1.8Gh, so not thinking it's the phone TBH....

Was just wondering if anyone had found an image setting/quality that loaded really quickly?
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 12th Sep 2012 09:55
png files are usually much bigger than jpg so your best option is jpg if you do not need transparencies.

you might increase the compression and balance between filesize and quality
MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 12th Sep 2012 10:28
Quote: "Was just wondering if anyone had found an image setting/quality that loaded really quickly? "


^2 [Power of 2 scale] [ie- 32x32 64x64 128x128 256x256 etc...]

An Interesting read...

And for those of us on here with more maths than most of us...

Bear in mind there are times when you need to do a ^2 -1 scaling... can not remember why right now... meaning 65x65 63x63 127x127 255x255 etc...

Hopefully someone might know the reason for this but I suspect Transparency?

Either way I hope this somewhat answers the question a little

bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 12th Sep 2012 11:30
MrValentine, so you are saying that if I have a 60x60 sprite, and I resize it in my paint tool to 64x64 it will load faster in AppGameKit?!!!

When I loaded loading single images vs loading the same set of assets as a spritesheet on iphone 3gs, the spritesheet took almost double the time to load and process!!!!!

if anyone can prove otherwise, I would be very happy to learn!!
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 12th Sep 2012 18:23
non-compressed files are the fastest loading. If you load a jpg then it has to be decoded into an uncompressed bitmap. The same goes for PNG, they have to be decoded. A bmp file is actually the most efficient, as it is already in a format almost identical to the screen output.

You then have to weigh this up against delivering bigger files. In the past I have supplied jpgs and saved them back out to bitmap once the game was first run.

bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 13th Sep 2012 00:01
BatVink so you are saying that AppGameKit loads and processes an 8mb bmp faster than the 300k jpg equivalent?

i think that on ios png are the fastest option.
i have used jpgs for backgrounds and i cut down the app size by many megabytes with no slower loading speeds (i put in timers), at least on ipad & iphone3gs
Santman
12
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 13th Sep 2012 00:10 Edited at: 13th Sep 2012 00:13
Hi guys,

Thaks for the feedback. I considered the compression speed of the image, or rather decompression, however I didn't expect that to pose such a prolem on a Galaxy S3 as it has plenty of decoding power, but I'm not sure how the android system, or AppGameKit for that matter, handles multiple cores. I know DBPro is limited to one core, so thought that AppGameKit may be to and that could be a factor, but we're talking it taking 5-6 times longer on my 1.8Ghz S3 than my 2.4Ghx PC. I tried BMP files to test the compression theory, but oddly they all errored and woulnd't load on the android device(support removed?). So, I then decided to do a range of tests.

For round 1, the image was 640x360 with a virtual resolution of 1280*720. The image was loaded, then set up (sprite created, scaled, positioned on screen). I then halfed the image and file size to see what changed.

Jpeg 640*360 Load = 0.119294 seconds on pc
Set up = 0.000014 seconds on pc
Load = 0.372208 seconds on phone
Set up = 0.000050 seconds on phone

PNG 640*360 Load = 0.126756 seconds on PC
Set up = 0.000013 seconds on PC
Load = 0.353764 seconds on phone
Set up = 0.000050 seconds on phone

Jpeg 320*180 Load = 0.043475 seconds on PC
Set up = 0.000013 seconds on PC
Load = 0.095764 seconds on phone
Set up = 0.000061 seconds on phone

Jpg quality dropped from 12 to 4, copping two thrids off the file size (110k to 40k).
Jpeg 320*180 Load = 0.035487 seconds on PC
Set up = 0.000014 seconds on PC
Load = 0.093891 seconds on phone
Set up = 0.000029 seconds on phone

So, interestingly, the two file types are negligably different in speed, though PNG is slightly faster. Very interestingly, although the loading got notably quicker for a smaller file - suggesting that perhaps the speed of the medium is the factor??? - the smaller image took 20% longer to set up, possibly due to scaling? However, reducing the file size even further then showed little or no notable speed increase - suggesting that perhaps the loading method from SD cards/android is optimized for files around the 100K mark? Perhaps someone more technically gifted can answer that!

Anyway, thanks for all the help guys, it was much appreciated.
Santman
12
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 13th Sep 2012 00:17 Edited at: 13th Sep 2012 00:17
P.S. - I tried scaling them to the factor of 2 as well, but this made almost no difference at all (roughly 0.003 seconds quicker), I assume due to the fact that scaling was then applied anyway.
Digital Awakening
AGK Developer
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 13th Sep 2012 00:33
You did not half the image, the smaller one is only 25% of the bigger image. Multiply the time by 4 and it takes longer to load the smaller image than the bigger one. This is because it takes time to access a file. A larger file is always faster to load. But remember that 1024x1024 is usually max on mobile devices.

PNG should be faster since it is closer to how the image is stored in memory compared to JPG. Not sure but I think images are stored as ^2 in memory. Your 640x360 image is likely to take up 1024x512x32 bytes of memory.


Demo 2 is out! Click the image for more.
Santman
12
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 13th Sep 2012 00:40
Digital Awakening,

Thanks for the correction, I typed half without thinking as I had the width in my head. Either way though, it would appear that the medium it's loading from is predictably the biggest factor. Annoying, as my project needs constant image loading!!!
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 13th Sep 2012 00:42
Quote: "BatVink so you are saying that AppGameKit loads and processes an 8mb bmp faster than the 300k jpg equivalent? "


technically yes,although there are many things wrong with this comparison, and you can't justtake it as face value...

1. An average 8MB bitmap would have to be set at 52% quality for a 300KB jpg (I tested on a simple image, where compression should be less lossy). The result was a terrible jpeg, so this is not a fair test.

2. It depends on how much image usage you have going on. Loading hundreds of images becomes more favourable for bitmaps, having one or two images and the whole question becomes irrelevant.

3. Storage type, storage speed etc play a big part, as does processor speed, nProcessor configuration etc.

4. Decompression algorithms perform differently on different hardware. If you can pass the raw file to a Cuda farm for example, then decoding is a non-isue.

In summary it all depends on many factors. But if the question is simply which type of image is fastest to process, then it is bitmap, as there is virtually no processing to be done.

Rich Dersheimer
AGK Developer
14
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 13th Sep 2012 01:00
Santman, were you testing this through the player? Or testing the compiled files?

I ask because all my big files load quickly through the player (they are transferred from the PC to the device as is) but load more slowly in compiled iOS and MUCH more slowly in compiled Android apk versions. I'm guessing that's because the files must be unpacked before being loaded in the app.

Santman
12
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 13th Sep 2012 01:08
Rich,

At the moment it's through the player and broadcasting to the phone. I'll compile a full build tomorrow and see, but until now I haven't noticed any difference.

As is, I've opted for really small, low quality jpegs for the thumbnails, then load a larger 640*360 jpeg when one is clicked, then substitute it (when they are clicked they are scaled to full screen, hence the need for quick loading!) - I have to say, it's working well so far.
Digital Awakening
AGK Developer
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 15th Sep 2012 10:47
Just so it is not overlooked:
PNG can be smaller than JPG depending on the type of image. They use different compression methods. PNG is lossless and will give you a perfect visual result and is good for images with fewer colors. You can also save 8-bit PNGs with less than 256 colors. 32-bit PNG gives you perfect quality but also takes more space. JPG really shines on photos as the loss in quality is not as visibly noticeable and the size is much smaller.


Demo 2 is out! Click the image for more.

Login to post a reply

Server time is: 2024-04-30 23:50:32
Your offset time is: 2024-04-30 23:50:32