当前位置: 首页>>代码示例>>Java>>正文


Java BitmapDisplayConfig类代码示例

本文整理汇总了Java中com.lidroid.xutils.bitmap.BitmapDisplayConfig的典型用法代码示例。如果您正苦于以下问题:Java BitmapDisplayConfig类的具体用法?Java BitmapDisplayConfig怎么用?Java BitmapDisplayConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


BitmapDisplayConfig类属于com.lidroid.xutils.bitmap包,在下文中一共展示了BitmapDisplayConfig类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getBitmapFromCache

import com.lidroid.xutils.bitmap.BitmapDisplayConfig; //导入依赖的package包/类
/**
 * 从缓存中获取原图
 * @param uri
 * @return
 */
public static Bitmap getBitmapFromCache(String uri) {
	BitmapDisplayConfig config = new BitmapDisplayConfig();
	config.setBitmapConfig(Bitmap.Config.ARGB_8888);
	config.setShowOriginal(true);
	Bitmap bitmap = mBitmapUtils.getBitmapFromMemCache(uri, config);
	if(bitmap != null) {
		return bitmap;
	}
	try {
		return BitmapFactory.decodeStream(new FileInputStream(mBitmapUtils.getBitmapFileFromDiskCache(uri)));
	} catch (FileNotFoundException e) {
		Log.e("getBitmapFileFromCache", "get bitmap error", e);
	}
	return null;
}
 
开发者ID:liuling07,项目名称:QiQuYing,代码行数:21,代码来源:BitmapUtil.java

示例2: decodeBitmapMeta

import com.lidroid.xutils.bitmap.BitmapDisplayConfig; //导入依赖的package包/类
private Bitmap decodeBitmapMeta(BitmapMeta bitmapMeta, BitmapDisplayConfig config) throws IOException {
    if (bitmapMeta == null) return null;
    Bitmap bitmap = null;
    if (bitmapMeta.inputStream != null) {
        if (config == null || config.isShowOriginal()) {
            bitmap = BitmapDecoder.decodeFileDescriptor(bitmapMeta.inputStream.getFD());
        } else {
            bitmap = BitmapDecoder.decodeSampledBitmapFromDescriptor(
                    bitmapMeta.inputStream.getFD(),
                    config.getBitmapMaxSize(),
                    config.getBitmapConfig());
        }
    } else if (bitmapMeta.data != null) {
        if (config == null || config.isShowOriginal()) {
            bitmap = BitmapDecoder.decodeByteArray(bitmapMeta.data);
        } else {
            bitmap = BitmapDecoder.decodeSampledBitmapFromByteArray(
                    bitmapMeta.data,
                    config.getBitmapMaxSize(),
                    config.getBitmapConfig());
        }
    }
    return bitmap;
}
 
开发者ID:android-quick-dev,项目名称:AndroidDevFramework,代码行数:25,代码来源:BitmapCache.java

示例3: displayImage

import com.lidroid.xutils.bitmap.BitmapDisplayConfig; //导入依赖的package包/类
@Override
public void displayImage(Activity activity, String path, GFImageView imageView, Drawable defaultDrawable, int width, int height) {
    BitmapDisplayConfig config = new BitmapDisplayConfig();
    config.setLoadFailedDrawable(defaultDrawable);
    config.setLoadingDrawable(defaultDrawable);
    config.setBitmapConfig(Bitmap.Config.RGB_565);
    config.setBitmapMaxSize(new BitmapSize(width, height));
    bitmapUtils.display(imageView, "file://" + path, config);
}
 
开发者ID:YuanPengandy,项目名称:GalleryFinal-master,代码行数:10,代码来源:XUtils2ImageLoader.java

示例4: onLoadCompleted

import com.lidroid.xutils.bitmap.BitmapDisplayConfig; //导入依赖的package包/类
@Override
public void onLoadCompleted(T container, String uri, Bitmap bitmap, BitmapDisplayConfig config, BitmapLoadFrom from) {
    this.setBitmap(container, bitmap);
    Animation animation = config.getAnimation();
    if (animation != null) {
        animationDisplay(container, animation);
    }
}
 
开发者ID:xulailing,项目名称:android-open-project-demo-master,代码行数:9,代码来源:DefaultBitmapLoadCallBack.java

示例5: addBitmapToMemoryCache

import com.lidroid.xutils.bitmap.BitmapDisplayConfig; //导入依赖的package包/类
private Bitmap addBitmapToMemoryCache(String uri, BitmapDisplayConfig config, Bitmap bitmap, long expiryTimestamp) throws IOException {
    if (config != null) {
        BitmapFactory bitmapFactory = config.getBitmapFactory();
        if (bitmapFactory != null) {
            bitmap = bitmapFactory.cloneNew().createBitmap(bitmap);
        }
    }
    if (uri != null && bitmap != null && globalConfig.isMemoryCacheEnabled() && mMemoryCache != null) {
        MemoryCacheKey key = new MemoryCacheKey(uri, config);
        mMemoryCache.put(key, bitmap, expiryTimestamp);
    }
    return bitmap;
}
 
