Have ondraw draw an existing canvas

Problems with Canvas, OpenGL, etc...

Have ondraw draw an existing canvas

Postby oculuss » Thu Jan 20, 2011 3:17 am

I'll explain my goals, then what i've tried and my problems.

My goal was to have a class I could create that would draw a graph for me. It would be used as follows:
Code: Select all
Graph myGraph = new Graph(100,100);

This would create 100x100 graph. I wanted to use a canvas to do this so i could draw on it using its handy openGL functions. I wanted to then pass that canvas back to a view's onDraw method, and have that view draw the image that i created.

Some ideas i tried:
I had my class extend canvas, but couldn't figure out how to draw an existing canvas, only the canvas that was passed to the onDraw method.
I tried having my class have a Bitmap member object, made a canvas to draw to that bitmap, then made a function to return that bitmap and draw it to the canvas that was passed in to my activity's onDraw method. This may not have worked because i'm not familiar with how java does passing by reference or by copy.

So, what I'm asking for is a knowledgable opinion on how I should accomplish this. Sample code of the important part of the class (how i get what i need to draw back to my activity's onDraw) and how i would use it in the onDraw method.
Posts: 3
Joined: Sun Dec 05, 2010 11:25 pm
Location: Michigan


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

Who is online

Users browsing this forum: No registered users and 2 guests