Results 1 to 2 of 2
Thread: Loading large images in JavaME
- 04-01-2009, 05:49 AM #1
Member
- Join Date
- Apr 2009
- Posts
- 1
- Rep Power
- 0
Loading large images in JavaME
Hi Everybody, Long time fan, first time caller. :D I didn't find anything in my search and hope that I have posted my question to the right place.
I am hoping someone could help me determine how to display large image files without popping the memory when loading them. At risk of stating the obvious:rolleyes:, when I say popping the memory I mean getting a java.lang.OutOfMemoryError exception.
So far when attempting to display images taken with an internal camera I have tried to use the MediaProcessor and ImageTransformControl however this method throws the aforementioned exception on the mediaProcessor.setInput() call with a large InputStream:
Java Code:FileConnection fc = (FileConnection)Connector.open(fileName); InputStream src = fc.openInputStream(); MediaProcessor mp = null; try { mp = GlobalManager.createMediaProcessor(image/jpeg); mp.setInput(src, MediaProcessor.UNKNOWN); //POP! ByteArrayOutputStream bos = new ByteArrayOutputStream(); mp.setOutput(bos); ImageTransformControl fc = (ImageTransformControl)mp.getControl( javax.microedition.amms.control.imageeffect.ImageTransformControl); fc.setEnforced(true); fc.setEnabled(true); mp.complete(); ... return Image.createImage(bos.toByteArray(), 0, bos.size());
Java Code:... byte[] data = new byte[chunkSize]; do { int length = fis.read(data, 0, chunkSize); Image img = Image.createImage(data, 0, chunkSize); ...
Open to suggestions,
-B
- 04-01-2009, 12:02 PM #2
Similar Threads
-
Displaying large images
By pir8ped in forum AWT / SwingReplies: 2Last Post: 01-21-2009, 10:20 PM -
JavaMe and native application interoperability
By islamfunny in forum CLDC and MIDPReplies: 1Last Post: 10-27-2008, 10:58 PM -
Loading images in seperate packages?
By Bibendum in forum New To JavaReplies: 0Last Post: 03-02-2008, 11:43 PM -
Loading Images - Imp
By Thulasiraman in forum Advanced JavaReplies: 0Last Post: 01-28-2008, 10:33 AM
Bookmarks