You Are Here:

Community: Developer Discussion Boards

#1 Old mutable Image vs immutable image - 2007-09-11, 15:08

Join Date: Jan 2007
Posts: 19
vijay.chaudhari
Offline
Registered User
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);
Reply With Quote

#2 Old Re: mutable Image vs immutable image - 2007-09-12, 08:31

Join Date: Aug 2006
Posts: 307
axs
Offline
Regular Contributor
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.
Reply With Quote

#3 Old Re: mutable Image vs immutable image - 2007-09-13, 09:06

Join Date: Jan 2007
Posts: 19
vijay.chaudhari
Offline
Registered User
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?
Reply With Quote

#4 Old Re: mutable Image vs immutable image - 2007-09-13, 09:32

Join Date: Aug 2006
Posts: 307
axs
Offline
Regular Contributor
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.
Reply With Quote

#5 Old Re: mutable Image vs immutable image - 2007-09-27, 12:47

Join Date: Apr 2007
Posts: 1,757
Tiger79's Avatar
Tiger79
Offline
Forum Nokia Champion
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 With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

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

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
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

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomE2fforumE2fshowthreadE2ephpE3ftE3d18645X qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE44iscussionQ qdcZtypeQUqfntypeZE44iscussionContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZentertainmentQ qfnZtopicQUqfnTopicZj2meQ qfnZtopicQUqfnTopicZjavaQ qfnZtopicQUqfnTopicZmediaQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE44iscussionQ qfnZtypeQUqfntypeZE44iscussionContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE44iscussionQ qrdfZtypeQUqfntypeZE44iscussionContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