在 Eclipse 中,我从模拟器中捕获了图像,并将格式保存为 JPEG。但我想将图像格式保存为 PNG。如何将图像格式从 JPEG 转换为 PNG。
在这里,我使用此代码将图像保存在目录中。
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyymmddhhmmss");
String date = dateFormat.format(new Date());
String photoFile = "Picture_" + date + ".PNG";
// String photoFile = "Picture_" + date + ".JPEG";
String filename = pictureFileDir.getPath() + File.separator + photoFile;
File pictureFile = new File(filename);
try {
FileOutputStream fos = new FileOutputStream(pictureFile);
fos.write(data);
fos.close();
Toast.makeText(context, "New Image saved:" + photoFile,
Toast.LENGTH_LONG).show();
} catch (Exception error) {
//Log.d(IntersaActivity.DEBUG_TAG, "File" + filename + "not saved: "+ error.getMessage());
Toast.makeText(context, "Image could not be saved.",
Toast.LENGTH_LONG).show();
}
提前致谢。