Hi All,
I am newbie in Mobile Java. In my application i want click a photo,save the image and then send the image to a webservice as base64 binary.
The webservice accepts images in PNG, GIF, JPEG, BMP.
I have taken a snapshot of the image and tried to save it as jpeg as follows
But the image created is of 0B and cannot be opened.Code:private void saveImageToMobile(Image aImage) { try { final FileConnection fc = (FileConnection) Connector.open("file:///c:/Data/Images/a.jpg"); if(!fc.exists()) { fc.create(); final OutputStream out; out = fc.openOutputStream(); //Create MediaProcessor for raw Image final MediaProcessor mediaProc = GlobalManager.createMediaProcessor("image/raw"); //Get control over the format ImageFormatControl formatControl = (ImageFormatControl) mediaProc.getControl("javax.microedition.amms.control.ImageFormatControl"); //Set necessary format formatControl.setFormat("image/jpeg"); mediaProc.setInput(aImage); mediaProc.setOutput(out); mediaProc.start(); mediaProc.addMediaProcessorListener(new MediaProcessorListener() { public void mediaProcessorUpdate(MediaProcessor mp, String string, Object o) { if(mediaProc.getState()==mediaProc.STOPPED){ try { out.flush(); out.close(); fc.close(); } catch (IOException ex) { ex.printStackTrace(); } } } }); } } catch(Exception e) { e.printStackTrace(); } }
I checked various posts on this subject but could not find any right pointers.
Also instead of saving this in a image can i send the raw image.What is the format of the raw image.Is it going to .bmp??
Regards
Biju

Reply With Quote


