Urgent - Image alpha / mask problem

Problems with Canvas, OpenGL, etc...

Urgent - Image alpha / mask problem

Postby aibo99 » Mon Jun 14, 2010 6:00 am

Hello,

I add an image called "refresh.png" in the dark color background. However, the circular arrow graphics turned into black color.

How could I change the circular arrow to white color during runtime ? (apply mask / filter / overylay / inverse color ?)

Appreciate it very much if you could give me some hints and coding.

Thanks
Attachments
01-refresh.png
01-refresh.png (459 Bytes) Viewed 992 times
aibo99
Freshman
Freshman
 
Posts: 9
Joined: Mon Oct 05, 2009 7:18 am

Top

Re: Urgent - Image alpha / mask problem

Postby Amazing Retardo » Mon Jun 14, 2010 8:04 am

In OpenGL, you could use glColor4f(1, 1, 1, 1) to make the arrow white (or any color for that matter) provided that it has alpha and that the arrow is white in color for the transparent regions and that blending is enabled with:

Code: Select all
gl.glEnable(GL10.GL_BLEND);
gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);


(forgive me if the function names/constants are misspelt, I'm remembering them from memory.. should be close enough though.)
Amazing Retardo
Freshman
Freshman
 
Posts: 4
Joined: Mon Jun 14, 2010 4:32 am

Re: Urgent - Image alpha / mask problem

Postby aibo99 » Mon Jun 14, 2010 9:30 am

Thank you very much for your help.

However, I lack experience of GL programming.

Would you please provide me some working code ?

Thanks again.
aibo99
Freshman
Freshman
 
Posts: 9
Joined: Mon Oct 05, 2009 7:18 am

Re: Urgent - Image alpha / mask problem

Postby Amazing Retardo » Mon Jun 14, 2010 10:28 am

Here's a simple tutorial to get you started (with lots of code samples):
http://blog.jayway.com/2009/12/03/openg ... id-part-i/

It's a multi-part tutorial so you might want to check out the other parts in the series too.

This is the API for GLSurfaceView, which does most of the work of setting OpenGL up:
http://developer.android.com/reference/ ... eView.html

I suggest using if you're new to OpenGL (as opposed to creating your own context and initialization code). Of course, depending on your scenario you may not even need OpenGL. (The concept for rendering a white arrow should be the same if you're just using canvas)
Amazing Retardo
Freshman
Freshman
 
Posts: 4
Joined: Mon Jun 14, 2010 4:32 am

Top

Return to Android 2D/3D Graphics - OpenGL Problems

Who is online

Users browsing this forum: No registered users and 4 guests