Greetings Everyone, I have been posting over at the official forum for awhile and find that... it's not much help (trying not to offend anyone here on my first post). I recognize a few names over here and am positive this will be a better experience. So without further ado.
Has anyone had any experience with the javax.microedition.amms.MediaProcessor? (jsr234) I am attempting to use the processor for the MIME types "image/jpg" or "image/raw". The following code illustrates the two alternative code paths:
private Image resizeImage(InputStream src) {
MediaProcessor mp = null;
ByteArrayOutputStream bos = null;
try {
mp = GlobalManager.createMediaProcessor("image/jpeg");
mp.setInput(src, MediaProcessor.UNKNOWN);// or set the size of the InputStream
/*Alternative path for above using "raw/image"
* private Image resizeImage(Image srcImg){
* MediaProcessor mp = null;
* ByteArrayOutputStream bos = null;
* try {
* mp = GlobalManager.createMediaProcessor("image/raw");
* mp.setInput(srcImg);
*/
log.log("mp input set.");
bos = new ByteArrayOutputStream();
mp.setOutput(bos);
// Tries to instantiate the ImageTransformControl. If not supported it returns null.
ImageTransformControl transformCtl = (ImageTransformControl) mp.getControl("javax.microedition.amms.control.imageeffect.ImageTransformControl");
//set output size
transformCtl.setTargetSize(displayImgWidth, displayImgHeight, 0);
transformCtl.setEnforced(true);
transformCtl.setEnabled(true);
// Do the actual processing. If you do not want to use a blocking call,
// use start() and MediaProcessorListener.
mp.complete();
log.log("completed without exception");
} catch (MediaException e) {
log.log("MediaException: " + e);
} catch (Exception e) {
System.out.println("Exception(): " + e);
} finally {
if(bos.size() == 0){
log.log("bos returned empty");
}
return Image.createImage(bos.toByteArray(), 0, bos.size());
}
}
I have spent several hours in this routine and have found it not very consistent, It's testing the very patience of my soul. :

I would ditch it if it weren't for the performance. I find that some Stream/Images are handled fine but for some unapparent reason others are not, in which case the after the setInput() method the remaining code is never executed and the OutputStream (bos) size in the finally block is zero yet an exception is never caught/thrown.

This seems to happen every time with an image captured by the phone.
Any insight is appreciated. -thanks!