• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java BitmapSize类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: displayImage

import com.lidroid.xutils.bitmap.core.BitmapSize; //导入依赖的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


示例2: optimizeMaxSizeByView

import com.lidroid.xutils.bitmap.core.BitmapSize; //导入依赖的package包/类
/**
 * @param view
 * @param maxImageWidth
 * @param maxImageHeight
 * 设置显示View的大小
 * @return
 */
public static BitmapSize optimizeMaxSizeByView(View view, int maxImageWidth, int maxImageHeight) {
    int width = maxImageWidth;
    int height = maxImageHeight;

    if (width > 0 && height > 0) { //当设置不为0的时候
        return new BitmapSize(width, height);
    }

    final ViewGroup.LayoutParams params = view.getLayoutParams(); 
    if (params != null) { 
        if (params.width > 0) {  //如果布局文件中配置了大小
            width = params.width;
        } else if (params.width != ViewGroup.LayoutParams.WRAP_CONTENT) {
            width = view.getWidth();
        }

        if (params.height > 0) {
            height = params.height;
        } else if (params.height != ViewGroup.LayoutParams.WRAP_CONTENT) {
            height = view.getHeight();
        }
    }

    if (width <= 0) width = getImageViewFieldValue(view, "mMaxWidth");
    if (height <= 0) height = getImageViewFieldValue(view, "mMaxHeight");

    BitmapSize screenSize = getScreenSize(view.getContext());
    if (width <= 0) width = screenSize.getWidth();
    if (height <= 0) height = screenSize.getHeight();

    return new BitmapSize(width, height);
}
 
开发者ID:xulailing,项目名称:android-open-project-demo-master,代码行数:40,代码来源:BitmapCommonUtils.java


示例3: optimizeMaxSizeByView

import com.lidroid.xutils.bitmap.core.BitmapSize; //导入依赖的package包/类
public static BitmapSize optimizeMaxSizeByView(View view, int maxImageWidth, int maxImageHeight) {
    int width = maxImageWidth;
    int height = maxImageHeight;

    if (width > 0 && height > 0) {
        return new BitmapSize(width, height);
    }

    final ViewGroup.LayoutParams params = view.getLayoutParams();
    if (params != null) {
        if (params.width > 0) {
            width = params.width;
        } else if (params.width != ViewGroup.LayoutParams.WRAP_CONTENT) {
            width = view.getWidth();
        }

        if (params.height > 0) {
            height = params.height;
        } else if (params.height != ViewGroup.LayoutParams.WRAP_CONTENT) {
            height = view.getHeight();
        }
    }

    if (width <= 0) width = getImageViewFieldValue(view, "mMaxWidth");
    if (height <= 0) height = getImageViewFieldValue(view, "mMaxHeight");

    BitmapSize screenSize = getScreenSize(view.getContext());
    if (width <= 0) width = screenSize.getWidth();
    if (height <= 0) height = screenSize.getHeight();

    return new BitmapSize(width, height);
}
 
开发者ID:android-quick-dev,项目名称:AndroidDevFramework,代码行数:33,代码来源:BitmapCommonUtils.java


示例4: getBitmapMaxSize

import com.lidroid.xutils.bitmap.core.BitmapSize; //导入依赖的package包/类
public BitmapSize getBitmapMaxSize() {
    return bitmapMaxSize == null ? BitmapSize.ZERO : bitmapMaxSize;
}
 
开发者ID:xulailing,项目名称:android-open-project-demo-master,代码行数:4,代码来源:BitmapDisplayConfig.java


示例5: setBitmapMaxSize

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


示例6: configDefaultBitmapMaxSize

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


示例7: display

import com.lidroid.xutils.bitmap.core.BitmapSize; //导入依赖的package包/类
public <T extends View> void display(T container, String uri, BitmapDisplayConfig displayConfig, BitmapLoadCallBack<T> callBack) {
    if (container == null) {
        return;
    }

    if (callBack == null) {
        callBack = new DefaultBitmapLoadCallBack<T>();  //默认的回调
    }

    if (displayConfig == null || displayConfig == defaultDisplayConfig) {
        displayConfig = defaultDisplayConfig.cloneNew();// 默认展示图片的设置
    }

    // Optimize Max Size
    BitmapSize size = displayConfig.getBitmapMaxSize();
    //配置显示控件的大小
    displayConfig.setBitmapMaxSize(BitmapCommonUtils.optimizeMaxSizeByView(container, size.getWidth(), size.getHeight()));

    container.clearAnimation();

    if (TextUtils.isEmpty(uri)) {
        callBack.onLoadFailed(container, uri, displayConfig.getLoadFailedDrawable());
        return;
    }

    // start loading
    callBack.onPreLoad(container, uri, displayConfig);

    // find bitmap from mem cache. 优先从运行内存的缓存中读取
    Bitmap bitmap = globalConfig.getBitmapCache().getBitmapFromMemCache(uri, displayConfig);

    if (bitmap != null) {
        callBack.onLoadStarted(container, uri, displayConfig);
        callBack.onLoadCompleted(
                container,
                uri,
                bitmap,
                displayConfig,
                BitmapLoadFrom.MEMORY_CACHE);
    } else if (!bitmapLoadTaskExist(container, uri, callBack)) { //这里判断任务是否正在加载中

        final BitmapLoadTask<T> loadTask = new BitmapLoadTask<T>(container, uri, displayConfig, callBack);

        // get executor
        PriorityExecutor executor = globalConfig.getBitmapLoadExecutor();
        File diskCacheFile = this.getBitmapFileFromDiskCache(uri);
        boolean diskCacheExist = diskCacheFile != null && diskCacheFile.exists();
        if (diskCacheExist && executor.isBusy()) {
        	//如果闪存中有缓存,而且BitmapLoadExecutor线程池不够用就使用DiskCacheExecutor的线程池
            executor = globalConfig.getDiskCacheExecutor();  
        }
        // set loading image
        Drawable loadingDrawable = displayConfig.getLoadingDrawable();
        callBack.setDrawable(container, new AsyncDrawable<T>(loadingDrawable, loadTask));

        loadTask.setPriority(displayConfig.getPriority());
        loadTask.executeOnExecutor(executor);
    }
}
 
