从 SD 卡获取图像,压缩它,然后将其保存回 SD?
我正在尝试从相机捕获图像,如果图像太大,我想压缩位图并将其发送回 SD 卡。我最初尝试将图像直接拉入内部存储器,但显然根据我之前问题的答案我可以做到这一点: Android 照片以非常小的尺寸拍摄
我怎样才能将该图像文件带回到我的应用程序内存中?
Im trying to capture an image from the camera, and if its too big i want to compress the bitmap and send it back to the sd card. I initially tried to pull the image directly into internal memory but apparently according to this answer to my previous question i can do that: android picture from camera being taken at a really small size
How could I bring that image file back into my apps internal memory?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用下面的代码重新缩放图像。
这会将您的图像压缩为更小的尺寸,您只需要根据您的要求提供新的高度和宽度。
You may rescale image using the code below.
This will compress your image to smaller size, you just have need to give new height and width as per your requirement.
单击按钮调用方法将图像保存到SD卡:
将图像保存到Sd卡:
从Sd卡获取图像:
用于存储图像到内部存储器:
从内部保存和读取位图/图像Android 中的内存
Onclick of button Call Method to Save your Image to SDcard:
Saving Image to SdCard:
For getting Image from SdCard:
For Storing Image to Internal Memory:
Saving and Reading Bitmaps/Images from Internal memory in Android
从相机获得的图像已经被压缩为 jpeg 格式。您永远不会从相机获得原始图像。
The image that you get from the camera is already compressed in the jpeg format. You will never get a raw image from the camera.