Android 图像捕获在里程碑上节省小尺寸

发布于 2024-09-08 13:38:27 字数 554 浏览 1 评论 0原文

我编写了一个简单的应用程序,可以打开相机并提供保存任何捕获的图像的路径。

代码基本上如下所示:

File file = new File( Environment.getExternalStorage() + "myimages/",
"my_image.jpg" );

Uri outputUri = Uri.fromFile( file );

Intent intent = new
Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE );
Intent.putExtra( MediaStore.EXTRA_OUTPUT, outputUri );

这在我的 Droid 上完美运行。图像始终以 2592x1936 保存。然而,在 Milestone 上进行测试时,图像以小得多的尺寸保存,例如 320x240 和 1280 x 1900。使用 adb logcat,我可以看到图像尺寸在拍摄照片后立即设置。

似乎里程碑上有一个默认设置导致了这种行为。

任何帮助将不胜感激。

谢谢, 〜杰里米

I've written a simple app that opens the camera and supplies a path for saving any captured images.

The code basically looks like this:

File file = new File( Environment.getExternalStorage() + "myimages/",
"my_image.jpg" );

Uri outputUri = Uri.fromFile( file );

Intent intent = new
Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE );
Intent.putExtra( MediaStore.EXTRA_OUTPUT, outputUri );

This works perfectly on my Droid. Images are consistently saved at 2592x1936. However, when testing on the Milestone, the images are saved at much smaller sizes such as 320x240 and 1280 x 1900. Using adb logcat, I can see that the image size is set as soon as the photo is taken.

It seems like there is a default setting on the Milestone causing this behavior.

Any help would be greatly appreciated.

Thanks,
~Jeremy

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

深海不蓝 2024-09-15 13:38:27

每部手机都有自己的制造商编写的相机应用程序。每个相机应用程序都会决定对拍摄的图像进行多少调整大小和/或压缩。如果您在更多手机上进行测试,您可能会发现获得了各种不同的图像尺寸和质量。只要您使用意图,就取决于用户选择处理该意图的任何 Activity(无论如何,它始终可能与默认相机应用程序不同)来决定如何处理它。

如果您想强制执行特定的图像尺寸或质量,您需要编写自己的相机活动。请记住,不同的手机将具有不同的硬件,无论如何都可以以各种不同的分辨率拍摄图像。您应该能够获得比 320x240 更好的分辨率,但由于硬件不同,您将无法在所有手机上获得一致的尺寸。

Every phone has its own manufacturer written camera app. Every camera app decides how much to resize and/or compress any images taken. If you test on more phones, you will probably find that you're getting a variety of different image sizes and qualities. As long as you are using intents, it is up to whatever Activity that the user chooses to handle that intent (which could always be different than the default camera app anyway) to decide what to do with it.

If you want to enforce a particular image size or quality, you need to write your own camera activity. Keep in mind that different phones are going to have different hardware that takes images at a huge variety of different resolutions anyway. You should be able to get better than 320x240, but you will not be able to get a consistent size across all phones because the hardware is different.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文