COM preSS从摄像机位图 [英] Compress Bitmap from Camera

查看:219
本文介绍了COM preSS从摄像机位图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要传送摄像机通过网络拍摄的图像。该图像是太大,创建使用bitmap.com preSS需要一个位图();它看起来像Gmail应用程序可以从相机中,同时保持其庞大的像素大小,但具有很大的减少其文件大小附加图像。

I need to send an image taken from the Camera over network. The image is too large to create a bitmap needed to use bitmap.compress(); It looks like the Gmail application can attach images from the camera while maintaining their large pixel size but with a great reduction their file size.

这是行不通的,因为我getBitmap()将返回一个图像到大分配,我不希望子样品下来,以更小的尺寸。

This won't work because I getBitmap() will return an Image to large to allocate and I don't want to sub sample it down to a smaller size.

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    getBitmap().compress(Bitmap.CompressFormat.JPEG, 70, baos);

我如何可以做同样的任何想法,而不会超出我的总内存?

Any ideas on how I can do the same without exceeding my total memory?

更新:

对于任何人回来这个线程我跟着菲尔的答案,并用阿帕奇MultiPartEntity获得轻松完成工作。 (它处理从磁盘流媒体文件,以网为你)<一个href="http://hc.apache.org/httpcomponents-client-ga/httpmime/apidocs/org/apache/http/entity/mime/MultipartEntity.html" rel="nofollow">http://hc.apache.org/httpcomponents-client-ga/httpmime/apidocs/org/apache/http/entity/mime/MultipartEntity.html

For anyone coming back to this thread I followed Phil's answer and used Apache MultiPartEntity to get the job done easily. (It handles streaming files from disk to network for you) http://hc.apache.org/httpcomponents-client-ga/httpmime/apidocs/org/apache/http/entity/mime/MultipartEntity.html

推荐答案

由于您没有定义完全是通过网络发送'的意思在这里,它是很难给出具体建议。

As you haven't defined quite what 'send over the network' means here, it's difficult to give specific advice.

不过,如果你想送无损图像(或小于已经发生的损失),我不认为你就可以COM preSS得多,因为JPEG已经融为一体presses。它采用有损COM pression,因此,如果您增加JPEG COM pression,你失去的细节(尽管也许不是那些你会发现,因为它是基于频率不是像素)

However, if you want to send a lossless image (or with less loss than has already occurred), I don't think you'll be able to compress much more, as JPEG already compresses. It uses lossy compression, so if you increase the JPEG compression, you lose details (although maybe not ones you'd notice, as it's based on frequencies not pixels)

如果你只需要通过网络发送,那么为什么不开一个InputStream和后台打印数据直接到网络?

If you just need to send over the network, then why not just open an InputStream, and spool data directly to the network?

希望这有助于 - 如果你能提供更多的细节,我会更新的答案

Hope this helps - if you can provide more details, I'll update the answer.

最良好的祝愿,

菲尔Lello

这篇关于COM preSS从摄像机位图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