如何在android中将图像格式从JPEG更改为PNG?
我通过传递意图来打开默认的 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 (){....}
谢谢 斯内哈
I am opening the default android device camera by passing an intent. So when an image is captured, by default, camera stores it in JPEG format. But I don't want to store them in lossy format. I want picture quality to be high. So how can i store it in PNG format?...
here goes my code to open camera :
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);
Then handle onActivutyForResult (){....}
Thanks
Sneha
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我还没有找到任何方法可以让相机将文件保存为
PNG
。但是您可以将
JPEG
图像转换为PNG
格式。请注意,这不会提高质量。您无法“增加”图像中的信息。这只会改变图像格式。
I haven't come across any method to make the camera save the file as
PNG
.But you could convert the
JPEG
Image intoPNG
format.Note, this won't enhance the quality. You cannot "increase" the information in an image. This will only change the Image Format.