![](/img/trans.png)
[英]How to save jpeg Image file size after read--rotate-write operations in Java?
[英]How to save an encoded jpeg image to file in Java BlackBerry
我正在为BlackBerry开发一个应用程序,以使用相机拍摄图像。 我几乎拥有所有必需的代码,但是我想知道如何将编码的jpeg图像保存到SD卡。 图像使用EncodedImage.createEncodedImage()函数进行编码。
您将需要获取图像的字节,然后使用OutputStream将其写入磁盘。 像这样
FileConnection imageFile = null;;
byte[] rawData = encodedImage.getData();
try{
//You can change the folder location on the SD card if you want
imageFile = (FileConnection) Connector.open("file:///SDCard/BlackBerry/images"+filename);
if(!imageFile.exists()){
imageFile.create();
}
//Write raw data
OutputStream outStream = imageFile.openOutputStream();
outStream.write(rawData);
outStream.close();
imageFile.close();
} catch(IOException ioe){
//handle exception
} finally {
try{
if(imageFile != null){
imageFile.close();
}
} catch(IOException ioe){
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.