如何压缩bitmap

来源:互联网 发布:java什么是多态 编辑:程序博客网 时间:2024/06/12 01:16

今天是第一次写博客,还是想写好点,

大家多多关照啊:

其实压缩bitmap的方式很多,以下就是一些个介绍:

首先按照某个值去压缩,
①:
然后
private Bitmap compressBitmap(Bitmap bitmap)
ByteArrayOutputStream out=new ByteArrayOutputStream();
 int option= ""
 bitmap.compress(CompressFormat.JPEG,option,out);
 byteArrayInputStream in=new ByteArrayInputStream(out.toByteArray); 
 
 Bitmap map2=BitmapFactory.decodeStream(in,null,null);
 return map2;
 }
②:
private Bitmap compressBitmap(Bitmap bitmap)
ByteArrayOutputStream out=new ByteArrayOutputStream();
 int option=100;
 bitmap.compress(CompressFormat.JPEG,option,out);
  
 while(out.toByteArray/1024>100){
  out.reset();
  map.compress(CompressFormat.JPEG,option,out);
  option-=10;

 }
 byteArrayInputStream in=new ByteArrayInputStream(out.toByteArray);
 Bitmap map2=BitmapFactory.decodeStream(in,null,null);
 return map2;
 }
5:今天很郁闷很郁闷,就是网络请求的时候我觉得还是要用多线程好点,要不然那些自定

义的数据根本就没有更新,所以我在这里必须要强调handler和thread 的重要性。
在这条路中,会走很多的弯路,但是弯路走多了也没事,因为弯路走多了,以后遇到弯路

,会知道即使是弯路也会找到出口,什么逻辑理论,太狗血了都。
6:对于开发人员来说,我觉得有一件事情非常非常的重要,那就是我们要静的下心来做开发。

 

0 0