I use the following code with the intention to create an image that's half white and half black and put it on a button. What's wrong with my code? (latter we want to use a more complicated logic about what pixels are white and what are black but it should still be black and white)
int height = 100;
int width = 100;
quadratImage = Bitmap.createBitmap(
width,
height,
Bitmap.Config.ALPHA_8);
for (int x = 0; x < width; x++){
for (int y = 0; y < height; y++){
int color;
if (x< 50){
color = R.color.black;
}
else{
color = R.color.white;
}
quadratImage.setPixel(
x, y, color);
}
}
quadratImage.prepareToDraw();
imageButton.setImageBitmap(quadratImage);
My colors are defined as:
<color name="black">#000000</color>
<color name="white">#ffffff</color>