×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    Registered User
    Join Date
    Dec 2008
    Posts
    40

    How to set blue color into white?

    Hi guys, I wanna set blue color of an image into white.
    I use image.getRGB to get rgb value. Then I get blue value with code like this:

    blue[i] = (int) (rgbData[i] & 0xFF);

    Now I wanna set blue[i] into white colour.
    Could u help me? I wanna have a grayscale image.
    Thanks before.
    Going to Reach UnreachableThing

  2. #2
    Super Contributor
    Join Date
    Sep 2008
    Location
    Noida, U.P.
    Posts
    1,330

    Thumbs up Re: How to set blue color into white?

    SAMPLE CODE TO CALL replaceRGB()
    Code:
    int rgb[]=new int[(img.getWidth()*img.getHeight())];
            img.getRGB(rgb, 0, img.getWidth(), 0, 0, img.getWidth(), img.getHeight());
            System.out.println("img length in int : "+rgb.length);
            rgb=replaceRGB(rgb,0xFF0000FF,0xFF000000);
            Image img = Image.createImage(rgb, img.getWidth(), img.getHeight(), false);

    HOW TO CONVERT COLOUR:

    Code:
     public int[] replaceRGB(int[] org,int oldColor,int newColor) {
            System.out.println("oldColor newColor : "+oldColor+" , "+newColor);
            int tmp[]= new int[org.length],count=0;
            while(count<org.length) {
               
                if(org[count] == oldColor) {
                    tmp[count]= newColor;
                }else
                    tmp[count]=org[count];
                 System.out.print(org[count]+" , ");
                count++;
            }
            return tmp;
        }
    check out this.
    thanks,
    jitu_goldie..

    KEEP TRYING..

  3. #3
    Regular Contributor
    Join Date
    Apr 2009
    Posts
    89

    Re: How to set blue color into white?

    Hi,

    Wrong Line..
    Image img = Image.createImage(rgb, img.getWidth(), img.getHeight(), false);
    Use this
    Image img = Image.createRGBImage(rgb, img.getWidth(), img.getHeight(), false);
    Thanks
    Osam

  4. #4
    Regular Contributor
    Join Date
    Apr 2009
    Posts
    89

    Re: How to set blue color into white?

    Hi,

    Can u tell me you want to change the Color of whole image or u want to change the color specific portion of the image.
    I have a code to change the color of whole image. If u need this then i will send u

    Let me know after that i can help u..

    Thanks
    Osam

  5. #5
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: How to set blue color into white?

    There's some sample code for converting an image to greyscale.

  6. #6
    Regular Contributor
    Join Date
    Apr 2009
    Posts
    89

    Re: How to set blue color into white?

    Hi,

    Go for the given link, it help u lot

    http://wiki.forum.nokia.com/index.ph..._Sprites_Color

    Thanks
    Osam

  7. #7
    Registered User
    Join Date
    Dec 2008
    Posts
    40

    Re: How to set blue color into white?

    Quote Originally Posted by Osam View Post
    Hi,

    Can u tell me you want to change the Color of whole image or u want to change the color specific portion of the image.
    I have a code to change the color of whole image. If u need this then i will send u

    Let me know after that i can help u..

    Thanks
    Osam
    hi Osam. Thanks for ur reply. I just wanna change specific color in my image. And thanks for ur help.
    Going to Reach UnreachableThing

  8. #8
    Super Contributor
    Join Date
    Sep 2008
    Location
    Noida, U.P.
    Posts
    1,330

    Thumbs up Re: How to set blue color into white?

    Quote Originally Posted by huriniin View Post
    hi Osam. Thanks for ur reply. I just wanna change specific color in my image. And thanks for ur help.
    checkout my first reply to u. Its have a method which changes the specific colour specified by u.
    thanks,
    jitu_goldie..

    KEEP TRYING..

  9. #9
    Regular Contributor
    Join Date
    Apr 2009
    Posts
    89

    Re: How to set blue color into white?

    Hello Huriniin,

    Your problem is solved or still there,the link i given u have a solution for your probelm.
    Let me know your problem is solved or not.


    Thanks
    Osam

  10. #10
    Registered User
    Join Date
    Dec 2008
    Posts
    40

    Re: How to set blue color into white?

    Thank you guys 4 all ur replies

    But, the real problem still exist.
    I save blue pixel value into rms(just blue).
    Then I call it back to create an Image. The image becomes blue.
    That I wanna make is change the blue color(when the value is 0) into white color.
    How I can do this?
    Going to Reach UnreachableThing

  11. #11
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: How to set blue color into white?

    So... you want to extract the blue channel, and create a grey scale image just from that data?

    Code:
    blue &= 0xff;
    int grey = 0xff000000 | (blue << 16) | (blue << 8) | blue;
    (assuming "blue" is an int).

    The "0xff000000" is to make sure that the alpha channel is set to fully-opaque.

    Graham.

  12. #12
    Registered User
    Join Date
    Dec 2008
    Posts
    40

    Re: How to set blue color into white?

    Quote Originally Posted by grahamhughes View Post
    So... you want to extract the blue channel, and create a grey scale image just from that data?

    Code:
    blue &= 0xff;
    int grey = 0xff000000 | (blue << 16) | (blue << 8) | blue;
    (assuming "blue" is an int).

    The "0xff000000" is to make sure that the alpha channel is set to fully-opaque.

    Graham.
    I've tried, but why the color change into blue at all? I just wanna change it into white when the color of blue pixel < 128.
    Take a look at my code please:

    intblue[i] = (int) (rgbData[i] & 0xFF);
    int grey[i] = 0xff000000 | (intblue[i] << 16) | (intblue[i] << 8) | intblue[i];
    if(grey[i] > 128)
    grey[i] = 255;
    else
    grey[i] = 0;

    What's wrong?
    Going to Reach UnreachableThing

  13. #13
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: How to set blue color into white?

    You're looking at the "grey" value (which is a complete ARGB pixel), not at the blue value.

    Also, "255" is not white. White is 0xffffffff.

  14. #14
    Registered User
    Join Date
    Dec 2008
    Posts
    40

    Re: How to set blue color into white?

    hi grahamhughes,
    You gave me this code

    intblue[i] = (int) (rgbData[i] & 0xFF);

    to grab blue pixel value.

    Now, I wanna change that blue into grayscale.
    I'm trying to clear my problem. It's hard to explain at first. Sorry guys.
    Going to Reach UnreachableThing

  15. #15
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: How to set blue color into white?

    Yes, and I gave you the code to convert that to a grey scale.

    But, then you want to convert it to white??

Similar Threads

  1. Replies: 16
    Last Post: 2008-03-10, 05:30
  2. How to set SubCell Colour in CAknGrid
    By mobile_don in forum Symbian User Interface
    Replies: 0
    Last Post: 2007-11-29, 11:35
  3. set api in location acquisition api
    By sravikantk2 in forum Symbian
    Replies: 0
    Last Post: 2007-05-22, 17:09
  4. In S60 3rd, CEikGlobalTextEditor::SetExtent can't set the control's size.
    By Shen Tianping in forum Symbian User Interface
    Replies: 5
    Last Post: 2007-05-16, 08:27
  5. How to set skin colors to CEikonEnv?
    By kasuga in forum Symbian
    Replies: 0
    Last Post: 2007-04-13, 00:06

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×