开发者ID:xulailing,项目名称:android-open-project-demo-master,代码行数:60,代码来源:BitmapUtils.java


示例8: getThumbBitmapFromCache

import com.lidroid.xutils.bitmap.core.BitmapSize; //导入依赖的package包/类
/**
	 * 获取缓存中图片的缩略图
	 * @param uri
	 * @return
	 */
	public static Bitmap getThumbBitmapFromCache(String uri, int width, int height) {
		BitmapDisplayConfig config = new BitmapDisplayConfig();
		config.setBitmapConfig(Bitmap.Config.ARGB_8888);
		config.setShowOriginal(false);
		BitmapSize bitmapSize = new BitmapSize(width, height);
		config.setBitmapMaxSize(bitmapSize);
		Bitmap bitmap = mBitmapUtils.getBitmapFromMemCache(uri, config);
		if(bitmap != null) {
			return bitmap;
		}
		try {
//			Bitmap bitmap2 = BitmapFactory.decodeStream(new FileInputStream());
			File file = mBitmapUtils.getBitmapFileFromDiskCache(uri);
	        BitmapFactory.Options options = new BitmapFactory.Options();  
	        options.inJustDecodeBounds = true;  
	        // 获取这个图片的宽和高,注意此处的bitmap为null  
	        bitmap = BitmapFactory.decodeFile(file.getAbsolutePath(), options);  
	        options.inJustDecodeBounds = false; // 设为 false  
	        // 计算缩放比  
	        int h = options.outHeight;  
	        int w = options.outWidth;  
	        int beWidth = w / width;  
	        int beHeight = h / height;  
	        int be = 1;  
	        if (beWidth < beHeight) {  
	            be = beWidth;  
	        } else {  
	            be = beHeight;  
	        }  
	        if (be <= 0) {  
	            be = 1;  
	        }  
	        options.inSampleSize = be;  
	        // 重新读入图片,读取缩放后的bitmap,注意这次要把options.inJustDecodeBounds 设为 false  
	        bitmap = BitmapFactory.decodeFile(file.getAbsolutePath(), options);  
	        // 利用ThumbnailUtils来创建缩略图,这里要指定要缩放哪个Bitmap对象  
	        bitmap = ThumbnailUtils.extractThumbnail(bitmap, width, height,  
	                ThumbnailUtils.OPTIONS_RECYCLE_INPUT);  
	        return bitmap;
		} catch (Exception e) {
			Log.e("getBitmapFileFromCache", "get bitmap error", e);
		}
		return null;
	}
 
开发者ID:liuling07,项目名称:QiQuYing,代码行数:50,代码来源:BitmapUtil.java


示例9: display

import com.lidroid.xutils.bitmap.core.BitmapSize; //导入依赖的package包/类
public <T extends View> void display(T container, String uri, BitmapDisplayConfig displayConfig, BitmapLoadCallBack<T> callBack) {
    if (container == null) {
        return;
    }

    if (callBack == null) {
        callBack = new DefaultBitmapLoadCallBack<T>();
    }

    if (displayConfig == null || displayConfig == defaultDisplayConfig) {
        displayConfig = defaultDisplayConfig.cloneNew();
    }

    // Optimize Max Size
    BitmapSize size = displayConfig.getBitmapMaxSize();
    displayConfig.setBitmapMaxSize(BitmapCommonUtils.optimizeMaxSizeByView(container, size.getWidth(), size.getHeight()));

    container.clearAnimation();

    if (TextUtils.isEmpty(uri)) {
        callBack.onLoadFailed(container, uri, displayConfig.getLoadFailedDrawable());
        return;
    }

    // start loading
    callBack.onPreLoad(container, uri, displayConfig);

    // find bitmap from mem cache.
    Bitmap bitmap = globalConfig.getBitmapCache().getBitmapFromMemCache(uri, displayConfig);

    if (bitmap != null) {
        callBack.onLoadStarted(container, uri, displayConfig);
        callBack.onLoadCompleted(
                container,
                uri,
                bitmap,
                displayConfig,
                BitmapLoadFrom.MEMORY_CACHE);
    } else if (!bitmapLoadTaskExist(container, uri, callBack)) {

        final BitmapLoadTask<T> loadTask = new BitmapLoadTask<T>(container, uri, displayConfig, callBack);

        // get executor
        PriorityExecutor executor = globalConfig.getBitmapLoadExecutor();
        File diskCacheFile = this.getBitmapFileFromDiskCache(uri);
        boolean diskCacheExist = diskCacheFile != null && diskCacheFile.exists();
        if (diskCacheExist && executor.isBusy()) {
            executor = globalConfig.getDiskCacheExecutor();
        }
        // set loading image
        Drawable loadingDrawable = displayConfig.getLoadingDrawable();
        callBack.setDrawable(container, new AsyncDrawable<T>(loadingDrawable, loadTask));

        loadTask.setPriority(displayConfig.getPriority());
        loadTask.executeOnExecutor(executor);
    }
}
 
开发者ID:android-quick-dev,项目名称:AndroidDevFramework,代码行数:58,代码来源:BitmapUtils.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Resource类代码示例发布时间:2022-05-23
下一篇:
Java MultiPoint类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap