×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Jan 2007
    Posts
    20

    mutable Image vs immutable image

    hello friends,

    i have created a mutable image of the size 1920x160 pixels..

    but i want to remove the one particular color from the image. but when i do the getRGB for the mutable image it says "Out of Memory Error" ... ?

    My code goes as belows..

    Image mapImage = Image.createImage(1920, 160);
    int[] pixels = new int [mapImage.getWidth() * mapImage.getHeight()];
    System.out.println("pixelDataArr length -- > " + pixelDataArr.length);
    System.out.println(" free memory after : " + Runtime.getRuntime().freeMemory());
    mapImage.getRGB(pixels,0,mapImage.getWidth(),0,0,mapImage.getWidth(),mapImage.getHeight());
    for(int i=0;i<pixels.length;i++)
    {
    if(pixels[i]==0xFFFF00FF)
    {
    pixels[i]=0x00000000;
    }
    }

    //and then create the image with a transparent background
    //mapImage=Image.createRGBImage(pixels,mMapWidth << 4, 2 << 4,true);
    mapImage=Image.createRGBImage(pixels,mapImage.getWidth(),mapImage.getHeight(),true);

  2. #2
    Regular Contributor
    Join Date
    Aug 2006
    Posts
    307

    Re: mutable Image vs immutable image

    IMHO the "Out of Memory Error" is not related to mutable or immutable format of an image. Try to process image pixels in a smaller parts, specifying different regions on the image. You can also extract such small reagons by Image.createImage() methods, and process them on the RGB level.

    I guess this is the only way to decrease the amount of required memory. Also it would be a good choice to call System.gc() to free some memory at each processing step.

  3. #3
    Registered User
    Join Date
    Jan 2007
    Posts
    20

    Re: mutable Image vs immutable image

    yes you were right .. the issue is not of the images while debugging i figured out that creating the int array with this large size was giving the problem..

    one problem has come
    i was showing the large mutable image of the size 1920x160 pixels...
    but after creating it i want to remove the mauve color from it...
    so i need the pixel data right ?

    then how would i get the pixel data from the image cause there is only one method getRGB() where the parameter is int array which is not getting created as i believe 1920x160 = 302700 total pixels
    302700 * 4 (int size) = 1210800 which comes around 1182 KB..

    so please tell me
    * how can i cut the image in parts
    * remove the color from parts
    * and finally join the parts to create the image?

  4. #4
    Regular Contributor
    Join Date
    Aug 2006
    Posts
    307

    Re: mutable Image vs immutable image

    The full specification for the getRGB() method is Image.getRGB(int[] rgbData, int offset, int scanlength, int x, int y, int width, int height), which actually lets you to extract a portion of an image and process it on the RGB level (http://java.sun.com/javame/reference...dui/Image.html).

    The Image.createRGBImage(int[] rgb, int width, int height, boolean processAlpha) will let you to create an image object up on the processed RGB data.

    The created and processed small images could be then directly putted on a screen (for rendering the map), or stored in memory as objects. Unfortunatelly there are not ways to store Image object's data on the persistent storage in some format (like JPEG or PNG), so you'll have to deal with the restricted memory on device by processing potions of big image and working with rather smaller parts of it.

  5. #5
    Super Contributor
    Join Date
    Apr 2007
    Posts
    2,708

    Re: mutable Image vs immutable image

    hi Vijay,
    did you manage to get it working ?
    and if so, could you let me know how ?
    I am working on a very similar problem, and any input would be tremendously helpfull
    thanks

Similar Threads

  1. Opening a JPEG Image
    By ummarbhutta in forum Mobile Java Media (Graphics & Sounds)
    Replies: 8
    Last Post: 2007-02-15, 06:34
  2. how to cut some part of Image
    By mshouab in forum Mobile Java Media (Graphics & Sounds)
    Replies: 2
    Last Post: 2006-08-04, 09:05
  3. HELP: Mutable Image to Immutable Image?
    By rj_cybersilver in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2005-03-26, 09:58
  4. Nokia Image Converter
    By davidpurdie in forum General Development Questions
    Replies: 0
    Last Post: 2004-02-18, 15:31
  5. Mutable Immutable Images - Nokia correct rather than J2MEWTK
    By Nokia_Archive in forum Mobile Java General
    Replies: 0
    Last Post: 2002-05-27, 15: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
  •  
×