0

I have a bitmap without a background but when I try to draw it on surfaceview it gives it black color, is there a way to fix it?

enter image description here

Edit: here is the code I use:

this.Sprite=BitmapFactory.decodeResource(getResources(), R.drawable.sprites);
this.Sprite=Bitmap.createScaledBitmap(Sprite, Sprite.getWidth()*2, Sprite.getHeight()*2, false);
Sprite=changeImageColor(Sprite);

I load a sprite picture that has a background, after that I remove the background by the first pixel at 0,0 color

public Bitmap changeImageColor(Bitmap srcBmp) {

int width = srcBmp.getWidth();
int height = srcBmp.getHeight();
int color=srcBmp.getPixel(0, 0);
for (int row = 0; row < height; row++) {
    for (int col = 0; col < width; col++) {
        int pixel = srcBmp.getPixel(col, row);
        if(pixel==color){
            srcBmp.setPixel(col, row, Color.TRANSPARENT);
        }
    }
}

return srcBmp;}

(the background color of the image is blue and it becomes black so I believe it should worK)

        c.drawBitmap(src, Position.x,Position.y, null);

I draw it like that after changing it size and cutting it.

SpoocyCrep
  • 604
  • 7
  • 23
  • Could you post some code ? Basically showing how you load the bitmap. I suspect something with it. Thank you. – Kevin LE GOFF Feb 13 '15 at 16:34
  • Could you try to change the Color.Transparent with the color of your background ? I am not sure that setting the Color to transparent mean it will show your background color. But it might be showing the surfaceview default background which is probably black ;) – Kevin LE GOFF Feb 13 '15 at 17:27
  • 1
    check http://stackoverflow.com/questions/7293961/android-transparent-canvas-surfaceview – CSmith Feb 13 '15 at 18:55

0 Answers0