want to draw over a changing solid-color background

by Rob Y. » Fri, 23 Apr 2010 10:56:32 GMT


Sponsored Links
 I'm trying to draw an animated picture over a background that I want
to shift gradually in color.

The picture is kept in a bitmap, and on each frame, I erase the
background to the new background color and then draw the bitmap on top
of it.  The bitmap was originally cleared to Color.TRANSPARENT, and
that works.  I can see the background color.  But as I animate my
image, each pixel in the bitmap that I 'erase' to Color.TRANSPARENT
seems to remain whatever color it originally was.  Eventually I just
end up with a big blob of color where the moving image should be.

Am I doing something wrong?  How come Color.TRANSPARENT results in
transparency when I use it to drawColor to my bitmap canvas, but not
when I draw with a Color.TRANSPARENT paint to the same canvas?

--



Other Threads

1. PendingIntent / addProximityAlert problem

Hello,
i have some questions about the addProximityAlert function.
My task is to develop an android navigation application. The app reads
some gps point out of a gpx-file.
Thats not really a problem. If the handy is near the point, the app
shall notify me this. So i used the addProximityAlert function:

setProximityAlert () {
..
double lati = lat[arrayindex]; //the saved gps data
double lng = lon[arrayindex];
expiration=-1;
..
Intent intent = new Intent(TREASURE_PROXIMITY_ALERT);
proximityIntent = PendingIntent.getBroadcast(getApplicationContext(),
0, intent, 0);
lm.addProximityAlert(lati, lng, radius, expiration, proximityIntent);
IntentFilter filter = new IntentFilter(TREASURE_PROXIMITY_ALERT);
registerReceiver(new ProximityIntentReceiver(), filter);
}

public class ProximityIntentReceiver extends BroadcastReceiver
{
          public void onReceive (Context context, Intent intent) {
            String key = LocationManager.KEY_PROXIMITY_ENTERING;
            entering = intent.getBooleanExtra(key, false);
            if (entering)
                arrayindex++;
            //lm.removeProximityAlert(proximityIntent);
          }

The setProximityAlert () function is called if the position has
changed.

I develop the app with the emulator and Android SDK 1.5. I use the
console with geo fix commands to simulate gps data.

If you can see in this lines of code, I use an arrayIndex. I've save
all gps data of the gpx file in an array. If the handy is near the
first point, the ProximityAlert notify, that the handy enters this
position.
My problem is, that sometimes the ProximityAlert fires only one time,
sometimes 3 times or more.
I think the problem is the expiration time? But if I took a value like
2000 (2sec), the proximityAlert only works for 2 seconds?!

A solution can be, that I use multiple proximityIntents variables, so
that I save all proximityAlerts with addProximityAlert function only
once. But if I than enters the position of the third gps point before
the second or first point, the ProximityAlert will fire, but it
shouldn't before them!
What can I do? Must I implement a subactivity, which starts when I
entered the first position, than raise a counter and go back into the
main activity? I think the problem will be the same?

Greets,
Stefan

PS: I'm german, so apologize some mistakes. And this project is my
first in the Android world. So i'm not an expert..

--~--~---------~--~----~------------~-------~--~----~

2. PendingIntent ProximityAlert problem

Hi,
I have a problem with the proximityAlert function. I develop a
navigation software, which reads some gps data out of a gpx file.
Then I write the first gps point in the addProximityAlert function.
When I get near this point, I want to raise an index to get the next
position from the gpx file (I save all positions in an array). But
some times the ProximityAlert fires one time (fine!), but sometimes it
fires 3 times or more? I think thats a problem with the expiration
time. I choose -1 (never expire). But if I took a value like 2000 (2
seconds), the alert fire only, if i reach the position in the next 2
seconds?
I have try to use the removeProximityAlert function (I have a global
PendingIntent variable therefore).
But then it fires instead of 3 times 6 times?!
I have also test to use multiple PendingInten variables and add them
all with the addProximityAlert function. But then the ProximityAlert
of the third point can fire before the first or second point?!
Here is a part of my code:

private void setProximityAlert() { //will call every time the
location changed

double lati = lat[arrayindex];
double lng = lon[arrayindex];
float radius = 10000f; //meters
long expiration = -1; //-1 fr "not expire"

Intent intent = new Intent(TREASURE_PROXIMITY_ALERT);
proximityIntent = PendingIntent.getBroadcast
(getApplicationContext(), 0, intent, 0);
lm.addProximityAlert(lati, lng, radius, expiration,
proximityIntent);
IntentFilter filter = new IntentFilter
(TREASURE_PROXIMITY_ALERT);
registerReceiver(new ProximityIntentReceiver(), filter);
}

/** Proximity Alert Broadcast Receiver */
public class ProximityIntentReceiver extends BroadcastReceiver
{
@Override
public void onReceive (Context context, Intent intent) {
String key = LocationManager.KEY_PROXIMITY_ENTERING;
entering = intent.getBooleanExtra(key, false);
if (entering)
arrayindex++;
entering = false;
//lm.removeProximityAlert(proximityIntent);
}
}

I hope that I discribe my problem well enough. I'm german, so
apologize some mistakes with the english syntax.

Greets,
Stefan

--~--~---------~--~----~------------~-------~--~----~

3. Add space between elements in a TableRow.

4. Some G1 phones getting "device not found" with adb...

5. Date.getTime() and Daylight Saving Time?

6. Bitmap in GLSurfaceView

7. App Test Group