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


Java Canvas.setDrawFilter方法代码示例

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


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

示例1: dispatchDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
protected void dispatchDraw(Canvas canvas) {
    super.dispatchDraw(canvas);
    if (mChanged && Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        post(new Runnable() {
            @Override
            public void run() {
                if (mAttached && Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    final int layerType = getLayerType();
                    // If it's already a hardware layer, it'll be built anyway.
                    if (layerType != LAYER_TYPE_HARDWARE || mFirst) {
                        mFirst = false;
                        setLayerType(LAYER_TYPE_HARDWARE, null);
                        buildLayer();
                        setLayerType(LAYER_TYPE_NONE, null);
                    }
                }
            }
        });
        mChanged = false;
    }
    PaintFlagsDrawFilter pfd = new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint
            .FILTER_BITMAP_FLAG);
    canvas.setDrawFilter(pfd);
}
 
开发者ID:Break369,项目名称:MyLife,代码行数:26,代码来源:BuildLayerFrameLayout.java

示例2: getRoundedCornerBitmap

import android.graphics.Canvas; //导入方法依赖的package包/类
public static Bitmap getRoundedCornerBitmap(Bitmap bitmap, int pixels) {
    Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap
            .getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(output);
    canvas.setDrawFilter(new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG));

    final int color = 0xff424242;
    final Paint paint = new Paint();
    final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
    final RectF rectF = new RectF(rect);
    final float roundPx = pixels;

    paint.setAntiAlias(true);
    paint.setDither(true);
    canvas.drawARGB(0, 0, 0, 0);
    paint.setColor(color);
    canvas.drawRoundRect(rectF, roundPx, roundPx, paint);

    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
    canvas.drawBitmap(bitmap, rect, rect, paint);

    return output;
}
 
开发者ID:Blankeer,项目名称:MDWechat,代码行数:24,代码来源:ImageHelper.java

示例3: onDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
public void onDraw(Canvas canvas) {
    canvas.setDrawFilter(new PaintFlagsDrawFilter(0, 3));
    int W = canvas.getWidth();
    int H = canvas.getHeight();
    Rect frame = CameraManager.get().getFramingRect();
    if (frame != null) {
        drawCover(canvas, frame, W, H);
        if (this.resultBitmap != null) {
            canvas.drawBitmap(this.resultBitmap, (float) frame.left, (float) frame.top, this.paint);
            return;
        }
        drawScanningLine(canvas, frame);
        drawRectEdge(canvas, frame);
        this.paint.reset();
        postInvalidateDelayed(ANIMATION_DELAY);
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:18,代码来源:ViewfinderView.java

示例4: onDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    canvas.setDrawFilter(new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG));
    if (mAnimator_visible.isRunning()) {
        int x = (int) mAnimator_visible.getAnimatedValue();
        drawClear(x, canvas);
        invalidate();
    } else if (isVisible) {
        drawClear(0, canvas);
    }

    if (mAnimator_gone.isRunning()) {
        float scale = (float) mAnimator_gone.getAnimatedValue();
        drawClearGone(scale, canvas);
        invalidate();
    }
}
 
开发者ID:yuhodev,项目名称:login,代码行数:19,代码来源:ClearEditText.java

示例5: onDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    //从canvas层面去除绘制时的锯齿
    canvas.setDrawFilter(mDrawFilter);
    for(int i=0,j=0,k=0;i<mTotalWidth;i++){

        if(i+mXOneOffset<mTotalWidth){//第一条波纹图形绘制
            canvas.drawLine(i,mTotalHeight-mYPositions[mXOneOffset+i]-WaveHeight,i,mTotalHeight,mWavePaint);
        }else {//大于周期值,则设置为j(与相位相关,已移动的X距离,最大值为一个周期,即控件的宽度)
            canvas.drawLine(i,mTotalHeight-mYPositions[j]-WaveHeight,i,mTotalHeight,mWavePaint);
            j++;
        }

        if(i+mXTwoOffset<mTotalWidth){//第二条波纹图形绘制
            canvas.drawLine(i,mTotalHeight-mYPositions[mXTwoOffset+i]-WaveHeight,i,mTotalHeight,mWavePaint1);
        }else {//大于周期值,则设置为k(与相位相关,已移动的X距离)
            canvas.drawLine(i,mTotalHeight-WaveHeight-mYPositions[k],i,mTotalHeight,mWavePaint1);
            k++;
        }

    }

    // 改变两条波纹的移动点
    mXOneOffset += mXOffsetSpeedOne;
    mXTwoOffset += mXOffsetSpeedTwo;

    // 如果已经移动到结尾处,则重头记录
    if (mXOneOffset >= mTotalWidth) {
        mXOneOffset = 0;
    }
    if (mXTwoOffset > mTotalWidth) {
        mXTwoOffset = 0;
    }

    // 引发view重绘,可以考虑延迟10-30ms重绘,空出时间绘制
    if (isAnim){
        new Thread(mRunnable).start();
    }
}
 
