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