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 would cause an image to load at 1/4 size?

Author
Message
JRNTexas
13
Years of Service
User Offline
Joined: 24th May 2011
Location: Austin, Texas
Posted: 2nd May 2015 19:05
This only happens on Android. It does not happen on my Windows machine. So while I am writing code and testing on my Windows system it responds as expected. But when I run it on an Android system, it responds differently.

I load several images in my app. They load just fine and the image sizes, as loaded, are the same as the actual image resolution, even on Android.

In one subroutine, when I load an image it loads at 1/4 size (1/2 width, 1/2 height).

I am checking the size with getImageWidth(980) and getImageHeight(980) and the image on disk is twice the width and twice the height, consequently 4 times the size of the image that gets loaded.

Has anyone experienced this?
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 2nd May 2015 19:38
hmm, maybe u used SetIntendedDeviceSize?

AGK 108 (B)19 + AppGameKit V2 Beta .. : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
JRNTexas
13
Years of Service
User Offline
Joined: 24th May 2011
Location: Austin, Texas
Posted: 2nd May 2015 19:48
@Markus,

Thanks for the quick response!

I am not using SetIntendedDeviceSize.

But good thought.
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 2nd May 2015 20:13
maybe u load with this image id elsewhere?
can u make an example?

AGK 108 (B)19 + AppGameKit V2 Beta .. : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
IronManhood
9
Years of Service
User Offline
Joined: 6th Feb 2015
Location: US
Posted: 2nd May 2015 23:23
Are the images power of 2?
JRNTexas
13
Years of Service
User Offline
Joined: 24th May 2011
Location: Austin, Texas
Posted: 3rd May 2015 23:12 Edited at: 3rd May 2015 23:16
Thanks guys for all the help. You've put me on the right track. I just can't determine where to go with my limited understanding.

OK...I know what the problem is.

On Android as opposed to Windows, when an image that is to be used as an animated sprite (as opposed to a static sprite) it loads (in anticipation of being used as an animated sprite) at 1/2 width & 1/2 height.

If the image is to be used as a static sprite, it does not load at 1/4 size.

Only on Android (haven't tested on iPad or iPhone) and not on Windows.

So this "feature" has caused me a more than 20 hours of "debugging", writing a "work around" and a lot of frustration.

@IronManhood, I'm sure that this is a power of 2 problem.

I did read the "Development Tips", i.e. the part about "Power of 2" but didn't realize that it would resize my image to a smaller size. From reading the information, it seemed it always made an image larger than the original.


I haven't been able to easily understand the "solution" to a power of 2 situation.

I am simply loading an image, that is to be used as an animated sprite. The images are of different sizes, some as large as 2350 X 510, with 5 "frames" in the image (470 X 510).

In another instance (for example) I have an image that is 3600 X 20
It has 18 "frames" within the image. Each frame is 200 X 20.

What I don't understand is how to load the image, then load it again, as a subimage. I follow the examples but the results are negative. I want to use the "subImage" not as several separate textures but as one image to use within an animated sprite.

Here is an example of my "test" code:


Any tutoring, suggestions, explanations or examples would be greatly appreciated.
JimHawkins
15
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 4th May 2015 11:00
It's unwise to use images > 1024x1024. Some devices will not handle them.

<<It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.>> Dijkstra
JRNTexas
13
Years of Service
User Offline
Joined: 24th May 2011
Location: Austin, Texas
Posted: 4th May 2015 18:53
@JimHawkins, thanks for the advice.

I'm writing an app for hire & it is meant to be run on specific devices and will never be available on the Play Store, etc. So no worries about compatibility issues.

But I would like for it to perform consistently and not have to write "work arounds" to address specific issues.
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 4th May 2015 23:24
about waste hours ...
i agree,
maybe this name is better LoadImageAndDoSomethingElse
i believe this image loading is not made by tgc, its some open source.

AGK 108 (B)19 + AppGameKit V2 Beta .. : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 5th May 2015 11:45
You can use AddSpriteAnimationFrame if your frames don't all fit on one atlas. That way you can keep your image sizes down.

V2 T1 (Mostly)
Uzmadesign
JRNTexas
13
Years of Service
User Offline
Joined: 24th May 2011
Location: Austin, Texas
Posted: 5th May 2015 16:51
@CJB, that's A great suggestion! Thanks.

Login to post a reply

Server time is: 2024-11-25 21:31:34
Your offset time is: 2024-11-25 21:31:34