开发者ID:huashengzzz,项目名称:SmartChart,代码行数:41,代码来源:DoubleWaveView.java

示例6: dispatchDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
protected void dispatchDraw(@NonNull Canvas canvas) {
    PaintFlagsDrawFilter pfd = new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint
            .FILTER_BITMAP_FLAG);
    canvas.setDrawFilter(pfd);
    final int count = getChildCount();
    for (int i = 0; i < count; i++) {
        final View child = getChildAt(i);
        if (child == null)
            return;
    }
    super.dispatchDraw(canvas);
}
 
开发者ID:Manuaravind1989,项目名称:FlowingSidebarMenu--Android,代码行数:14,代码来源:DrawerLayout.java

示例7: onDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
    mPath.reset();
    mPath.addRoundRect(mRectF, rids, Path.Direction.CW);
    canvas.setDrawFilter(paintFlagsDrawFilter);
    canvas.save();
    canvas.clipPath(mPath);
    super.onDraw(canvas);
    canvas.restore();
}
 
开发者ID:yuqirong,项目名称:CardSwipeLayout,代码行数:11,代码来源:RoundImageView.java

示例8: onDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    canvas.setDrawFilter(this.pfdf);
    drawBg(canvas);
    drawRuler(canvas);
    drawIndicator(canvas);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:8,代码来源:BooheeRulerView.java

示例9: onDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
    canvas.setDrawFilter(pfd);
    if (currentPoint == null) {
        currentPoint = new Point(width, height);
        drawShade(canvas);
        startShadeAnimation();
    } else {
        drawShade(canvas);
    }
}
 
开发者ID:NickKJ,项目名称:Mask-Animation,代码行数:12,代码来源:ShadeTriangleTotalForRankView.java

示例10: onDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
    canvas.setDrawFilter(mDrawFilter);
    super.onDraw(canvas);
    drawLines(canvas);
}
 
开发者ID:stytooldex,项目名称:stynico,代码行数:7,代码来源:SunLineView.java

示例11: draw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
public void draw(Canvas canvas) {
    canvas.setDrawFilter(pfd);
    canvas.drawCircle(getWidth() / 2, getHeight() / 2, Math.max(getWidth(), getHeight()) / 2, mBgPaint);
    super.draw(canvas);
}
 
开发者ID:lpy19930103,项目名称:MinimalismJotter,代码行数:7,代码来源:CircleView.java

示例12: getView

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    final ApplicationInfo info = mApplications.get(position);

    if (convertView == null) {
        final LayoutInflater inflater = getLayoutInflater();
        convertView = inflater.inflate(R.layout.application, parent, false);
    }

    Drawable icon = info.icon;

    if (!info.filtered) {
        //final Resources resources = getContext().getResources();
        int width = 42;//(int) resources.getDimension(android.R.dimen.app_icon_size);
        int height = 42;//(int) resources.getDimension(android.R.dimen.app_icon_size);

        final int iconWidth = icon.getIntrinsicWidth();
        final int iconHeight = icon.getIntrinsicHeight();

        if (icon instanceof PaintDrawable) {
            PaintDrawable painter = (PaintDrawable) icon;
            painter.setIntrinsicWidth(width);
            painter.setIntrinsicHeight(height);
        }

        if (width > 0 && height > 0 && (width < iconWidth || height < iconHeight)) {
            final float ratio = (float) iconWidth / iconHeight;

            if (iconWidth > iconHeight) {
                height = (int) (width / ratio);
            } else if (iconHeight > iconWidth) {
                width = (int) (height * ratio);
            }

            final Bitmap.Config c =
                    icon.getOpacity() != PixelFormat.OPAQUE ?
                        Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565;
            final Bitmap thumb = Bitmap.createBitmap(width, height, c);
            final Canvas canvas = new Canvas(thumb);
            canvas.setDrawFilter(new PaintFlagsDrawFilter(Paint.DITHER_FLAG, 0));
            // Copy the old bounds to restore them later
            // If we were to do oldBounds = icon.getBounds(),
            // the call to setBounds() that follows would
            // change the same instance and we would lose the
            // old bounds
            mOldBounds.set(icon.getBounds());
            icon.setBounds(0, 0, width, height);
            icon.draw(canvas);
            icon.setBounds(mOldBounds);
            icon = info.icon = new BitmapDrawable(thumb);
            info.filtered = true;
        }
    }

    final TextView textView = (TextView) convertView.findViewById(R.id.label);
    textView.setCompoundDrawablesWithIntrinsicBounds(null, icon, null, null);
    textView.setText(info.title);

    return convertView;
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:61,代码来源:Home.java


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