| Reply | « Previous Thread | Next Thread » |
|
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); |
| vijay.chaudhari |
| View Public Profile |
| Find all posts by vijay.chaudhari |
|
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. |
|
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? |
| vijay.chaudhari |
| View Public Profile |
| Find all posts by vijay.chaudhari |
|
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. |
|
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 |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| Opening a JPEG Image | ummarbhutta | Mobile Java Media (Graphics & Sounds) | 8 | 2007-02-15 07:34 |
| how to cut some part of Image | mshouab | Mobile Java Media (Graphics & Sounds) | 2 | 2006-08-04 10:05 |
| HELP: Mutable Image to Immutable Image? | rj_cybersilver | Mobile Java Media (Graphics & Sounds) | 1 | 2005-03-26 10:58 |
| Nokia Image Converter | davidpurdie | General Discussion | 0 | 2004-02-18 16:31 |
| Mutable Immutable Images - Nokia correct rather than J2MEWTK | Nokia_Archive | Mobile Java General | 0 | 2002-05-27 16:06 |