开发者ID:xulailing,项目名称:android-open-project-demo-master,代码行数:14,代码来源:BitmapCache.java

示例6: getBitmapFromMemCache

import com.lidroid.xutils.bitmap.BitmapDisplayConfig; //导入依赖的package包/类
/**
 * Get the bitmap from memory cache.
 *
 * @param uri    Unique identifier for which item to get
 * @param config
 * @return The bitmap if found in cache, null otherwise
 */
public Bitmap getBitmapFromMemCache(String uri, BitmapDisplayConfig config) {
    if (mMemoryCache != null && globalConfig.isMemoryCacheEnabled()) {
        MemoryCacheKey key = new MemoryCacheKey(uri, config);
        return mMemoryCache.get(key);
    }
    return null;
}
 
开发者ID:xulailing,项目名称:android-open-project-demo-master,代码行数:15,代码来源:BitmapCache.java

示例7: getBitmapFromDiskCache

import com.lidroid.xutils.bitmap.BitmapDisplayConfig; //导入依赖的package包/类
/**
 * Get the bitmap from disk cache.
 *
 * @param uri
 * @param config
 * @return
 */
public Bitmap getBitmapFromDiskCache(String uri, BitmapDisplayConfig config) {
    if (uri == null || !globalConfig.isDiskCacheEnabled()) return null;
    if (mDiskLruCache == null) {
        initDiskCache();
    }
    if (mDiskLruCache != null) {
        LruDiskCache.Snapshot snapshot = null;
        try {
            snapshot = mDiskLruCache.get(uri);
            if (snapshot != null) {
                Bitmap bitmap = null;
                if (config == null || config.isShowOriginal()) {
                    bitmap = BitmapDecoder.decodeFileDescriptor(
                            snapshot.getInputStream(DISK_CACHE_INDEX).getFD());
                } else {
                    bitmap = BitmapDecoder.decodeSampledBitmapFromDescriptor(
                            snapshot.getInputStream(DISK_CACHE_INDEX).getFD(),
                            config.getBitmapMaxSize(),
                            config.getBitmapConfig());
                }

                bitmap = rotateBitmapIfNeeded(uri, config, bitmap);
                bitmap = addBitmapToMemoryCache(uri, config, bitmap, mDiskLruCache.getExpiryTimestamp(uri));
                return bitmap;
            }
        } catch (Throwable e) {
            LogUtils.e(e.getMessage(), e);
        } finally {
            IOUtils.closeQuietly(snapshot);
        }
    }
    return null;
}
 
开发者ID:xulailing,项目名称:android-open-project-demo-master,代码行数:41,代码来源:BitmapCache.java

示例8: decodeBitmapMeta

import com.lidroid.xutils.bitmap.BitmapDisplayConfig; //导入依赖的package包/类
/**
 * 流转化为bitmap, 而且根据config压缩图片
 * @param bitmapMeta
 * @param config
 * @return
 * @throws IOException
 */
private Bitmap decodeBitmapMeta(BitmapMeta bitmapMeta, BitmapDisplayConfig config) throws IOException {
    if (bitmapMeta == null) return null;
    Bitmap bitmap = null;
    if (bitmapMeta.inputStream != null) {
    	//BitmapFromDescriptor这一块使用的是这个方法而不是直接用流, 在网上找了一些
    	//资料, 这种转化能避免一些莫名其妙的图片加载不出来的问题
        if (config == null || config.isShowOriginal()) {
        	//原图
            bitmap = BitmapDecoder.decodeFileDescriptor(bitmapMeta.inputStream.getFD());
        } else {
        	//压缩图
            bitmap = BitmapDecoder.decodeSampledBitmapFromDescriptor(
                    bitmapMeta.inputStream.getFD(),
                    config.getBitmapMaxSize(),
                    config.getBitmapConfig());
        }
    } else if (bitmapMeta.data != null) {
        if (config == null || config.isShowOriginal()) {
            bitmap = BitmapDecoder.decodeByteArray(bitmapMeta.data);
        } else {
            bitmap = BitmapDecoder.decodeSampledBitmapFromByteArray(
                    bitmapMeta.data,
                    config.getBitmapMaxSize(),
                    config.getBitmapConfig());
        }
    }
    return bitmap;
}
 
开发者ID:xulailing,项目名称:android-open-project-demo-master,代码行数:36,代码来源:BitmapCache.java

示例9: rotateBitmapIfNeeded

