×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Jun 2008
    Posts
    15

    Image.getRGB() problem

    I am having a serious problem with the Image.getRGB() method.

    Suppose I have a specific ARGB byte array and I create an image of it. The thing is when I try to obtain the ARGB array of the new image again using the getRGB() method, the resulting array is not exactly the previous one which I just made the image based on! There are slightly differences between the two arrays. In this example according to my observation one bit of the all red and green and blue bytes have changed, mostly the alpha byte without any changes.

    I read the J2ME Image.getRGB() API which says:
    "The returned values are not guaranteed to be identical to values from the original source, such as from createRGBImage or from a PNG image. Color values may be resampled to reflect the display capabilities of the device (for example, red, green or blue pixels may all be represented by the same gray value on a grayscale device). "

    I desperately need your help how to overcome this problem. I just need the original RGB!!
    Please do reply anyone who has a solution!

  2. #2
    Nokia Developer Champion
    Join Date
    Nov 2007
    Location
    Rome, Italy
    Posts
    2,405

    Re: Image.getRGB() problem

    Hi daregazi,

    as you've read from getRGB() JavaDocs, that is the exact behaviour of this method. To get precise pixel color informations, afaik, there's no other way than implementing your image decoder (for the formats you need).. or search for existing ones (but I'm not aware of any Java ME ones)

    Pit

  3. #3
    Registered User
    Join Date
    Jun 2008
    Posts
    15

    Re: Image.getRGB() problem

    thanks Jappit,

    As you said I have had looked at a PNG decoder in J2SE, do you think if I try to adapt it to J2ME and replace the getRaster() method correspondingly with getRGB(), my problem will be solved?
    My concern is even having a specific png decoder, I still need to use the same method getRGB(), and it would return the RGB array arbitrarily!!!

    What do you think?
    cheers

  4. #4
    Nokia Developer Champion
    Join Date
    Nov 2007
    Location
    Rome, Italy
    Posts
    2,405

    Re: Image.getRGB() problem

    If you manage to manually read/decode your PNG image with a custom image decoder, then you should have total access to all PNG informations, so also original colors information should be available.

    Pit

    Edit: obviously, your PNG decoder should not give you back a javax.microedition.lcdui.Image instance, since you would fall back in the previous case, so having the getRGB() method returning the "adapted" color values. Your custom decoder should instead return you a custom object, from which you can easily retrieve the PNG informations you need.
    Last edited by jappit; 2008-06-27 at 14:47. Reason: Clarification

Similar Threads

  1. Problem with eglSwapBuffers and heap corruption
    By greatape in forum Symbian Media (Closed)
    Replies: 2
    Last Post: 2007-05-24, 03:35
  2. netcards - Problem with opening adapter
    By kernj in forum Symbian Tools & SDKs
    Replies: 5
    Last Post: 2007-01-10, 08:56
  3. WAP service problem on Apache
    By bigg_o in forum Browsing and Mark-ups
    Replies: 3
    Last Post: 2005-04-17, 16:05
  4. Problem: S60 SDK for CW in PC with .NET
    By anttij in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 1
    Last Post: 2005-02-28, 11:36
  5. wireless problem
    By sash_mca in forum Mobile Web Site Development
    Replies: 0
    Last Post: 2003-06-06, 11:34

Posting Permissions

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