java类android.graphics.BitmapRegionDecoder的实例源码

SkiaPooledImageRegionDecoder.java 文件源码 项目:garras 阅读 26 收藏 0 点赞 0 评论 0
private synchronized BitmapRegionDecoder getNextAvailable() {
    for (Map.Entry<BitmapRegionDecoder, Boolean> entry : decoders.entrySet()) {
        if (!entry.getValue()) {
            entry.setValue(true);
            return entry.getKey();
        }
    }
    return null;
}
SkiaPooledImageRegionDecoder.java 文件源码 项目:garras 阅读 22 收藏 0 点赞 0 评论 0
private synchronized boolean markAsUnused(BitmapRegionDecoder decoder) {
    for (Map.Entry<BitmapRegionDecoder, Boolean> entry : decoders.entrySet()) {
        if (decoder == entry.getKey()) {
            if (entry.getValue()) {
                entry.setValue(false);
                return true;
            } else {
                return false;
            }
        }
    }
    return false;
}
DecodeUtils.java 文件源码 项目:medialibrary 阅读 28 收藏 0 点赞 0 评论 0
public static BitmapRegionDecoder createBitmapRegionDecoder(
        ThreadPool.JobContext jc, String filePath, boolean shareable) {
    try {
        return BitmapRegionDecoder.newInstance(filePath, shareable);
    } catch (Throwable t)  {
        Log.w(TAG, t);
        return null;
    }
}
DecodeUtils.java 文件源码 项目:medialibrary 阅读 36 收藏 0 点赞 0 评论 0
public static BitmapRegionDecoder createBitmapRegionDecoder(
        ThreadPool.JobContext jc, FileDescriptor fd, boolean shareable) {
    try {
        return BitmapRegionDecoder.newInstance(fd, shareable);
    } catch (Throwable t)  {
        Log.w(TAG, t);
        return null;
    }
}
DecodeUtils.java 文件源码 项目:medialibrary 阅读 24 收藏 0 点赞 0 评论 0
public static BitmapRegionDecoder createBitmapRegionDecoder(
        ThreadPool.JobContext jc, InputStream is, boolean shareable) {
    try {
        return BitmapRegionDecoder.newInstance(is, shareable);
    } catch (Throwable t)  {
        // We often cancel the creating of bitmap region decoder,
        // so just log one line.
        Log.w(TAG, "requestCreateBitmapRegionDecoder: " + t);
        return null;
    }
}
BitmapRegionTileSource.java 文件源码 项目:FlickLauncher 阅读 19 收藏 0 点赞 0 评论 0
public static SimpleBitmapRegionDecoderWrapper newInstance(
        InputStream is, boolean isShareable) {
    try {
        BitmapRegionDecoder d = BitmapRegionDecoder.newInstance(is, isShareable);
        if (d != null) {
            return new SimpleBitmapRegionDecoderWrapper(d);
        }
    } catch (IOException e) {
        Log.w("BitmapRegionTileSource", "getting decoder failed", e);
        return null;
    }
    return null;
}
CustomRegionDecoder.java 文件源码 项目:Camera-Roll-Android-App 阅读 45 收藏 0 点赞 0 评论 0
@Override
public Point init(Context context, Uri uri) throws Exception {
    InputStream inputStream = context.getContentResolver().openInputStream(uri);
    decoder = BitmapRegionDecoder.newInstance(inputStream, false);
    options = new BitmapFactory.Options();
    boolean use8BitColor = Settings.getInstance(context).use8BitColor();
    options.inPreferredConfig = use8BitColor ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565;
    return new Point(this.decoder.getWidth(), this.decoder.getHeight());
}
CropPhotoActivity.java 文件源码 项目:TAG 阅读 17 收藏 0 点赞 0 评论 0
@TargetApi(10)
private Bitmap decodeRegionCrop(ImageViewTouch cropImage) {
    int width = initWidth > initHeight ? initHeight : initWidth;
    int screenWidth = DemoApplication.getApp().getScreenWidth();
    float scale = cropImage.getScale() / getImageRadio();
    RectF rectf = cropImage.getBitmapRect();
    int left = -(int) (rectf.left * width / screenWidth / scale);
    int top = -(int) (rectf.top * width / screenWidth / scale);
    int right = left + (int) (width / scale);
    int bottom = top + (int) (width / scale);
    Rect rect = new Rect(left, top, right, bottom);
    InputStream is = null;
    System.gc();
    Bitmap croppedImage = null;
    try {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        oriBitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
        is = new ByteArrayInputStream(baos.toByteArray());
        BitmapRegionDecoder decoder = BitmapRegionDecoder.newInstance(is, false);
        croppedImage = decoder.decodeRegion(rect, new BitmapFactory.Options());
    } catch (Throwable e) {

    } finally {
        IOUtil.closeStream(is);
    }
    return croppedImage;
}
BitmapSource.java 文件源码 项目:BitmapView 阅读 27 收藏 0 点赞 0 评论 0
public TileImage getTileImage() {
    if (mIsGif) {
        return null;
    }

    InputStream inputStream = getInputStream();
    if (inputStream != null) {
        BitmapFactory.Options options = new BitmapFactory.Options();
        options.inJustDecodeBounds = true;
        BitmapFactory.decodeStream(inputStream, null, options);
        closeSilently(inputStream);
        int width = options.outWidth;
        int height = options.outHeight;

        if (width <= 0 || height <= 0) {
            return null;
        }

        inputStream = getInputStream();
        try {
            BitmapRegionDecoder bitmapRegionDecoder = BitmapRegionDecoder.newInstance(inputStream, false);
            closeSilently(inputStream);
            inputStream = getInputStream();
            int orientation = OrientationInfoUtility.getOrientation(inputStream);
            closeSilently(inputStream);
            return TileImage.newInstance(width, height, orientation, bitmapRegionDecoder);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    return null;
}
TileImage.java 文件源码 项目:BitmapView 阅读 17 收藏 0 点赞 0 评论 0
public static TileImage newInstance(int width, int height, @OrientationInfoUtility.ORIENTATION_ROTATE int orientation,
                                    BitmapRegionDecoder bitmapRegionDecoder) {
    TileImage image = new TileImage();
    image.mWidth = width;
    image.mHeight = height;
    image.mOrientation = orientation;
    image.mBitmapRegionDecoder = bitmapRegionDecoder;
    return image;
}


问题


面经


文章

微信
公众号

扫码关注公众号