Android :: Unable To See Bitmaps At 0 0 Of Canvas

Jul 6, 2010

I have following example code:

Character c = CharacterFactory.getCharacter(CharacterEnum.SpecialCharacter); //factory has applicationContext reference to get bitmaps from R. ... Paint bitmapPaint = new Paint(); ... View::onDraw(Canvas canvas) ... canvas.drawBitmap(c.bitmap(), 0, 0, bitmapPaint);

For some reason (must be something simple) I do not see the bitmaps at the 0,0 of the canvas. Inspecting the bitmap and etc does not show anything obvious (nulls), I must have missed something. Is there something I should be paying particular attention to while drawing bitmaps?

Android :: Unable to see bitmaps at 0 0 of canvas


Android :: Compare Bitmaps In Canvas

Aug 18, 2010

I am using the above code for displaying bitmap.and i also move that bitmap.Now my qusetion is how i am compare bitmap with another bitmap. Please give me some suggestions.

View 2 Replies View Related

Android :: App Gets Too Slow While Drawing Two Bitmaps On A Canvas / Fix It?

Nov 4, 2010

I have two bitmap overlapped .The top bitmap is transparent and when user touch to screen i copy pixels from another bitmap to top bitmap.My goal is to give to users the feeling of erasing image with touching to see another image.However it is not working properly especially when user drags his finger too fast on the screen.I made a few tests and i beleive drawing bitmaps to the canvas every time cause the lag but i don't know how to fix it.

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 :: Unable To Rotate Image In Around Its Center Point In Canvas / What To Do?

Nov 10, 2010

Rotate image on canvas around its center . i tried some example from net but i am failed

if i am using bitmap.creatbitmpa with matrix i am getting error

Please suggest me which is better

View 1 Replies View Related

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 :: Widget With Custom Bitmaps

Oct 1, 2010

I am writing a clock widget that uses customised bitmaps (so the widget loads the bitmap from the sdcard) Just have a couple of questions regarding how updates work:

1. if i want to display seconds on the clock widget will the widget load the bitmaps off the disk every second or can they be cached somehow so it doesn't reload off the disk each time. or If it does reload a bitmap each second, would this use a lot of power?

2. If i load the customised number bitmaps into a static array and then pass them as bitmaps to the widget would this use less power than just loading off the SD card?

View 6 Replies View Related

Android :: Load Bitmaps Into ImageViews

Oct 15, 2010

I want to load bitmaps into ImageViews in Android, but I don't want to use the R.drawable syntax because I have a lot of images with a standard naming convention so it's much easier to get the image with some logic. For example, all my images are named:

img1.png
img2.png
img3.png

So if a user selects a value, let's say x, I show "img" + x + ".png" in the ImageView. Looks like Bitmap.decodeFile is what I need, but I need to know the syntax of how to get to my drawables folder since that's where the images are. Or if there's perhaps a better way.

I realize I could do this with a switch statement instead of concatenating the image name but that would be a lot of lines since I have so many images.

View 3 Replies View Related

Android : Get Bitmaps Blurred Using Droid?

Sep 9, 2010

I am struggling to get Bitmaps blurred using Android.

I have seen a lot of information about using a simple kernel like

0 0 0 5 0 0 0
0 5 18 32 18 5 0
0 18 64 100 64 18 0
5 32 100 100 100 32 5
0 18 64 100 64 18 0
0 5 18 32 18 5 0
0 0 0 5 0 0 0


My problem is that I am really not sure how to multiply this with my Bitmap in an efficient way. Should I go through every pixel and image.getPixel(x, y)

