Android :: Difference Between View's And Bitmap's Canvas?
Mar 6, 2009Can anyone explain me the difference between View's Canvas and Bitmaps Canvas
View 2 RepliesCan anyone explain me the difference between View's Canvas and Bitmaps Canvas
View 2 RepliesMy 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..
Can anyone point me to an example of how to blur a Canvas or Bitmap?
View 2 Replies View RelatedI am getting the following logs when i am changing the wallpaper for Homescreen. Even i am recycling the bitmap is done when the wallpaper changes in OnWallpaperChanged(). Still i m getting the bellow error.
CODE:.........................
I want to get the current bitmap associated with my canvas so I can perform operations on it. I can't see how to do this though.
I've seen some examples where you create a bitmap and set the canvas to use this bitmap, so obviously you can then access it later, but I'm using the canvas returned from a SurfaceHolder so there's no constructor.
For instance, examples often show this kind of thing:
CODE:...........
So at this point I can see bmp.
In my case, the canvas is obtained by:
CODE:......
So how can I get the bitmap for c?
In short, my aim is to capture the current canvas contents where I have drawn "stuff", and make a copy of it, reversed, to put underneath. Like a reflection. The example of this that I found performed it all via bitmaps, so I assumed I needed to somehow capture the current canvas to a bitmap to then use it.
I am starting to develop a game. Right now I got a sprite animation going when a player moves across using sprite sheet. In my sprite sheet the character is always facing the same way, left. Now if I want the character to move right, I want it to be facing right. So is there a quick way in android to invert the bitmap after it has been loaded in? Or do I have to create sprite sheet for character facing right?
View 2 Replies View RelatedI 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 RelatedDoes anyone how I go about detecting when a user presses on a bitmap which is inside a canvas?
View 2 Replies View RelatedGreetings Developers,
I am just putting this question out there.
Is there a large efficiency difference between Canvas.drawBitmap or OpenGL. I am drawing using Canvas.drawBitmap and running slowing FPS, would openGL speed that up a lot you think?
i want to create a basic animation with a sprite sheet. there is only one row with about 2 pics (that's the first animation).
View 3 Replies View RelatedAt canvas there are many methods (canvas.rotate (35); canvas.drawBitmap (myBitmap, x, y, null); and many other things), but the method of mirror reflexion of image is absent (or I have not found it). At Bitmap too not that is not. Is it possible to reflect horizontally on canvas the image given Bitmap?
View 1 Replies View RelatedSpecifically I want to know if one can give me better performance. I want to draw the whole surface myself as I am scrolling a large bitmap. Basically I am trying to figure out how things like ListView / GridView do smooth scrolling (see thumbnails in picture viewer app) and writing custom views (even using surface views) seem to be flicker a lot.
View 2 Replies View RelatedI 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.
As we know, we can rotate a bitmap through 2 ways. The 1st way is: Matrix mt = new Matrix(); mt. postRotate (degree);Bitmap bitmap = CreateBitmap(src, 0, 0, w, h, mt, true); canvs.drawBitmap(bitmap, 0, 0, paint); In this way, we always need create new bitmap for every rotation, it is not good way for high performance game or app.The 2nd way is: canvas.save(); canvas.rotate(degree); canvas.drawBitmap(bitmap, 0, 0, paint); canvas.restore();In this way, we avoid creating new bitmap frequently, but the rotation bitmap is distortion, the bitmap quality is worse than first way.So, Is there 3rd way to rotate bitmap with high performance and good quality? Your any comments are really appreciated!
View 3 Replies View RelatedI am trying to draw an animation. To do so I have extended View and overridden the onDraw() method. What I would expect is that each time onDraw() is called the canvas would be in the state that I left it in and I could choose to clear it or just draw over parts of it (This is how it worked when I used a SurfaceView) but each time the canvas comes back already cleared. Is there a way that I can not have it cleared? Or maybe save the previous state into a Bitmap so I can just draw that Bitmap and then draw over top of it?
View 4 Replies View RelatedI am using SurfaceView to draw my game on the screen of the phone. Basically now I want to be able to draw Android Views on my View, such as a Button or ListView. I am simlpy getting a Canvas and then I draw on that... does anybody know how to draw AndroidViews (Button, ListView.) on my Canvas?
View 2 Replies View RelatedI have a view that is round and hovering above (-> in z-axis direction coming out of the screen) the main content. When the someone taps the screen I want either the main content to be selected or the view hovering above, when it covers the main view.
So far that works perfectly. I have a round shaped item on a transparent canvas. Meaning you can see everything of the background that is outside of that circle. However, you cannot select it, because it is still the hovering canvas, just with a transparent paint.
Now I'm wondering, to solve this issue, if it is possible to make the view/canvas itself round shaped?
Update
I added an image for better explanation what I try to achieve.
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...
I called canvas.drawBitmap to draw an image, but somehow it's showing up behind/underneath the custom view (or it's background). can someone explain this?
View 1 Replies View RelatedI have create a subclass of View and overwritten onDraw() - see some test code below. It draws a line consisting of some points. Before the line is drawn the canvas is rotated and restore after the drawing. The angle by which the canvas is rotated increases by 5 degrees every time onDraw() is called. The view is invalidated about once a second causing the view to be redrawn. Due to the rotated canvas the line drawn looks like a clock hand rotating counter-clockwise. This works - but not always. Sometimes the line is not drawn for one or more seconds, although I know from the log statement that onDraw() was called. Sometimes means: The line may be not shown after 8 seconds, then again after 35 seconds and so on. If the canvas is not rotated the problem does not occur. This also happens when I use a SurfaceView instead of a View. It does not only occur in the simulator but also on my G1 - both using Android 1.6.
CODE:.............
I am drawing text in my custom view in android using canvas.drawtext. i need to change back color, and want text right aligned. for example i want to print the text in a 10, 10, 100, 20 rectangle of color yellow and text color red and right aligned. how can i do that ?
View 2 Replies View RelatedI have a custom view which is drawing some bitmaps on screen. I want to scale the bitmaps depending on some sensor data. Can anyone suggest to me the best way (performance wise) to scale the bitmaps.
Right now I'm creating the bitmaps in the constructor of the view but if I start to scale it in the onDraw method I believe I'll just be re-drawing the bitmaps (Which will be a memory / cpu hog).
When is it necessary, or better to use a SurfaceView instead of a View?
View 3 Replies View RelatedI'm trying to convert my LinearLayout to a bitmap so that I can save the current layout content as an image in SD card. First, I create bitmap and canvas and attach the layout to the canvas.
Followed steps from http://www.brighthub.com/mobile/google-android/articles/30676.aspx#comments.
Code to add child view into layout before creating bitmap:
CODE:............
When I press the save button, it should save the current layout as an image to SD card.
Here are my steps:
CODE:...............
It can create folder in SD card but no file created under this folder. It always gives me FileNotFoundException. I'm not sure it is the file creating problem or the screenBitmap problem.
I have a view. I want to place a bitmap image as its background image. I was not able to do that.
My code is below...
I have a views on the main class and many other class with an onDraw() method to draw a canvas.
Java:
CODE:.....................
Difference between View margin and padding , mPadding and mUserPadding?
View 2 Replies View RelatedI'm trying to create a MapView in a service (live wallpaper), but have it hidden so that I can render it to a Bitmap, and then map it to a texture to render in opengl. I have a Canvas and a Bitmap, and I intended to call myMap.draw(myCanvas) in order to get it into the correct bitmap so that I could then bind it as a texture.
When I Initialize I do the following:
myMap = new MapView(ctx, APPSTATICS.MAP_API_KEY);
I get an error:
java.lang.RuntimeException: stub at com.google.android.maps.MapView.<init> (Unknown Source)
Why I can't create a new mapview which I can use to draw to a offscreen bitmap?
I will try to explain what exactly I need to do.
I have 3 separate screens say A,B,C. There is another screen called say HomeScreen where all the 3 screens bitmap should be displayed in Gallery view and the user can select in which view does he wants to go.
I have been able to get the Bitmaps of all the 3 screens and display it in Gallery view by placing all the code in HomeScreen Activity only. Now, this has complicated the code a lot and I will like to simplify it.
So, can I call another Activity from HomeScreen and do not display it and just get the Bitmap of that screen. For example, say I just call HomeScreen and it calls Activity A,B,C and none of the Activities from A,B,C are displayed. It just gives the Bitmap of that screen by getDrawingCache(). And then we can display those bitmaps in Gallery view in HomeScreen.
I hope I have explained the problem very clearly.
Please let me know if this is actually possible.
I have an ImageView that contains a bitmap. Now the bitmap can change size within a known range. This makes the surrounding views to relocate which I want to prevent. I've tried setting margins and padding for the ImageView but without success.
View 1 Replies View Related