在android中压缩位图时出错

时间:2012-09-27 12:38:04

标签: android

File file = new File(imgfilepath);
if(file.exists()&&file.canRead())
{
    try{
        bitmap = BitmapFactory.decodeFile(imgfilepath);
    }catch(Exception e)
    {
        error=1;
    }

    try{
        blob = new ByteArrayOutputStream();
    }catch(Exception e)
    {
        error=2;
    }

    try{
        bitmap.compress(Bitmap.CompressFormat.JPEG,1, blob);
    }catch(Exception e)
    {
        error=3;
    }

    try{
        bitmapdata = blob.toByteArray();
    }catch(Exception e)
    {
        error=4;
    }
}

我得到错误值3如何解决这个问题,提供的图像是jpg。 它有效,但现在它将返回错误

0 个答案:

没有答案
相关问题