RGB from bitmap

by Andareena Vootog » Tue, 03 Nov 2009 06:05:20 GMT

Sponsored Links
        if you are using bitmap, use an integer array to store the bitmap.
use bitmap.getPixel() to get the corresponding bitmap in integer array. By
using bitwise rotation operation, we will get RGB values. (Also byte array
can be used). See the code below.

             int[] pix = new int[picw * pich];
            bitmap.getPixels(pix, 0, picw, 0, 0, picw, pich);

            int R, G, B,Y;

            for (int y = 0; y < pich; y++)
            for (int x = 0; x < picw; x++)
                int index = y * picw + x;
                int R = (pix[index] >> 16) & 0xff;     //bitwise shifting
                int G = (pix[index] >> 8) & 0xff;
                int B = pix[index] & 0xff;

                //R,G.B - Red, Green, Blue
                 //to restore the values after RGB modification, use //next
                pix[index] = 0xff000000 | (R << 16) | (G << 8) | B;

Thanks and Regards,

Andarena Vootog
Vootog Information Systems < http://www.vootog.com > Pvt Ltd.


RGB from bitmap

by Jeffrey Blattman » Tue, 03 Nov 2009 06:07:42 GMT

Other Threads

1. Question about adapters

I'm kind of at a loss of how to achieve this probably simple task. How
do I get the contents of a variable (say and int variable) to display
on the screen? I've collected that I have to use an adapter, but I
can't find a simple explanation of how to use them.

In one of the tutorials, they list this code:

ArrayAdapter adapter = ArrayAdapter.createFromResource(
            this, R.array.planets,

Problem is that I have no idea what a few things mean (like the use of
"this" and what items need to get in the parenthesis after
ArrayAdapter.createFromResource. If someone could refer me to a post
describing adapters and how to use them that would be great.

Also as a side question, if I need to transfer data from one view to
another, do I need to pass it using intents? And if so, how to I send/
read them?


2. Communicate between two threads

Hi all,

I am trying to create a ListView and ServerSocket, and display the IP
of each incoming connection on the ListView.

But I find out that create a ServerSocket and invoke the .accept()
method will block, and make the UI unresponsive, if I create the
socket in the same thread of the View.

So I created a new Class which implements the Runnable interface, and
create a ServerSocket there.

What is the best way now, to pass information (IP or client socket
object) between the two thread?

(so that I could update the ListView in thread one when new incoming
socket is accepted)

Thank you.


3. Please help me !

4. OpenCORE 2.04 bug in OMA1 passthru CPM plugin test

5. OpenCORE build error in Ubuntu 9.04

6. is there anything wrong with the function camera.takePicture()???

7. Problem running on 1.6 SDK.