Android处理照片质量、分辨率、旋转角度一些方法

package com.huatek.sales.util;


import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;


import>

public>         image.compress(Bitmap.CompressFormat.JPEG, 100, baos);//质量压缩方法,这里100表示不压缩,把压缩后的数据存放到baos中   
       >         while ( baos.toByteArray().length / 1024>100) {  //循环判断如果压缩后图片是否大于100kb,大于继续压缩          
           >         }   
        ByteArrayInputStream>         Bitmap bitmap = BitmapFactory.decodeStream(isBm, null, null);//把ByteArrayInputStream数据生成图片   
        return bitmap;   
    }  


/** 
     * 创建1280*720分辨率的图片 
     * @param>         BitmapFactory.Options opts = new BitmapFactory.Options();  
       >         BitmapFactory.decodeFile(filePath, opts);  
  
       >         opts.inJustDecodeBounds = false;  
  
        try {  
        //照片尺寸被缩小了1/4
           >         } catch (Exception e) {  
            // TODO: handle exception  
        }  
        //恢复bitmap尺寸大小
        return big(bitmap);  
    }
    
private static Bitmap big(Bitmap bitmap) {
if(bitmap != null) {
Matrix> matrix.postScale(1.33333334f,1.33333334f); //长和宽放大缩小的比例
Bitmap> return resizeBmp;
} else {
return bitmap;
}
}
    public static int computeSampleSize(BitmapFactory.Options options,  
   int>                 maxNumOfPixels);  
       >             roundedSize = 1;  
           >             }  
        }>         }  
   return>         double h = options.outHeight;  
       >                 .sqrt(w * h / maxNumOfPixels));  
       >                 Math.floor(w / minSideLength), Math.floor(h / minSideLength));  
       >             return 1;  
        }>             return lowerBound;  
        }>         try {  
            ExifInterface>             int orientation = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);  
           >                     break;  
           >                     break;  
           >                     break;  
            }  
        }>         matrix.postRotate(angle);  
        // 创建新的图片  
        Bitmap>                 bitmap.getWidth(), bitmap.getHeight(), matrix, true);  
        return resizedBitmap;  
    }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值