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 / Help! Sprites have borders in the AGK Player (Android)

Author
Message
mYsT!C
19
Years of Service
User Offline
Joined: 7th Feb 2005
Location: Germany
Posted: 24th Mar 2013 21:30
I have a big problem while using the AppGameKit Player on my Android device (Galaxy S3, latest player from Play Store).

I created png-files to build an animated sprite.
I used IrfanView to produce my files and setting the transparency.

While my project runs fine on Windows, the sprite has a border on android.

Has anyone an idea what to do?

This is how my images look like:
And this is how it looks on android:
xCept
21
Years of Service
User Offline
Joined: 15th Dec 2002
Location:
Posted: 24th Mar 2013 21:47
This is caused by the default min/mag filters AppGameKit uses when sprites are scaled. After you load the image, you can remove this blurring effect (and the purple border) by calling:

SetImageMinFilter(myImg, 0)
SetImageMagFilter(myImg, 0)

For best results, you should consider creating a PNG with a truly transparent background (alpha channel) at which point the options above will not be necessary.
mYsT!C
19
Years of Service
User Offline
Joined: 7th Feb 2005
Location: Germany
Posted: 24th Mar 2013 21:58 Edited at: 24th Mar 2013 22:23
thank you, with those two commands the boarders disappear!!

But what do you recommend to create png-files with an alpha-channel?


In the help they say that the filter is only active, when textures are bigger than the screen size. My images are 128x128 and my device's screen is certainly bigger. I don't understand the problem
xCept
21
Years of Service
User Offline
Joined: 15th Dec 2002
Location:
Posted: 24th Mar 2013 22:43
The 'mag' filter is applied whenever a sprite is stretched beyond the dimensions of its assigned image. So, if your original texture is 128x128 but you create a sprite and set its size to 256x256, the image itself will be stretched to twice its size. If the mag filter is set to 0 it will be sized to the nearest pixel, whereas the default filter option of 1 creates a more anti-aliased effect to smooth the edges. The nature of AGK's screen handling (e.g., SetVirtualResolution) also means that sprites may be stretched even if you don't explicitly do so yourself. If you set the virtual resolution to 320x480 but run it on a device with 640x960, the sprites will be stretched twice the size automatically.

If you are after a free image editor that supports alpha channels, try Gimp.
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 25th Mar 2013 14:56
Transparent pixels still have a color value assigned to them as they are 32bit pixels, in this case it looks like IrfanView has assigned them the color purple so when linear filtering occurs (creating semi transparent pixels around the edge) you end up with some of this purple bleeding through. You will need to find a program that lets you edit this color so it more closely matches the color of your sprite.
mYsT!C
19
Years of Service
User Offline
Joined: 7th Feb 2005
Location: Germany
Posted: 25th Mar 2013 17:17
Ok, at least I understand the problem. While it looks pretty on my PC, AppGameKit scales the sprites to fit my device's screen.

I used a virtual resolution of 640x480. My S3 has 1280x720. That explains everything.

The pink color was set by myself, because I thought that one will not be used that often, so I won't get ugly holes in my images.

I will now try a darker colour and hope I can live with that !

Thank you guys for the explanations!
Marl
12
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 25th Mar 2013 18:30
It's pretty common in computer graphics to use purple or pink as the transparency indicator for the very reason you give, its the fact that it retains this colour that causes the problem.

One way around - still using irfanview - it is to design the graphics as before, then just before you output the transparent version, brighten the whole image a tiny amount (so that any black becomes very dark grey) and fill the purple part with black.

Any outline will now be black and the bits which were black - and are now very dark grey - will not be transparent.

Not a perfect solution, but workable.

If you are putting the sprite over different colours, a transparency of 50% grey is the least "distracting" - ie will stand out less than other colours against black, white or whatever.

Login to post a reply

Server time is: 2024-05-07 07:40:10
Your offset time is: 2024-05-07 07:40:10