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...

Android :: GLSurfaceView swaps 2D bitmaps being drawn / cause of this can be?


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 :: Overlays Drawn On The Map

Jul 17, 2010

What I am trying to do - I am continuously getting a stream of lat/lng positions, I want to move a overlay item dynamically on the map based on the lat/lng in the stream. I am displaying the location of moving object dynamically on the map

I am putting my whole code in a while(true) loop and trying to read the stream every 5 seconds and refresh the overlays on the map. But overlay items are not shown until the function (either oncreate, or any onclickeventhandler etc) is completed. For example, test code, I am adding a single test overlay item when ever the user clicks on a button. If I put a wait(2000000) "after" I add overlays and invalidate the map, the overlay is not displayed until the time has elapsed and the function is completed.

View 5 Replies View Related

Android :: OpenGl Drawn Something?

May 10, 2010

glReadPixels is too slow, so I need another way. Without testing object by object, Is there any other way?

View 7 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 :: 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?

View 5 Replies View Related

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 :: 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 :: Use SurfaceView Properly , Nothing Is Drawn

May 31, 2009

I had it working with a normal View but that is to slow. I was told to use SurfaceView but can't figure out how to use OnKey with it and if I should use onDraw or draw? And how do I pass stuff to draw? does it happen automatically? code...

View 3 Replies View Related

Android :: Does A RemoteView Get Drawn On Screen?

Apr 28, 2009

From the javadoc of RemoteView, it said " * A class that describes a view hierarchy that can be displayed in another process."

But unlike View class, RemoteView does not have a 'draw(Canvas canvas)' method. Can you please tell me which method of RemoteView causing its layout to be drawn on screen?

View 2 Replies View Related

Android :: Able To Get Current OverlayItem Being Drawn

Jul 8, 2010

I want to be able to get some reference to the curent object being drawn. code...

Above is my draw method and I want to extend the draw method to write the title underneath each item for example. This would require the .getTitle() method from the OverlayItem. Possibly some tracking of objects outside of this method but not sure where to put it....

View 1 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 :: 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 : 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 :: Implement Dynamically Drawn Content?

Feb 2, 2010

Based on the limitations of RemoteViews, it looks to me that the appropriate way to get it actually drawn on the screen is to use an ImageView in the actual layout, then when it is updating, create a ShapeDrawable or two and draw them onto a newly created Bitmap. Then, set that Bitmap as the source of the ImageView. There is Something about that process that I'm just not grokking, though. The following is the code I tried to use to update the widget. I get nothing drawn on the screen at all. The ImageView has a placeholder image just set by its src property. When I don't run the code to update it to my drawing, the placeholder image stays in place. So, I know this code is doing something, just obviously not the right thing.

RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget);
Bitmap bitmap = Bitmap.createBitmap(100, 100, Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);

ShapeDrawable drawable = new ShapeDrawable(new ArcShape(0, 360));
drawable.getPaint().setColor(0xffff0000);
drawable.getPaint().setStrokeWidth(5.0f);
drawable.setIntrinsicWidth(100);
drawable.setIntrinsicHeight(100);
drawable.draw(canvas);

views.setImageViewBitmap(R.id.ImageView01, bitmap);
appWidgetManager.updateAppWidget(appWidgetId, views);

I knew it couldn't be that easy. So, am I even heading in the right direction? Update Ok, maybe that was too much information. The question I'm really trying to ask is this: If I want to draw shapes on a widget, should I use an ImageView and create a bitmap from my ShapeDrawable or is there more appropriate way to draw into a widget where it is constrained by RemoteViews?

View 7 Replies View Related

Android :: Get Bitmap Data Before It Is Drawn On Screen

Feb 22, 2010

To any normal android Widgets based on View( Button ,TextView ...), I wanna manipulate the bitmap data before it is drawn on screen. I have tried the onDraw(Canvas canvas) method, But when the programe hit the onDraw(Canvas canvas) method, I think the bitmap has already been drawn to screen.

If there is any way that I can get the bitmap data before it's drawn to screen, so I can prevent it from being displayed , but grab the data, put it on the intent for some further use?

View 2 Replies View Related

Android :: Gradient Drawn On Canvas Looks Banded / What To Fix

Sep 23, 2010

I have a gray gradient drawable (png image in res/drawable). If I draw it on a white Canvas it looks banded (not smooth). If I put the gradient on white background in GIMP, and then draw this drawable on the Canvas, it looks great. What's the problem? I tested this on Nexus One. Calling setDither(true) on the drawable has no noticable effect.

View 2 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 :: 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 :: Taking Screen Shot Of Whatever Is Drawn On View

Oct 28, 2009

I am trying to take a screen shot of whatever is drawn on my custom view's canvas. The getDrawingCache() call returns null sometimes. Any pointers to what I am doing wrong here?

View 3 Replies View Related

Android :: Why Force Close Before Activity Screen Is Drawn?

Jun 29, 2010

My app keeps force closing before it starts, eclipse returns no errors in my code and my xml is good.

package com.mhe.test.scan;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class main extends Activity {
/** Called when the activity is first created. */
@Override public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button myScanButton = (Button) findViewById(R.id.myScanButton); myScanButton.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent("com.google.zxing.client.android.SCAN");
intent.putExtra("SCAN_MODE", "PRODUCT_MODE");
startActivityForResult(intent, 0);
} } );
} EditText totalbox = (EditText) findViewById(R.id.totalbox);
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
if (requestCode == 0) { if (resultCode == RESULT_OK) {
String contents = intent.getStringExtra("SCAN_RESULT");
// Handle successful scan totalbox.setText(contents)
} else if (resultCode == RESULT_CANCELED) {
// Handle cancel totalbox.setText("@string/bummer");
} } } }
Essentially it is supposed to call zxing Barcode Scanner to scan a barcode on a button click and return the result into an EditText field.

View 2 Replies View Related

Android :: Develop Owner Drawn EditText Widget

Jan 26, 2010

I'm considering to develop owner drawn EditText widget. So, what do you think I should read or refer, firstly? Or, could you give me some good examples of both owner drawn widget or custom widget?

View 1 Replies View Related

Android :: Measuring Text Width To Be Drawn On Canvas

Jul 15, 2010

Is there a method which returns the width ( in pixels ) of a text to be drawn on an Android canvas using the drawText() method according to the Paint used to draw it.

View 1 Replies View Related

Android :: Measuring Text Height To Be Drawn On Canvas

Sep 6, 2010

Any straight forward way to measure the height of text? The way I am doing it now is by using Paint's measureText() to get the width, then by trial and error finding a value to get an approximate height. I've also been messing around with FontMetrics, but all these seem like approximate methods that suck. I am trying to scale things for different resolutions. I can do it, but I end up with incredibly verbose code with lots of calculations to determine relative sizes. I hate it! There has to be a better way.

View 1 Replies View Related

Android :: Show Shadow For Text Drawn On Google Map

Jun 7, 2010

In my map application I am using overlay items and texts. I need shadows for both. For overlayitems I am able to display shadows. How to show shadow for the text drawn?

View 4 Replies View Related

Android :: What Event Is Fired After All Views Are Fully Drawn?

Oct 16, 2010

I need to capture the absolute positions of some ImageViews to use as drop targets. I can't seem to find what event I need to put my code in to read the screen and get the Left(), Top() .. positions. I do not want monitor the inflation of each individual view. There must be some sort of onScreenFinsihed type of event, but I can't find it. onMeasure and onDraw seem to fire at the start of their work, I need to know when they are done.

View 1 Replies View Related







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