Android :: Draw From Old Canvas

Oct 28, 2010

I'm making an App that needs to be able to draw new graphics on top of the last set.

This is my current onDraw() method -
protected void onDraw(Canvas canvas) {
canvas.drawColor(Color.WHITE);
if(points.size() > 0) {
//do some stuff here - this is all working ok
canvas.drawLine(p1.x, p1.y, p2.x, p2.y, linePaint);
}
}

Basically, I need to draw the new graphics as a layer on top of the last, so what I'm looking for is a way to carry the image of the last canvas to the current. I have tried to figure it out myself using the canvas.setBitmap() method but it acts very funny.

Android :: Draw From Old Canvas


Android :: Reset Canvas - Draw A New Bitmap Into The Canvas

Jul 7, 2010

My loadMap() method generate a canvas.throwIfRecycled exception when i try to load a new map.
When i start the game, the initial map loads and work fine though,
its only when i try to load a new map that i get the exception ..

How can i "reset" canvas and the bitmap i use to draw into, so i can startover fresh with them ?
here's what i use to create and draw my maps:

CODE:.........

So basicaly once i created and used picDest and canvas, i cannot figure how to reset it all for when i want to load a new map..

View 1 Replies View Related

Android :: Draw Text On Canvas?

Oct 28, 2010

i'm trying to develop a simple pie chart class for android. For now, it can take a map of labels and values and draw the pie chart. I'm yet to add the legends for the pie, which is where i need to place the texts near small rectangles on the screen corner. Any help appreciated, since i'm new to Android dev.

View 1 Replies View Related

Android :: How To Repeatedly Draw On A Canvas?

Sep 7, 2010

My requirement is to draw a line on canvas for every second. I am able to draw the line but its clearing the previously drawn lines when I call myview.invalidate(). Now my question is how to draw a new line retaining all the previously drawn line on the same canvas.

View 5 Replies View Related

Android :: Drawable Cannot Draw Into Canvas / What To Do?

May 26, 2009

I want to load an icon from resource and draw over it. But I cannot get it into a canvas. Can anyone please help me with the code below. If I uncomment c.drawColor(), I get blue color as expected. So the problem is on icon.draw(). code...

View 2 Replies View Related

Android :: Can I Draw Views On Canvas

Sep 28, 2010

