java - how to read RGB Data from png in j2me -


hey have using j2me read image

i want process on image darkenes , lightens

i read image input stream

        inputstream istrm = getclass().getresourceasstream("/earth.png");          bytearrayoutputstream bstrm = new bytearrayoutputstream();         int ch;    while ((ch = istrm.read()) != -1){     bstrm.write(ch);       byte imagedata[] = bstrm.tobytearray();    image im = image.createimage(imagedata, 0, imagedata.length); 

how can rgb values or how can add values array of pixles
imagedata[] can more lightens or darkness ,

is there header data including in input stream had read , cause me error when iam adding values ?

i think should able following:

int width = im.getwidth(); int height = im.getheight(); int[] rgbdata = new int[width*height]; // since working rgba  im.getrgb(rgbdata, 0, width, 0, 0, width, height);  // now, data stored in each integer 0xaarrggbb,  // high-order bits alpha channel each integer 

now, if want put them 3 arrays, 1 each channel, following:

int red[][] = new int[width][height]; int green[][] = new int[width][height]; int blue[][] = new int[width][height];  (int = 0; < width; i++) {   (int j = 0; j < height; j++)   {     red[i][j] = rgb[i*width + j] & 0xff0000;     green[i][j] = rgb[i*width + j] & 0xff00;     blue[i][j] = rgb[i+width + j] & 0xff;   } } 

Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -