缩小图像尺寸使用COM pression不改变尺寸 [英] Reduce Image Size Using Compression Without changing Dimension

查看:233
本文介绍了缩小图像尺寸使用COM pression不改变尺寸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何降低图像大小而不改变图像尺寸(高度和宽度应该是相同的)。在Android的我怎样才能做到这一点?。我希望减少image.I的质量要超过network.So大小发送应smaller.I需要类似的https://play.google.com/store/apps/details?id=com.shoozhoo.imageresizer&hl=en

How to reduce Image Size without changing image dimensions(Height and width should be same).In android How can i do this?.I want to reduce the quality of image.I want to send it over the network.So size should be smaller.I need a functionality similar to https://play.google.com/store/apps/details?id=com.shoozhoo.imageresizer&hl=en

推荐答案

请注意链接通过裁剪它降低了图像的大小应用程序。

Note the application linked reduce the size of the image by cropping it.

如果你想减少你需要COM preSS使用低质量的它的图像的存储字节。在这里,你交易的质量大小。

If you want to reduce the stored bytes of an image you need to compress it using a lower quality. Here you trade quality for size.

下面是一些code。

Bitmap bm = ... /* load your image into a bitmap object */

try {
  OutputStream out = new FileOutputStream(new File("my-smaller-image.jpg") ;
  bm.compress(Bitmap.CompressFormat.JPEG, 80 /* this is the quality parameter */, out) ;
  out.flush() ;
  out.close() ;
}
catch (Exception e) {}

下面的质量参数设置为80,用你选择的一个或给你正确的文件大小。

Here the quality parameter is set to 80, use one of your choosing or giving you the correct file size.

这篇关于缩小图像尺寸使用COM pression不改变尺寸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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