I want to load e.g. LinearLayout with some Buttons from XML and draw it on Canvas in a way that the Views behave normally (I can set onClick actions for the Buttons and when I press a Button, it changes it's background drawable). Can I do this?

View 1 Replies View Related

Android : Way To Draw Nine Patch Onto Canvas?

Jan 24, 2010

I'm trying to draw a nine patch onto a Canvas object on the Android. What seems strange is that although I generated my nine patch using the draw9patch tool, the constructor for NinePatch requires an additional byte array called the "chunk" to construct the nine patch. Why isn't this simpler? What is the "chunk"? And if you have done this yourself, how did you go about it?

View 1 Replies View Related

Android : Can I Draw Outside Bounds Of An Canvas

Oct 26, 2010

I'm porting an app written in a graphics environment that allows drawing to happen outside the bounds of the clipping rectangle. Any way to do this in Android?

View 1 Replies View Related

Android :: Using StaticLayout With Canvas To Draw Text

Feb 4, 2010

I have figured out the static layout this far, but I have no idea how to make it display my text anywhere else but in the top left corner. StaticLayout layout = new StaticLayout(text, getTextPaint(), 140, android.text.Layout.Alignment.ALIGN_CENTER,(float)1.0, (float)0.0, true); layout.draw(canvas);

View 2 Replies View Related

Android :: How To Increase FPS When Draw On Canvas - Now 20 - Desired 40-50

Jan 18, 2010

First I want to say that I have read many articles on this subject in this forum and on some external resources(very helpful was Robert Green's diary at www.rbgrn.net and www.droidnova.com).

However, despite all of this I want to start topic regarding FPS, and ask for advice from experienced game developers on Android platform.

My main question is "How to improve FPS when draw on Canvas?"

I have implemented simple 2D arcade game skeleton for testing purpose. Now I have ~20 FPS and want to increase this value to 40-50 FPS, if this is possible of course. I know about Open GL ES, but so far I am interested in Canvas.

In every frame I draw following stuff on the screen: - Canvas.drawColor(Color.BLACK) - to clear the screen - 1 spaceship PNG 24x24 image 1.25 kb - 5 asteroids PNG 64x64 image ~8 kb each - from 1 to 30 bullets PNG 8x8 image 299 b - 4 30x30 Rectangles - to control objects on the screen

After running my app, in logcat I can see following output data: - Average FPS: 20 (Total frames drawn: 1945 in 97 seconds) - Average onDraw: 32 ms (clear canvas: 3, draw game stuff: 26, draw controls: 1) - Average updatePhysics: 1 ms

From this output I can assume, that my main problem here is "draw game stuff" wich includes: - draw 1 spaceship - draw 5 asteroids - draw from 1 to 30 bullets

Here is my code:........................

View 1 Replies View Related

Android :: Draw Canvas Using Blur Effect?

Dec 30, 2009

I need do draw on Android's Canvas using Blur effect, it is a very simple feature, I need to draw a circular area, which is blurred (the foreground) and the background transparent, I can do everything with manipulating the colour alpha to do it with custom transparency but I need it to be blurred instead of transparent..

View 1 Replies View Related

Android :: Code To Draw Hands On Canvas?

Jun 28, 2010

I want to draw hands on the canvas which is smooth and closed arc. How can I draw it? Any code regarding graphics or reference class to draw it will be helpful.

View 2 Replies View Related

Android :: How Google Map Draw On Canvas In Droid

Sep 16, 2010

Can anybody tell me or send me some links if there is any..which tells how Google map draw on canvas in android. what is the logic behind that.

View 1 Replies View Related

Android :: How To Draw Canvas In Respect Of Phone Orientation?

Oct 11, 2010

There is no problem with portrait mode but when i try my app on landscape mode it doesn't look how it should.What is general approach to solve this problem.My first idea is replacing X and Y places.If i am on the right track how should i do this ? Should i use an if statement at the beginning of the onDraw() function and write entire same code twice (one for x,y and other is for y,x) ?

View 2 Replies View Related

Android :: Draw Multiple Shapes Using Loop - Canvas

Aug 7, 2010

I am very new to android development and have been trying to draw a square comprised of multiple smaller rectangles of different colours... Like a Mosaic essentially. Basically at the moment I am reading values from a file which assigns the colour to the smaller Rects. I am using a pair of nested for loops to try to draw the small Rects sequentially, line by line. However when the program finishes there is only one small Rect drawn which is the last one to be drawn and its colour corresponds to the first value read from the file. Here is some of my code to show you what I mean:

public SnapshotDraw(Context context) {
super(context);

for(int a = 0; a < 63; a++){
for(int b = 0; b < 63; b++){
fileName = PREFIX + "2" + EXTENSION;..............

View 3 Replies View Related

Android :: Draw A View On A Canvas By Giving X , Y Postion?

Sep 29, 2010

How can i draw a view on a canvas by giving the x,y position in the canvas.

For example,
I have custom view myView, which was created by inflating one of my layout.xml file.
Now i want to draw this myView on the canvas at position (x, y).

How can i do that? code...

View 1 Replies View Related

Android :: Draw And Scale A Bitmap On A Canvas Using Bicubic Interpolation

Mar 25, 2010

I want to draw a bitmap on a canvas with bigger size than it is. I can use canvas.drawBitmap(bitmap, null, destRect, null); but that gives a poor quality, as the result is pixelated, if the source image is sightly smaller than the destination rectangle. How can i draw my bitmap using bilinear or bicubic resampling?

View 1 Replies View Related

Android :: Draw Translucent Bitmaps Using Canvas Without Having To Resort To OpenGL?

Mar 17, 2010

I have a Bitmap object and want to render it to a Canvas object with varying levels of translucency (i.e. make the whole bitmap partially see through). For example, I have sprites in a game (that are drawn over the top of a bitmap background) that I want to fade out from being opaque to being invisible. Can I do this without having to resort to OpenGL?

View 2 Replies View Related

Android :: Method To Draw Bitmaps Faster On Droid Canvas / OpenGL?

Jun 15, 2010

I currently have a game written using the Android canvas. It is completely 2D, and I draw bitmaps as sprites on the canvas, and it technically works, but I have a few features that I need to add that will require drawing many more bitmaps on the screen, and there will be a lot more movement.

The app needs more power.

What is the best way to go from this method of drawing Bitmaps on a canvas to using OpenGL so I can draw them faster?

View 2 Replies View Related

Android :: Draw Route Path Draw Function

Sep 5, 2010

In my android application I use this method in "draw" Overlay class for draw route on map. Can someone tell me if this method is good (in terms of performance) for route draw on map or I must to put code in Thread ??
I'm new to android.

public synchronized void draw(Canvas canvas, MapView mapView, boolean shadow) {
if (pointsAndTimes.isEmpty()) {
return;
}
Projection projection = mapView.getProjection();
Paint paint = new Paint();
paint.setARGB(250, 255, 0, 0);.............

View 1 Replies View Related

Android :: Draw Shape Within Shape Or Draw 2 Lines Around Shape

Jun 21, 2010

I want to have a elmenent with a 2 color border outline. I can do a single color outline using the element, but this only allows me to draw a single line. I tried using 2 elements within my but that didnt work either. Is there a way to either draw a shape within a shape or draw 2 lines around my shape (which has rounded corners btw).

View 3 Replies View Related

Android :: Transparent Canvas

Apr 4, 2009

I'm trying to make an app that requires me to draw over a layout with buttons, etc. I want to build a transparent canvas over the current layout and draw onto that canvas. How is this done?

View 3 Replies View Related

Android :: Copy From One Canvas To Another?

Oct 4, 2010

I want to copy the image drawn in one canvas (details) into another canvas. The commonly discussed solution of using bitmaps will not work because the Bitmap class does not have many of the important methods belonging to the Canvas class.

View 1 Replies View Related

Android :: OpenGL ES Canvas ?

Jun 13, 2010

I'm working on an OpenGL ES game using the NDK. My min SDK version is 1.6. I have created an OpenGL Es 1.0 renderer in Java and am calling a native JNI method in that renderloop.

The problem I'm having is that it seems that the resolution of the rendering context is limited. When using the emulator I'm getting a rendering canvas of 480x320, which is fine. Now; when I use my HTC Desire I am only getting a canvas of 533x320 while the native resolution of this phone is 800x480px.

View 2 Replies View Related

Android :: Possible For A View Having More Than One Canvas?

Aug 26, 2009

I have a View and that has a canvas. I am rotating the canvas, for rotating a bitmap. But after that, I need to draw one more bitmap on the Canvas and, this should not rotate. The second bitmap has to be static.

I tried with matrix rotation for bitmap. But its not rotating in the specified co-ordinates.

View 3 Replies View Related

Android :: Canvas.drawText ?

Apr 16, 2010

I have a view, I'm drawing with the Canvas object in the onDraw(Canvas canvas) method.

My code is:

CODE:....................

The problem is the text doesn't show through the background, what am I doing wrong? If I remove the canvas.drawPaint(paint) and paint.setColor(android.R.color.black) you can see the text on the screen.....

View 2 Replies View Related

How To Write On Canvas In Android

Mar 25, 2013

How I can show keyboar to write like text on canvas by soft keyboad?

View 4 Replies View Related

Android :: Save Canvas To Disk

Sep 22, 2009

I am doing a painting program (KIds Paint - you can find in Android Market) and I have a lot of requests to save the content on disk or to wallpaper. I have been searching around but cannot find solution. My guess is that I probably wanted to get the bitmap from the canvas, but I can't find ways to get it. Then I try to set an empty bitmap into the canvas and draw on the canvas, and save the bitmap... but I got an empty bitmap..........

View 7 Replies View Related

Android :: Converting Canvas To Drawable?

Sep 5, 2009

Is it possible to convert a Canvas to Drawable?I may be really off in my solution, so if you have a better suggestion, please do tell me. This is what I'm trying to do.I'm trying to create a custom RadioButton. to set different states of the radio button, I need to use this parameter and one of the parameter to addState is Drawable. I know I can easily provide an image file and use it as a Drawable, but I want to do some image manipulation to the image before using it.There is a tutorial in ApiDemo called AlphaBitmap. It uses the onDraw method of a View to change a PNG file to full red and draw something with a gradient. So I customized it to shade an icon with gradient. So the problem now is that this is a View, and the View works perfectly fine if I add this View to the main view. But i want to convert this View to Drawable so I can use it as one of the parameter in addState. What I really want to achieve is to have different colour shades for different state of the RadioButton without providing different images to do so.

View 6 Replies View Related

Android :: Path Appearing Twice On Map Canvas

Sep 14, 2010

I have a Main_Overlay class that extends Overlay. I added This overlay to the mapview and override the Draw method as of below:....................

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved