當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。