我正在通过传递一个意图来打开默认的android设备摄像头。因此,当捕捉到图像时,默认情况下,相机会将其存储为JPEG格式。但我不想以有损格式存储它们。我想要高质量的图像。那么如何将其存储为PNG格式呢?
下面是我打开摄像头的代码:
Date dt = new Date();
int date=dt.getDate();
int hours = dt.getHours();
int minutes = dt.getMinutes();
int seconds = dt.getSeconds();
String curTime = date+"_"+hours + "_"+minutes + "_"+ seconds;
_path=Environment.getExternalStorageDirectory() +"/"+curTime+".jpg";
File file = new File( _path );
Uri outputFileUri = Uri.fromFile( file );
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE );
intent.putExtra( MediaStore.EXTRA_OUTPUT, outputFileUri );
context.startActivityForResult(intent,0); 然后处理onActivutyForResult (){....}
谢谢Sneha
发布于 2011-12-12 21:07:59
我还没有找到任何方法来让相机将文件保存为PNG。
但是您可以将JPEG图像转换为PNG格式。
try {
FileOutputStream out = new FileOutputStream(filename);
bmp.compress(Bitmap.CompressFormat.PNG, 100, out); //100-best quality
out.close();
} catch (Exception e) {
e.printStackTrace();
}注意,这不会提高质量。您不能“增加”图像中的信息。这只会更改图像格式。
https://stackoverflow.com/questions/8474032
复制相似问题