while storing those values to a new array (so I don't have to get those values over and over again) and then go through the array and for each value add up the surrounding values multiplied by the corresponding field in the kernel divided by 1068 (in the case of the above kernel (= all entries summed up))?

Is there any better way to do this? Is there a simple solution for the borders?

Or is there even something available in the Android SDK I missed?

View 2 Replies View Related

Android :: Downloading Images And Converting To Bitmaps

Jun 16, 2010

I am working on an application that downloads images from a url. The problem is that only some images are being correctly downloaded and others are not. First off, here is the problem code:

public Bitmap downloadImage(String url) {
HttpClient client = new DefaultHttpClient();
HttpResponse response = null;
try {.......................................

So what I have is a method that takes the url as a string argument and then downloads the image, converts the HttpResponse stream to a bitmap by means of the BitmapFactory.decodeStream method, and returns it. The problem is that when I am on a slow network connection (almost always 3G rather than Wi-Fi) some images are converted to null--not all of them, only some of them. Using a Wi-Fi connection works perfectly; all the images are downloaded and converted properly. Does anyone know why this is happening? Or better, how can I fix this? How would I even go about testing to determine the problem?

View 2 Replies View Related

Android :: Track Memory Consumption (Bitmaps)?

Mar 26, 2009

How can one track memory consumption in Android? The Android "Heap" view in Eclipse and java.lang.Runtime methods seem failing for my purpose. I tried to figure out how much memory my app consumes in order to make decisions for future directions. Most of the memory goes into Bitmap objects. Just to test memory consumption I created huge bitmaps in a Loop and logged the java.lang.Runtime memory values: created bitmap (610k free, 2371k total, 16384k max) created bitmap (615k free, 2371k total, 16384k max) created bitmap (615k free, 2371k total, 16384k max) created bitmap (615k free, 2371k total, 16384k max)

Nothing seems to hapen, but on the fifth Bitmap: java.lang.OutOfMemoryError: bitmap size exceeds VM budget at android.graphics.Bitmap.nativeCreate(Native Method) at android.graphics.Bitmap.createBitmap(Bitmap.java:343) at de.greenrobot.colorball.GameView.init(GameView.java:86)

This seems confusing at first. Is java.lang.Runtime the right place to check application memory stats in Android at all? Are Bitmaps allocated outside the app's heap? How can I track it?

View 4 Replies View Related

Android :: Allocating Bitmaps And Out Of Memory Error

Jun 16, 2010

I'm running into OutOfMemoryErrors when allocating bitmaps. This is not something I can reproduce with emulators, and has been reported by a few beta testers with the HTC Incredible. I'm not sure I can solve this directly, and my best hope is to follow best practices for bitmaps and memory thereof. But looking for those best practices based on groups archives left me with more questions than answers. If anyone has a chapter about this in their book, I will buy the book. Here are the things I've mulled over so far:

1. I have a bitmap for a drawing buffer. It is about 3-4 megabytes on some devices. This is the biggest bitmap I have, and without it, I wouldn't be able to much of anything useful in my app. I am assuming that it would not be useful to use inPurgeable if this is a bitmap that is drawn into. Is this true?

2. Next biggest in the hierarchy are some bitmaps that are about 22K bytes and 256K unpacked. Since I believe about 25 of these might be used at one time, I have a cache with a size of 25. I am careful to use BitmapFactory.Options.InPurgeable, so I believe that could make them take only 22K each, but I don't see that as guaranteed. Maybe they are taking 256K each, which would put me in the danger zone. As they are cycled out of the cache, I call bitmap.recycle(). I think this a good practice. Is it?

3. Next are some resources with icon size 32x32 pixels. There are about 50 that could be used or reused. If I use code like this:

Drawable s = mCtx.getResources().getDrawable(R.drawable.symbol_icon);
Where s is a local variable to rendering. Suppose I call this 37 times. Am I to assume that Android will do something smart like create only one bitmap for this resource even if it is used 37 times? Or am I to assume that Android will do something stupid like create 37 bitmaps and keep references in an obscure location that will prevent garbage collection? Do I need to get more access to these bitmaps and do something smart myself?

4. Finally are some other icons used for menus and ImageButtons. Most are declared in layout files - so I don't touch the bitmaps directly.

I'd like to make my memory usage more efficient, but don't want to spend time on things that will amount to shuffling chairs on the Titanic. And how do I best measure this usage? Interestingly enough, I've tried using the Allocation Tracker and it says I haven't allocated a single bitmap. In light of the above, I don't think that's right.

View 11 Replies View Related

Android :: OutOfMemory With 9M Free Heap Because Of Bitmaps!

Mar 3, 2010

Our app has some memory peaks, which let the heap grow to 13M. After the peak, there's 9M of free heap. Everything's fine until Bitmap objects come into play. Despite having 9M of free heap creating Bitmaps, which have only some 100k, now fail with a OutOfMemoryException!

My theory: Allocation fails if (Java) heap *size* plus external allocations (e.g. Bitmaps) exceed 16M, no matter that there is lots of free memory in the heap. The VM could shrink the heap, but actually does not. Would be quite a flaw in the VM.

Does anyone share this theory?

On the downside of this theory: I do not see anything appropriate (killing the process is probably not) an app developer could do to prevent those OutOfMemoryExceptions given that those memory peaks are legitimate and unavoidable.

View 18 Replies View Related

Android :: GLSurfaceView Swaps 2D Bitmaps Being Drawn / Cause Of This Can Be?

Sep 8, 2010

I have an application that receives information from a database, and is used to visualize 2D bitmaps onto a GLSurfaceView. The information received will determine the x-position of the bitmap, and which bitmap image to use (there are 4 different bitmaps in my res folder to choose from).

Below are the three classes that are being used. The Activity sets the Shapes objects that need to be drawn by passing an ArrayList to the GLLayer class. This ArrayList is passed to the instance of ShapeStorage class via another setList method. This class is responsible for drawing when they are received.

The problem that I'm having is the following. Suppose I receive one object (let's say that it's a square at it's located at x=1). Some time goes by, and I receive another shape (this time, it's a triangle, and it's located at x=-1). However, when this new shape appears on the screen, the old bitmap's appearance changes to a triangle, and the new one becomes a square. In other words, the objects themselves are at the correct position that they are supposed to be at, but the bitmap being associated with them has changed. Does anyone know what the possible cause of this can be? I'm still a newbie to OpenGL-ES, and while this code looks very convoluted, it just involves setting a bunch of various properties for the View. code...

View 1 Replies View Related

Android : Leaking Bitmaps From Adapter's GetView

Mar 31, 2009

I definitely have a memory leak problem and i'm trying to figure out there. After 6-10 config changes i'm getting out of memory in regards to BitmapFactory. I'm kind of suspect that this is going on within adapter. I have a listview . ListItems are an thumbnail image ( ImageView ) and TextView for text.

Here is the getView code.

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

And get ThumbnailBitmap() is basically BitmapFactory.decodeByteArray ..

Is it possible that i'm leaking drawables ? Heap is not increasing by the way .

View 3 Replies View Related

Android :: Java.lang.OutOfMemoryError When Load Bitmaps

Jun 8, 2010

I used this sort of code to make sure my bitmaps load:................

In 2.2, it's now failing sometimes and my catch block no longer catches anything. Why would that be? Is there a better way to avoid a java.lang.OutOfMemoryError?

View 10 Replies View Related

Android :: Drawn Bitmaps Are Not Scrolling In Custom View

Nov 9, 2010

I am creating a CustomView with bigger image based on tutorial on and developers forum. It is scolling fine.I need exact pixel coordinates of my image.I am getting that also.now I want to draw some images upon scrolling image.I am able to draw images using onDraw().But images are not getting scrolled.Any idea how to resolve this?

View 4 Replies View Related

Android :: Bitmaps Loaded From Gallery Are Rotated In ImageView

Sep 5, 2010

When I load an image frome the media gallery into a Bitmap, everything works fine, except that pictures that were shot with the camera while holding the phone vertically, are rotated so that I always get a horizontal picture even though it appears vertical in the gallery. how can I load it correctly?

View 3 Replies View Related

Android :: Drawing Bitmaps On Screen In Game Without Slow Performance

Sep 16, 2009

I want to make a tile based game for android. At the moment I am drawing each tile as a separate bitmap. I have a big for loop that reads from a string and draws different tiles depending on what character it finds to draw the level. I have allowed the user to scroll the screen using scrolling gestures. However the game is too slow. It takes a long time to update the screen after the user scrolls. I presume this is because it has to draw each tile's bitmap individually. What would be a faster way to draw the level? I was thinking I could merge all the tiles into one bitmap. But I don't know how to do this.

Anyway here is my code so you can see the problem:
package org.example.tutorial2d;
import android.app.Activity;
import android.os.Bundle;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.GestureDetector.OnGestureListener;
import org.example.tutorial2d.Panel;
public class Tutorial2D extends Activity implements OnGestureListener {
GestureDetector gestureScanner; Panel main;
/** Called when the activity is first created. */
@Override public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
gestureScanner = new GestureDetector(this);
//requestWindowFeature(Window.FEATURE_NO_TITLE);
main = new Panel(this); setContentView(main); }
@Override public boolean onTouchEvent(MotionEvent me) {
return gestureScanner.onTouchEvent(me); }
@Override public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
main.handleScroll(distanceX,distanceY); return true; }
@Override public boolean onDown(MotionEvent e) { return true;
} @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { return true;
} @Override public void onLongPress(MotionEvent e){
} @Override public void onShowPress(MotionEvent e) {
} @Override public boolean onSingleTapUp(MotionEvent e) { return true; } }

