Layouts on OpelGL Figures

All your problems with Audio, Video and Images.

Layouts on OpelGL Figures

Postby Jbeer » Thu Nov 13, 2008 5:31 pm

Hello everybody.

I am working in OpenGL aplications with Android, and I would like to know if is it possible to:

-Convert a Layout to a Drawable (or a Bitmap) to put it on a OnpelGL figure as Texture

the idea is to show information (text, images) in a face of a cube, for example.


I have been smashing my head with the APIs but nothing useful found.

Any Idea?

Thanks!


PD. In less than 1 week, we will have 2 Android mobiles here, in the Spanish company I work for. Yeah!! ;)
Jbeer
Junior Developer
Junior Developer
 
Posts: 14
Joined: Tue Jul 22, 2008 8:07 am
Location: España

Top

Postby MrSnowflake » Thu Nov 13, 2008 7:46 pm

You can make "screenshots" of Views. I can't find it right now, but there's a function in there which makes a drawble of the selected View.
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby Jbeer » Fri Nov 14, 2008 9:01 am

Thanks for the reply.

I found a View method called getDrawingCache(), have anyone of you used it? I had to enable the cache with the setDrawingCacheEnabled(boolean enabled) method, but no result is given, the response is always null.

Another point is that I want to make that "screenshots" witout showing the layouts in the screen. I want to have the layout created (but not shown), and generate the bitmaps internaly. Is it possible?
Jbeer
Junior Developer
Junior Developer
 
Posts: 14
Joined: Tue Jul 22, 2008 8:07 am
Location: España

Postby MrSnowflake » Fri Nov 14, 2008 11:43 am

The view you want to capture has to be in the ContentView tree, otherwise it wil indeed return null. You can try calling onDraw() or invalidate() on the view yourself, never tried if this works.
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby Jbeer » Tue Nov 18, 2008 12:17 pm

Umm...

I am triying other thing.

What about converting a Canvas to a Bitmap?

Can I draw in a canvas and that, convert to a Bitmap image?

All it to put the Bitmap in the OpelGL texture.
Jbeer
Junior Developer
Junior Developer
 
Posts: 14
Joined: Tue Jul 22, 2008 8:07 am
Location: España

Postby Jbeer » Thu Nov 20, 2008 1:38 pm

Solved!

I could put a view in a OpenGL figure as Texture.

The steps are the following:

-Create an Empty Bitmap

-Create a Canvas using that Bitmap (new Canvas(Bitmap)) Warning! The Bitmap MUST be mutable, so everything we draw in the canvas will be drawn in the Bitmap.

-Create a ViewGroup and add to this viewgroup all the views we want.

-Using the dispatchDraw method from the ViewGroup, draw the Views in the canvas.

So, in the Bitmap we have drawn the ViewGroup!

Thanks for the support ;)
Jbeer
Junior Developer
Junior Developer
 
Posts: 14
Joined: Tue Jul 22, 2008 8:07 am
Location: España

Top

Postby MrSnowflake » Thu Nov 20, 2008 1:43 pm

Nice, now you can make tilted listViews and twisted browser views :D
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 12 guests