java类android.graphics.BitmapFactory.Options的实例源码

ImageDecodingInfo.java 文件源码 项目:GitHub 阅读 28 收藏 0 点赞 0 评论 0
private void copyOptions(Options srcOptions, Options destOptions) {
    destOptions.inDensity = srcOptions.inDensity;
    destOptions.inDither = srcOptions.inDither;
    destOptions.inInputShareable = srcOptions.inInputShareable;
    destOptions.inJustDecodeBounds = srcOptions.inJustDecodeBounds;
    destOptions.inPreferredConfig = srcOptions.inPreferredConfig;
    destOptions.inPurgeable = srcOptions.inPurgeable;
    destOptions.inSampleSize = srcOptions.inSampleSize;
    destOptions.inScaled = srcOptions.inScaled;
    destOptions.inScreenDensity = srcOptions.inScreenDensity;
    destOptions.inTargetDensity = srcOptions.inTargetDensity;
    destOptions.inTempStorage = srcOptions.inTempStorage;
    if (Build.VERSION.SDK_INT >= 10) copyOptions10(srcOptions, destOptions);
    if (Build.VERSION.SDK_INT >= 11) copyOptions11(srcOptions, destOptions);
}
BaseImageDecoder.java 文件源码 项目:android-project-gallery 阅读 27 收藏 0 点赞 0 评论 0
protected ImageFileInfo defineImageSizeAndRotation(InputStream imageStream, ImageDecodingInfo decodingInfo)
        throws IOException {
    Options options = new Options();
    options.inJustDecodeBounds = true;
    BitmapFactory.decodeStream(imageStream, null, options);

    ExifInfo exif;
    String imageUri = decodingInfo.getImageUri();
    if (decodingInfo.shouldConsiderExifParams() && canDefineExifParams(imageUri, options.outMimeType)) {
        exif = defineExifOrientation(imageUri);
    } else {
        exif = new ExifInfo();
    }
    return new ImageFileInfo(new ImageSize(options.outWidth, options.outHeight, exif.rotation), exif);
}
BaseImageDecoder.java 文件源码 项目:GitHub 阅读 29 收藏 0 点赞 0 评论 0
protected ImageFileInfo defineImageSizeAndRotation(InputStream imageStream, ImageDecodingInfo decodingInfo)
        throws IOException {
    Options options = new Options();
    options.inJustDecodeBounds = true;
    BitmapFactory.decodeStream(imageStream, null, options);

    ExifInfo exif;
    String imageUri = decodingInfo.getImageUri();
    if (decodingInfo.shouldConsiderExifParams() && canDefineExifParams(imageUri, options.outMimeType)) {
        exif = defineExifOrientation(imageUri);
    } else {
        exif = new ExifInfo();
    }
    return new ImageFileInfo(new ImageSize(options.outWidth, options.outHeight, exif.rotation), exif);
}
MediaStoreUtils.java 文件源码 项目:boohee_v5.6 阅读 32 收藏 0 点赞 0 评论 0
public static Bitmap getBitmapFromUri(Context context, Uri uri, Options options) {
    Bitmap bitmap = null;
    InputStream is = null;
    try {
        is = context.getContentResolver().openInputStream(uri);
        bitmap = BitmapFactory.decodeStream(is, null, options);
        if (is != null) {
            try {
                is.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    } catch (FileNotFoundException e2) {
        e2.printStackTrace();
        if (is != null) {
            try {
                is.close();
            } catch (IOException e3) {
                e3.printStackTrace();
            }
        }
    } catch (Throwable th) {
        if (is != null) {
            try {
                is.close();
            } catch (IOException e32) {
                e32.printStackTrace();
            }
        }
    }
    return bitmap;
}
BitmapUtil.java 文件源码 项目:GCSApp 阅读 35 收藏 0 点赞 0 评论 0
public static void saveBitmapFronPath(String srcPath, String picName, String filePath)
        throws FileNotFoundException {

    Options options = new Options();
    options.inJustDecodeBounds = true;
    Bitmap temp = BitmapFactory.decodeFile(srcPath, options);
    options.inJustDecodeBounds = false;
    int actualWidth = options.outWidth;
    int actualHeight = options.outHeight;
    int desiredWidth = actualWidth;
    int desiredHeight = actualHeight;
    if (actualWidth > NOMARL_SIZE && actualHeight > NOMARL_SIZE) {
        if (actualWidth > actualHeight) {
            desiredWidth = (int) (actualWidth * ((NOMARL_SIZE *1.0) / actualHeight));
            desiredHeight = NOMARL_SIZE;
        } else {
            desiredHeight = (int) (actualHeight * ((NOMARL_SIZE *1.0)/ actualWidth));
            desiredWidth = NOMARL_SIZE;
        }
    }
    options.inSampleSize = findBestSampleSize(actualWidth, actualHeight,
            desiredWidth, desiredHeight);
    options.inPurgeable = true;// 同时设置才会有效
    options.inInputShareable = true;//。当系统内存不够时候图片自动被回收

    temp = BitmapFactory.decodeFile(srcPath, options);
    Bitmap resizedBitmap = Bitmap.createScaledBitmap(temp, desiredWidth,
            desiredHeight, true);
    resizedBitmap = BitmapUtil.getRotationBitmap(srcPath, resizedBitmap);
    saveBitmap(resizedBitmap, new File(filePath,picName));
    if(null != temp){
        temp.recycle();
    }
    if(null != resizedBitmap){
        resizedBitmap.recycle();
    }
}
BitmapUtils.java 文件源码 项目:android-project-gallery 阅读 34 收藏 0 点赞 0 评论 0
public static Bitmap getSampledBitmap(String filePath, int reqWidth, int reqHeight)
{
    Options options = new Options();
    options.inJustDecodeBounds = true;

    BitmapFactory.decodeFile(filePath, options);

    // Raw height and width of image
    final int height = options.outHeight;
    final int width = options.outWidth;
    int inSampleSize = 1;

    if (height > reqHeight || width > reqWidth)
    {
        if (width > height)
        {
            inSampleSize = (int)FloatMath.floor(((float)height / reqHeight)+0.5f); //Math.round((float)height / (float)reqHeight);
        }
        else
        {
            inSampleSize = (int)FloatMath.floor(((float)width / reqWidth)+0.5f); //Math.round((float)width / (float)reqWidth);
        }
    }

    options.inSampleSize = inSampleSize;
    options.inJustDecodeBounds = false;

    return BitmapFactory.decodeFile(filePath, options);
}
ImageResizeUtil.java 文件源码 项目:ArtOfAndroid 阅读 32 收藏 0 点赞 0 评论 0
public static Bitmap decodeBitmapFromResource(Resources res, int resId, int reqWidth, int reqHeight) {
    Options options = new Options();
    options.inJustDecodeBounds = true;
    BitmapFactory.decodeResource(res, resId, options);

    options.inSampleSize = calcInSampleSize(options, reqWidth, reqHeight);

    options.inJustDecodeBounds = false;
    return BitmapFactory.decodeResource(res, resId, options);
}
BitmapUtil.java 文件源码 项目:GCSApp 阅读 33 收藏 0 点赞 0 评论 0
/**
 * 压缩收藏表情,最大边压到150
 */
public static Bitmap getFaceBitmapFronPath(Context context, String filePath)
        throws FileNotFoundException {
    if (null == filePath) {
        return null;
    }

    Options options = new Options();
    options.inJustDecodeBounds = true;
    Bitmap temp = BitmapFactory.decodeFile(filePath, options);
    options.inJustDecodeBounds = false;
    int actualWidth = options.outWidth;
    int actualHeight = options.outHeight;
    int desiredWidth = actualWidth;
    int desiredHeight = actualHeight;
    if (actualWidth > 150 && actualHeight > 150) {
        if (actualWidth > actualHeight) {
            desiredWidth = (int) (actualWidth * ((150 *1.0) / actualHeight));
            desiredHeight = 150;
        } else {
            desiredHeight = (int) (actualHeight * ((150 *1.0)/ actualWidth));
            desiredWidth = 150;
        }
    }
    options.inSampleSize = findBestSampleSize(actualWidth, actualHeight,
            desiredWidth, desiredHeight);
    temp = BitmapFactory.decodeFile(filePath, options);
    temp = Bitmap.createScaledBitmap(temp, desiredWidth,
            desiredHeight, true);
    return temp;
}
BaseImageDecoder.java 文件源码 项目:ImageLoaderSupportGif 阅读 28 收藏 0 点赞 0 评论 0
protected ImageFileInfo defineImageSizeAndRotation(InputStream imageStream, ImageDecodingInfo decodingInfo)
        throws IOException {
    Options options = new Options();
    options.inJustDecodeBounds = true;
    BitmapFactory.decodeStream(imageStream, null, options);

    ExifInfo exif;
    String imageUri = decodingInfo.getImageUri();
    if (decodingInfo.shouldConsiderExifParams() && canDefineExifParams(imageUri, options.outMimeType)) {
        exif = defineExifOrientation(imageUri);
    } else {
        exif = new ExifInfo();
    }
    return new ImageFileInfo(new ImageSize(options.outWidth, options.outHeight, exif.rotation), exif);
}
VideoShotEditActivity.java 文件源码 项目:letv 阅读 26 收藏 0 点赞 0 评论 0
private RoundedImageView createImageViewFromFile(int position, String filename) {
    if (!FileUtils.checkFileIsEnabledPath(filename)) {
        return null;
    }
    Options newOpts = new Options();
    newOpts.inJustDecodeBounds = true;
    Bitmap bitmap = BitmapFactory.decodeFile(filename, newOpts);
    int w = newOpts.outWidth;
    int h = newOpts.outHeight;
    int be = 1;
    if (w > h && ((float) w) > 300.0f) {
        be = (int) (((float) newOpts.outWidth) / 300.0f);
    } else if (w < h && ((float) h) > 400.0f) {
        be = (int) (((float) newOpts.outHeight) / 400.0f);
    }
    if (be <= 0) {
        be = 1;
    }
    Options newOpts2 = new Options();
    newOpts2.inSampleSize = be;
    newOpts2.inJustDecodeBounds = false;
    Bitmap bitmap2 = BitmapFactory.decodeFile(filename, newOpts2);
    RoundedImageView imageView = (RoundedImageView) this.mInflater.inflate(R.layout.videoshot_rounded_item, null, false).findViewById(R.id.riv_imageView);
    imageView.setTag(Integer.valueOf(position));
    imageView.setImageBitmap(bitmap2);
    if (this.mIVArray != null) {
        this.mIVArray.add(imageView);
        return imageView;
    }
    this.mIVArray = new ArrayList();
    this.mIVArray.add(imageView);
    return imageView;
}


问题


面经


文章

微信
公众号

扫码关注公众号