圖像保存在本地在application.I想挽救J2ME應用程序 圖像電話memory.Is有任何編碼器或轉換字節數組?如何保存呢?請幫助我....在j2me中如何將圖像保存在手機內存中以保存s40?
try {
String url=System.getProperty("fileconn.dir.photos")+"model0_0.jpg";
FileConnection fc=(FileConnection)Connector.open(url,Connector.READ_WRITE);
if(!fc.exists()) {
fc.create();
}else {
// return;
}
OutputStream os=fc.openOutputStream();
int iw=galleryImage.getWidth();int ih=galleryImage.getHeight();
rawInt=new int[iw*ih];
galleryImage.getRGB(rawInt,0,iw,0,0,iw,ih);
ByteArrayOutputStream baos=new ByteArrayOutputStream();
for(int i=0;i<rawInt.length;i++)
baos.write(rawInt[i]);
byte byteData[]=baos.toByteArray();
baos.close();
ByteArrayInputStream b_stream=new ByteArrayInputStream(byteData);
int i=0;
/*while((i=b_stream.read())!=-1) {
os.write(i);
}*/
for(i=0;i<content.length;i++) {
os.write(b_stream.read());
}
//os.write(byteData);
os.flush();
os.close();
System.out.println("\n\nImage Copied..\n");
fc.close();
} catch (IOException e) {
//System.out.println("image not read for gallery");
e.printStackTrace();
}
catch(java.lang.IllegalArgumentException iae){iae.printStackTrace();}
catch(Exception e){e.printStackTrace();}
我試過這個code.When一個Unformatted文件存儲在defaut圖像文件夾中。那個文件大小是0.0KB.I認爲,圖像不被讀取............
嘗試在E:中保存圖像,E:是諾基亞設備中手機的SD卡。 – Lucifer
謝謝,我明白了。請通過鏈接https://github.com/Pash237/j2me-JPEG-library並下載com文件夾文件,並導入我的應用程序,並改變了幾行。它的工作很好....... – ranjith