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;
            }
            else
            {
               planet1 = y;
            }
       }

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

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!

Glad it worked out for you :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.