Erase a part of a bitmap

Tutorials concerning the OpenGL® ES cross-platform API for full-function 2D and 3D graphics on the Google-Android platform.

Erase a part of a bitmap

Postby Thej0sepH » Tue Aug 25, 2009 7:20 pm

Hello people, i need to find the way to erase pixels from a bitmap using Canvas without dropping your FPS to 0.
I Tried to draw a circle using bitmap.setPixel(x,y,Color.Transparent)
But i get like 1 second lag after a little 50 pixels radius circle is erased from the bigger bitmap.
Have someone found any method?
By the way ive already tried to create a new Canvas(BitmapIneedtoErase) and use the .drawCircle method, it works with any color but no transparent.

This is the code im using right now.
Code: Select all
                   int c = 0;      
      int d = 0;
      float contanteAngulo = 360;
      float angulin = 0;   
while(c<360){            
               angulin=(float)(contanteAngulo/360*c);
            
               float piX = (float)(posX+mapa.getPosX());
               float piY = (float)(posY+mapa.getPosY());
               float pfX = (float)(piX+(tankcito.getBunge())*Math.cos(angulin/180*Math.PI));
               float pfY = (float)(piY+(tankcito.getBunge())*Math.sin(angulin/180*Math.PI));
                 float distanciaX = pfX - piX;
                 float distanciaY = pfY - piY;   
                 float cx = piX;
                 float cy = piY;
                 d=0;
                
                  while(d<tankcito.getBunge()){
                     if(mapa.getSobremapa().getPixel((int)(cx-mapa.getPosX()),(int)(cy-mapa.getPosY()))==0 ){
                     
                     }
                     else{
                     mapa.getSobremapa().setPixel((int)(cx-mapa.getPosX()),(int)(cy-mapa.getPosY()),0);                             
               
                     }
                     cx=cx+distanciaX/tankcito.getBunge();
                  cy=cy+distanciaY/tankcito.getBunge();
                   d=d+1;
            
            
            }
                 c = c+1;
            }


I really need to find a solution soon thank to everybody who tries to help.
Greetings
Thej0sepH
Freshman
Freshman
 
Posts: 3
Joined: Thu Apr 02, 2009 5:47 am

Top

Return to Android 2D/3D Graphics - OpenGL Tutorials

Who is online

Users browsing this forum: No registered users and 2 guests