And the class that does all the work:
package org.example.tutorial2d;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.util.Log;
import android.view.View;
import org.example.tutorial2d.Point;
public class Panel extends View {
private int scrollX = 0; private int scrollY = 0;
public Panel(Context context) { super(context);
} @Override public void onDraw(Canvas canvas) {
/*Bitmap scratch; //Drawable scratch;
//scratch = getContext().getResources().getDrawable(
// R.drawable.icon); canvas.drawColor(Color.BLACK);
//scratch.draw(canvas); int origin = 0;
scratch = BitmapFactory.decodeResource(getResources(), R.drawable.horizontal5);
canvas.drawBitmap(scratch, origin, origin, null);
int width = scratch.getWidth(); int height = scratch.getHeight();
scratch = BitmapFactory.decodeResource(getResources(), R.drawable.room4entrynesw3x3);
canvas.drawBitmap(scratch, origin + width, origin - 32, null);
[Code]

View 3 Replies View Related

Android :: Bitmaps And Out Of Memory Error (Allocating Back Buffer)

Sep 2, 2010

We are also having occasional problems with OutOfMemory errors in createBitmap. It tends to happen after a few orientation changes when we are allocating the backbuffers. I have made it so that it calls recycle() on the old bitmaps (if any exist) and does a System.gc() before allocating the new backbuffers. What we are doing is allocating a backbuffer that is twice the width and height of the screen so that we can quickly zoom in and out.

With a 854x480 screen this would presumably be 6.25MB in size. The problem as I see it is the 16 or 24MB maximum heap size per process. This is unreasonably small, especially on devices that have 512MB of RAM. Ideally the max heap size should be something like 64MB, or perhaps allow apps to request a larger heap size from the user.

View 14 Replies View Related

Android :: Concate / Combine Two Bitmaps And Make Them One Image In Droid?

Sep 17, 2010

Can anyone tell me how to combine or concatenate two bitmap images into one in android?

View 2 Replies View Related

Android :: Out Of Memory Error On Large Bitmaps And Activity Life Cycle

Jul 24, 2010

I have a scrollable map app which for now has a huge bitmap. It loads fine on startup, but when it looses foreground status and the user brings it backs again im getting an out of memory error. In onPause it trashes the bitmap using recycle, and marks it as null. The onResume checks to see if map==null and will load the bitmap back again, which is crashing the program despite me recycling the bitmap...Here are some bits of code. All of the other references to Bitmap map first check if it is null before loading/drawing..............

View 1 Replies View Related

Overlay Bitmaps With Click Of Button

Oct 27, 2011

I am currently working on an app and I want to lay a Bitmap over the Google Maps bitmap with the click of a button. I am assuming this is possible, and maybe a lot easier than I'm making it.

class MapOverlay extends com.google.android.maps.Overlay
{
@Override
public boolean draw(Canvas canvas, MapView mapView,
boolean shadow, long when)

[Code] ......

View 1 Replies View Related

Android :: Check Cache Size For Bitmaps / Fix Maximum Size Of It?

Jun 30, 2010

I manage a cache of bitmap. Do you have an advise to fix the maximum size of it?

View 2 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 :: 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.

View 2 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







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