I am trying to define specific gray values in an image. In my application, I create empty bitmaps and generate different patterns on it afterwards(e.g. sinusodial 2D patterns with gray values from 0 - 255 or 0 -1).
In my pevious research I could only find this line of code, that was supposed to solve my poblem:
myBitmap.setPixel(x, y, Color.rgb(45, 127, 0));
But this only tells me how to work with colors, not with gray values.
Does anyone have an idea?
I don't know if there is a way to give an Android bitmap a backing store where each pixel is represented by one byte, but you certainly can set a pixel to gray by setting red, green, and blue values to the same:
int gray = 127; // 0-255
myBitmap.setPixel(x, y, Color.rgb(gray, gray, gray));