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


Java ShapeDrawable.draw方法代码示例

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


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

示例1: roundBitmap

import android.graphics.drawable.ShapeDrawable; //导入方法依赖的package包/类
public static Bitmap roundBitmap(Bitmap bitmap, int i, int i2, float f, float f2, float f3,
                                 float f4) throws Throwable {
    int width = bitmap.getWidth();
    int height = bitmap.getHeight();
    Rect rect = new Rect(0, 0, width, height);
    Bitmap createBitmap = (width == i && height == i2) ? Bitmap.createBitmap(bitmap.getWidth
            (), bitmap.getHeight(), Config.ARGB_8888) : Bitmap.createBitmap(i, i2, Config
            .ARGB_8888);
    Canvas canvas = new Canvas(createBitmap);
    Paint paint = new Paint();
    Rect rect2 = new Rect(0, 0, i, i2);
    paint.setAntiAlias(true);
    canvas.drawARGB(0, 0, 0, 0);
    paint.setColor(-12434878);
    float[] fArr = new float[]{f, f, f2, f2, f3, f3, f4, f4};
    ShapeDrawable shapeDrawable = new ShapeDrawable(new RoundRectShape(fArr, new RectF(0.0f,
            0.0f, 0.0f, 0.0f), fArr));
    shapeDrawable.setBounds(rect2);
    shapeDrawable.draw(canvas);
    paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
    canvas.drawBitmap(bitmap, rect, rect2, paint);
    return createBitmap;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:24,代码来源:BitmapHelper.java

示例2: studyBitmapShader

import android.graphics.drawable.ShapeDrawable; //导入方法依赖的package包/类
/**
     * 位图图像渲染
     * @param canvas
     */
    private void studyBitmapShader(Canvas canvas) {
        //创建BitmapShader
        //其中TileMode.MIRROR x方向镜像  TileMode.REPEAT y方向重复
        mBitmapShader = new BitmapShader(mBitMap, Shader.TileMode.MIRROR, Shader.TileMode.REPEAT);

        //创建矩阵   来缩放图片
        Matrix matrix = new Matrix();
        matrix.setScale(0.2f,0.2f);
        mBitmapShader.setLocalMatrix(matrix);

        mPaint.setAntiAlias(true);
        mPaint.setShader(mBitmapShader);

        //画圆形的图片
//        canvas.drawCircle(mBitMap.getWidth()/2,mBitMap.getHeight()/2,300,mPaint);

        //画矩形的图片
//        Rect rect = new Rect(0,0,600,600);
//        canvas.drawRect(rect,mPaint);
//
        //画椭圆的图片
//        RectF rectf = new RectF(0,0,400,300);
//
//        canvas.drawOval(rectf,mPaint);

        //用shapeDrawable 实现圆形图片
        ShapeDrawable shapeDrawable = new ShapeDrawable(new OvalShape());
        shapeDrawable.getPaint().setShader(mBitmapShader);
        shapeDrawable.setBounds(0,0,400,400);
        shapeDrawable.draw(canvas);

    }
 
开发者ID:fanxiaole,项目名称:androidShader_rippleView_radarView,代码行数:37,代码来源:MyGradientView.java


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