Hello all. The app I'm working gives the user the ability to open images from the phone to send using J2ME.
The problem is, when an image size is too large, the app throws an out of memory exception.
I'm opening the images using the File API.
A second method I tried usingCode:FileConnection fc = (FileConnection) Connector.open("file://localhost/" + currDirName + fileName); if (!fc.exists()) { throw new IOException("File does not exists"); } InputStream fis = fc.openInputStream(); Image im = Image.createImage(fis); fis.close();
I was wondering if there is any API that enables me to resize the image using the phone's memory, before loading it into my app?Code:FileConnection fc = (FileConnection) Connector.open("file://localhost/" + currDirName + fileName); if (!fc.exists()) { throw new IOException("File does not exists"); } InputStream fis = fc.openInputStream(); ByteArrayOutputStream file = new ByteArrayOutputStream(); int c; byte[] data = new byte[1024]; while ((c = fis.read(data)) != -1) { file.write(data, 0, c); } byte[] fileData = null; fileData = file.toByteArray(); fis.close(); fc.close(); file.close(); Image im = Image.createImage(fileData, 0, fileData.length);
Currently I have this temporarily solved by calling platformRequest(), but the problem is I can't alter the photo photo viewer UI to add a "send" command which would upload the image to the server. (even if it's still a large size)
I was wondering if there is a way to alter this?

Reply With Quote

