[Solved] PNG Alpha Transparency on SDL Android

BlitzMax Forums/Brucey's Modules/[Solved] PNG Alpha Transparency on SDL Android

RustyKristi(Posted 2016) [#1]
This has been tested on desktop to be working but when building on android there's no transparency and it's black background instead.

Can someone confirm on this? thanks


RustyKristi(Posted 2016) [#2]
MASKEDIMAGE works btw but it does not look good.


Derron(Posted 2016) [#3]
Works here as intended.

- I opened up "Dig/samples/interpolation"
- copied "start_logo.png" from "Dig/samples/_res" into this directory
- opened up "interpolation.bmx" and appened after the latest import:

Import brl.ramstream
Import Brl.PNGLoader
Incbin "start_logo.png"


After "setBlend" I added:
Local img:TImage = LoadImage("incbin::start_logo.png",0)


Then I added right before the first "If KeyHit":
	For Local i:Int = 0 To 15
		SetColor i*20, i*20 + 55,i*20
		DrawRect(GraphicsWidth() - i*(img.width/15), GraphicsHeight() - img.height,(img.width/15), img.height)
	Next
	SetColor 255,255,255
	DrawImage(img, GraphicsWidth() - img.width, GraphicsHeight() - img.height)


Result was like intended: slight shadow of the text was displayed, so no simple "1 color transparency" but a real alpha channel usage.


bye
Ron


Derron(Posted 2016) [#4]
BTW: instead of incbin, you could also copy the image to "assets" within the newly created "android-project-interpolation".

You then could load the image via:
Local img2:TImage = LoadImage("sdl::start_logo.png",0)

You might need to "import Sdl.sdl" first.


bye
Ron


RustyKristi(Posted 2016) [#5]
Thanks Derron! :D I will try this asap..


RustyKristi(Posted 2016) [#6]
Ok so I finally got it after doing some tests. If I'm not mistaken that for alpha png images you need to SetColor to white (255,255,255) before you load the image.

I don't know or I have yet to find a manual or online docs showing this method but I'm glad to have solved this issue so thanks again! :D