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


Java BitmapDrawable.draw方法代码示例

本文整理汇总了Java中android.graphics.drawable.BitmapDrawable.draw方法的典型用法代码示例。如果您正苦于以下问题:Java BitmapDrawable.draw方法的具体用法?Java BitmapDrawable.draw怎么用?Java BitmapDrawable.draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.graphics.drawable.BitmapDrawable的用法示例。


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

示例1: dispatchDraw

import android.graphics.drawable.BitmapDrawable; //导入方法依赖的package包/类
/**
 * By overriding dispatchDraw, the BitmapDrawables of all the cells that were on the
 * screen before (but not after) the layout are drawn and animated off the screen.
 */
@Override
protected void dispatchDraw (Canvas canvas) {
    super.dispatchDraw(canvas);
    if (mCellBitmapDrawables.size() > 0) {
        for (BitmapDrawable bitmapDrawable: mCellBitmapDrawables) {
            bitmapDrawable.draw(canvas);
        }
    }
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:14,代码来源:InsertionListView.java

示例2: centerCrop

import android.graphics.drawable.BitmapDrawable; //导入方法依赖的package包/类
/**
 * 居中剪切图片
 */
public static Bitmap centerCrop(Resources res, Bitmap bitmap, int width, int height) {
    if (bitmap == null) {
        return null;
    }
    Bitmap result = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);

    Matrix matrix = new Matrix();

    float scale;
    float dx = 0, dy = 0;

    final int dwidth = bitmap.getWidth();
    final int dheight = bitmap.getHeight();

    final int vwidth = width;
    final int vheight = height;

    if (dwidth * vheight > vwidth * dheight) {
        scale = (float) vheight / (float) dheight;
        dx = (vwidth - dwidth * scale) * 0.5f;
    } else {
        scale = (float) vwidth / (float) dwidth;
        dy = (vheight - dheight * scale) * 0.5f;
    }

    matrix.setScale(scale, scale);
    matrix.postTranslate(Math.round(dx), Math.round(dy));

    Canvas canvas = new Canvas(result);
    canvas.concat(matrix);
    BitmapDrawable bitmapDrawable = new BitmapDrawable(res, bitmap);
    bitmapDrawable.setBounds(0, 0, dwidth, dheight);
    bitmapDrawable.draw(canvas);

    return result;
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:40,代码来源:ImagePickerImageView.java


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