import com.lidroid.xutils.bitmap.BitmapDisplayConfig; //导入依赖的package包/类
private synchronized Bitmap rotateBitmapIfNeeded(String uri, BitmapDisplayConfig config, Bitmap bitmap) {
    Bitmap result = bitmap;
    if (config != null && config.isAutoRotation()) {
        File bitmapFile = this.getBitmapFileFromDiskCache(uri);
        if (bitmapFile != null && bitmapFile.exists()) {
            ExifInterface exif = null;
            try {
                exif = new ExifInterface(bitmapFile.getPath());
            } catch (Throwable e) {
                return result;
            }
            int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_UNDEFINED);
            int angle = 0;
            switch (orientation) {
                case ExifInterface.ORIENTATION_ROTATE_90:
                    angle = 90;
                    break;
                case ExifInterface.ORIENTATION_ROTATE_180:
                    angle = 180;
                    break;
                case ExifInterface.ORIENTATION_ROTATE_270:
                    angle = 270;
                    break;
                default:
                    angle = 0;
                    break;
            }
            if (angle != 0) {
                Matrix m = new Matrix();
                m.postRotate(angle);
                result = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), m, true);
                bitmap.recycle();
                bitmap = null;
            }
        }
    }
    return result;
}
 
开发者ID:xulailing,项目名称:android-open-project-demo-master,代码行数:39,代码来源:BitmapCache.java

示例10: BitmapUtils

import com.lidroid.xutils.bitmap.BitmapDisplayConfig; //导入依赖的package包/类
public BitmapUtils(Context context, String diskCachePath) {
    if (context == null) {
        throw new IllegalArgumentException("context may not be null");
    }

    this.context = context.getApplicationContext();
    globalConfig = BitmapGlobalConfig.getInstance(this.context, diskCachePath);
    defaultDisplayConfig = new BitmapDisplayConfig();
}
 
开发者ID:xulailing,项目名称:android-open-project-demo-master,代码行数:10,代码来源:BitmapUtils.java

示例11: BitmapLoadTask

import com.lidroid.xutils.bitmap.BitmapDisplayConfig; //导入依赖的package包/类
public BitmapLoadTask(T container, String uri, BitmapDisplayConfig config, BitmapLoadCallBack<T> callBack) {
    if (container == null || uri == null || config == null || callBack == null) {
        throw new IllegalArgumentException("args may not be null");
    }

    this.containerReference = new WeakReference<T>(container);
    this.callBack = callBack;
    this.uri = uri;
    this.displayConfig = config;
}
 
开发者ID:xulailing,项目名称:android-open-project-demo-master,代码行数:11,代码来源:BitmapUtils.java

示例12: onLoadCompleted

import com.lidroid.xutils.bitmap.BitmapDisplayConfig; //导入依赖的package包/类
@Override
public void onLoadCompleted(ImageView arg0, String arg1, Bitmap arg2,
		BitmapDisplayConfig arg3, BitmapLoadFrom arg4) {
	LoadPercentImageView imageView = (LoadPercentImageView)arg0;
	imageView.setProgress(100);
	imageView.setComplete(true);
	imageView.setImageBitmap(arg2);
}
 
开发者ID:liuling07,项目名称:QiQuYing,代码行数:9,代码来源:PercentImageViewLoadCallBack.java

示例13: onLoading

import com.lidroid.xutils.bitmap.BitmapDisplayConfig; //导入依赖的package包/类
@Override
	public void onLoading(ImageView arg0, String uri,
			BitmapDisplayConfig config, long total, long current) {
//		super.onLoading(arg0, uri, config, total, current);
		LoadPercentImageView imageView = (LoadPercentImageView)arg0;
		int progress = (int)(((double)current) / ((double)total) * 100);
		imageView.setProgress(progress);
	}
 
开发者ID:liuling07,项目名称:QiQuYing,代码行数:9,代码来源:PercentImageViewLoadCallBack.java

示例14: MemoryCacheKey

import com.lidroid.xutils.bitmap.BitmapDisplayConfig; //导入依赖的package包/类
private MemoryCacheKey(String uri, BitmapDisplayConfig config) {
    this.uri = uri;
    this.subKey = config == null ? null : config.toString();
}
 
开发者ID:xulailing,项目名称:android-open-project-demo-master,代码行数:5,代码来源:BitmapCache.java

示例15: configDefaultDisplayConfig

import com.lidroid.xutils.bitmap.BitmapDisplayConfig; //导入依赖的package包/类
public BitmapUtils configDefaultDisplayConfig(BitmapDisplayConfig displayConfig) {
    defaultDisplayConfig = displayConfig;
    return this;
}
 
开发者ID:xulailing,项目名称:android-open-project-demo-master,代码行数:5,代码来源:BitmapUtils.java


注:本文中的com.lidroid.xutils.bitmap.BitmapDisplayConfig类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。