Hello. I have a grayscale image that i want to process. I take the raster and then i want to scan the pixels and once i find a non-black pixel, i want to make an operetion(which doesn't matter right now). When i have an ARGB image i do this

int[] sample = new int[4];
int[] sample2 = new int[4];

for(int y = centery; y<50; y++)
            sample2 = raster.getPixel(centerx,y, sample);
            if (sample2[0] == 0)
               planet1 = 1;
               planet1 = y;

What should i do in case of a grayscale image? Thanx a lot in advance.

Edited by mike_2000_17: Fixed formatting

9 Years
Discussion Span
Last Post by Ezzaral

Another thing i though that it would be useful is to convert the gray scale image (i mean TYPE_BYTE_GRAY) to TYPE_INT_ARGB. How can i do that because the way i do it , seems to be incorrect. Thanx


You may be able to get the 0-255 grayscale value like this

int grayVal = ((int) sample2[0]) & 0xff;

(I haven't worked with it myself, but some reading suggests that might work for you.)


Thanks a lot man. It seems to do the work i need!! You have plenty of knowledge!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.