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


Java Paint.setFlags方法代码示例

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


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

示例1: blur

import android.graphics.Paint; //导入方法依赖的package包/类
public static void blur(Context context,Bitmap bkg, View view) {
    long startMs = System.currentTimeMillis();
    float radius = 15;
    float scaleFactor = 8;
    //放大到整个view的大小
    bkg = DrawableProvider.getReSizeBitmap(bkg, view.getMeasuredWidth(), view.getMeasuredHeight());

    Bitmap overlay = Bitmap.createBitmap((int) (view.getMeasuredWidth() / scaleFactor)
            , (int) (view.getMeasuredHeight() / scaleFactor), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(overlay);
    canvas.translate(-view.getLeft() / scaleFactor, -view.getTop() / scaleFactor);
    canvas.scale(1 / scaleFactor, 1 / scaleFactor);
    Paint paint = new Paint();
    paint.setFlags(Paint.FILTER_BITMAP_FLAG);
    canvas.drawBitmap(bkg, 0, 0, paint);
    overlay = FastBlur.doBlur(overlay, (int) radius, true);
    view.setBackgroundDrawable(new BitmapDrawable(context.getResources(), overlay));
    Log.w("test", "cost " + (System.currentTimeMillis() - startMs) + "ms");
}
 
开发者ID:snowwolf10285,项目名称:PicShow-zhaipin,代码行数:20,代码来源:FastBlur.java

示例2: blur_3

import android.graphics.Paint; //导入方法依赖的package包/类
@SuppressLint({"NewApi"})
public static void blur_3(Context context, Bitmap bkg, View view) {
    long startMs = System.currentTimeMillis();
    Display d = ((Activity) context).getWindowManager().getDefaultDisplay();
    Bitmap overlay = Bitmap.createBitmap((int) (((float) d.getWidth()) / 1.0f), (int) (((float) d.getHeight()) / 1.0f), Config.ARGB_8888);
    Canvas canvas = new Canvas(overlay);
    canvas.scale(1.0f / 1.0f, 1.0f / 1.0f);
    Paint paint = new Paint();
    paint.setFlags(2);
    canvas.drawBitmap(bkg, 0.0f, 0.0f, paint);
    overlay = FastBlur.doBlur(overlay, (int) 100.0f, true);
    if (LetvUtils.getSDKVersion() >= 16) {
        view.setBackground(new BitmapDrawable(context.getResources(), overlay));
    } else {
        view.setBackgroundDrawable(new BitmapDrawable(context.getResources(), overlay));
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:18,代码来源:BlurUtils.java

示例3: blur

import android.graphics.Paint; //导入方法依赖的package包/类
public static void blur(Bitmap bkg, View view) {
    long startMs = System.currentTimeMillis();
    float radius = 15;
    float scaleFactor = 8;
    //放大到整个view的大小
    bkg = DrawableProvider.getReSizeBitmap(bkg, view.getMeasuredWidth(), view.getMeasuredHeight());

    Bitmap overlay = Bitmap.createBitmap((int) (view.getMeasuredWidth() / scaleFactor)
            , (int) (view.getMeasuredHeight() / scaleFactor), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(overlay);
    canvas.translate(-view.getLeft() / scaleFactor, -view.getTop() / scaleFactor);
    canvas.scale(1 / scaleFactor, 1 / scaleFactor);
    Paint paint = new Paint();
    paint.setFlags(Paint.FILTER_BITMAP_FLAG);
    canvas.drawBitmap(bkg, 0, 0, paint);
    overlay = FastBlur.doBlur(overlay, (int) radius, true);
    view.setBackgroundDrawable(new BitmapDrawable(UiUtils.getResources(), overlay));
    Log.w("test", "cost " + (System.currentTimeMillis() - startMs) + "ms");
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:FastBlur.java

示例4: init

import android.graphics.Paint; //导入方法依赖的package包/类
private void init(Context context) {
    setWillNotDraw(false);
    setVisibility(INVISIBLE);

    lineStroke = Utils.dpToPx(4);
    isReady = false;
    isRevealAnimationEnabled = true;
    dismissOnTouch = false;
    isPerformClick = false;
    enableDismissAfterShown = false;
    dismissOnBackPress = false;
    handler = new Handler();
    preferencesManager = new PreferencesManager(context);
    eraser = new Paint();
    eraser.setColor(0xFFFFFFFF);
    eraser.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
    eraser.setFlags(Paint.ANTI_ALIAS_FLAG);
}
 
开发者ID:HueToYou,项目名称:ChatExchange-old,代码行数:19,代码来源:SpotlightView.java

示例5: blurBitmap

import android.graphics.Paint; //导入方法依赖的package包/类
public static Bitmap blurBitmap(Bitmap bkg, int width, int height) {
    long startMs = System.currentTimeMillis();
    float radius = 15;//越大模糊效果越大
    float scaleFactor = 8;
    //放大到整个view的大小
    bkg = DrawableProvider.getReSizeBitmap(bkg, width, height);
    Bitmap overlay = Bitmap.createBitmap((int) (width / scaleFactor)
            , (int) (height / scaleFactor), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(overlay);
    canvas.scale(1 / scaleFactor, 1 / scaleFactor);
    Paint paint = new Paint();
    paint.setFlags(Paint.FILTER_BITMAP_FLAG);
    canvas.drawBitmap(bkg, 0, 0, paint);
    overlay = FastBlur.doBlur(overlay, (int) radius, true);
    Log.w("test", "cost " + (System.currentTimeMillis() - startMs) + "ms");
    return overlay;
}
 
开发者ID:VK2012,项目名称:AppCommonFrame,代码行数:18,代码来源:FastBlur.java

示例6: blur

import android.graphics.Paint; //导入方法依赖的package包/类
public static void blur(Context context, Bitmap bkg, View view) {
    long startMs = System.currentTimeMillis();
    float radius = 15;
    float scaleFactor = 8;
    //放大到整个view的大小
    bkg = DrawableProvider.getReSizeBitmap(bkg, view.getMeasuredWidth(), view.getMeasuredHeight());

    Bitmap overlay = Bitmap.createBitmap((int) (view.getMeasuredWidth() / scaleFactor)
            , (int) (view.getMeasuredHeight() / scaleFactor), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(overlay);
    canvas.translate(-view.getLeft() / scaleFactor, -view.getTop() / scaleFactor);
    canvas.scale(1 / scaleFactor, 1 / scaleFactor);
    Paint paint = new Paint();
    paint.setFlags(Paint.FILTER_BITMAP_FLAG);
    canvas.drawBitmap(bkg, 0, 0, paint);
    overlay = FastBlur.doBlur(overlay, (int) radius, true);
    view.setBackgroundDrawable(new BitmapDrawable(context.getResources(), overlay));
    Log.w("test", "cost " + (System.currentTimeMillis() - startMs) + "ms");
}
 
开发者ID:devzwy,项目名称:NeiHanDuanZiTV,代码行数:20,代码来源:FastBlur.java

示例7: onFinishInflate

import android.graphics.Paint; //导入方法依赖的package包/类
@Override
public void onFinishInflate() {
    super.onFinishInflate();

    backgroundColour = CustomApp.getInstance().getResources().getColor(R.color.colorPrimary);
    progressColour = CustomApp.getInstance().getResources().getColor(R.color.colorPrimaryDark);

    paint = new Paint();
    paint.setFlags(Paint.ANTI_ALIAS_FLAG);
    paint.setStyle(Paint.Style.FILL_AND_STROKE);
}
 
开发者ID:erdo,项目名称:asaf-project,代码行数:12,代码来源:AnimatedTastyRatingBar.java

示例8: transform

import android.graphics.Paint; //导入方法依赖的package包/类
@Override
protected Bitmap transform(@NonNull BitmapPool pool, @NonNull Bitmap toTransform, int outWidth, int outHeight) {
    int width = toTransform.getWidth();
    int height = toTransform.getHeight();
    int scaledWidth = width / sampling;
    int scaledHeight = height / sampling;

    Bitmap bitmap = pool.get(scaledWidth, scaledHeight, Bitmap.Config.ARGB_8888);

    Canvas canvas = new Canvas(bitmap);
    canvas.scale(1 / (float) sampling, 1 / (float) sampling);
    Paint paint = new Paint();
    paint.setFlags(Paint.FILTER_BITMAP_FLAG);
    canvas.drawBitmap(toTransform, 0, 0, paint);
    // Allocate memory for Renderscript to work with
    Allocation input = Allocation.createFromBitmap(
            rs,
            bitmap,
            Allocation.MipmapControl.MIPMAP_FULL,
            Allocation.USAGE_SHARED
    );
    Allocation output = Allocation.createTyped(rs, input.getType());
    rs.setMessageHandler(new RenderScript.RSMessageHandler());

    // Load up an instance of the specific script that we want to use.
    ScriptIntrinsicBlur script = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
    script.setInput(input);

    // Set the blur radius
    script.setRadius(radius);

    // Start the ScriptIntrinisicBlur
    script.forEach(output);

    // Copy the output to the blurred bitmap
    output.copyTo(bitmap);


    return bitmap;
}
 
开发者ID:YugengWang,项目名称:OneWeather,代码行数:41,代码来源:BlurTransformation.java

示例9: of

import android.graphics.Paint; //导入方法依赖的package包/类
public static Bitmap of(Context context, Bitmap source, BlurFactor factor) {
  int width = factor.width / factor.sampling;
  int height = factor.height / factor.sampling;

  if (Helper.hasZero(width, height)) {
    return null;
  }

  Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);

  Canvas canvas = new Canvas(bitmap);
  canvas.scale(1 / (float) factor.sampling, 1 / (float) factor.sampling);
  Paint paint = new Paint();
  paint.setFlags(Paint.FILTER_BITMAP_FLAG | Paint.ANTI_ALIAS_FLAG);
  PorterDuffColorFilter filter =
      new PorterDuffColorFilter(factor.color, PorterDuff.Mode.SRC_ATOP);
  paint.setColorFilter(filter);
  canvas.drawBitmap(source, 0, 0, paint);

  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
    try {
      bitmap = Blur.rs(context, bitmap, factor.radius);
    } catch (RSRuntimeException e) {
      bitmap = Blur.stack(bitmap, factor.radius, true);
    }
  } else {
    bitmap = Blur.stack(bitmap, factor.radius, true);
  }

  if (factor.sampling == BlurFactor.DEFAULT_SAMPLING) {
    return bitmap;
  } else {
    Bitmap scaled = Bitmap.createScaledBitmap(bitmap, factor.width, factor.height, true);
    bitmap.recycle();
    return scaled;
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:38,代码来源:Blur.java

示例10: init

import android.graphics.Paint; //导入方法依赖的package包/类
private void init(AttributeSet attrs, int defStyle) {
    final TypedArray a = getContext().obtainStyledAttributes(
            attrs, R.styleable.RoundedLetterView, defStyle, 0);

    if(a.hasValue(R.styleable.RoundedLetterView_rlv_titleText)){
        mTitleText = a.getString(R.styleable.RoundedLetterView_rlv_titleText);
    }

    mTitleColor = a.getColor(R.styleable.RoundedLetterView_rlv_titleColor,DEFAULT_TITLE_COLOR);
    mBackgroundColor = a.getColor(R.styleable.RoundedLetterView_rlv_backgroundColorValue,DEFAULT_BACKGROUND_COLOR);

    mTitleSize = a.getDimension(R.styleable.RoundedLetterView_rlv_titleSize,DEFAULT_TITLE_SIZE);
    a.recycle();

    //Title TextPaint
    mTitleTextPaint = new TextPaint();
    mTitleTextPaint.setFlags(Paint.ANTI_ALIAS_FLAG);
    mTitleTextPaint.setTypeface(mFont);
    mTitleTextPaint.setTextAlign(Paint.Align.CENTER);
    mTitleTextPaint.setLinearText(true);
    mTitleTextPaint.setColor(mTitleColor);
    mTitleTextPaint.setTextSize(mTitleSize);

    //Background Paint
    mBackgroundPaint = new Paint();
    mBackgroundPaint.setFlags(Paint.ANTI_ALIAS_FLAG);
    mBackgroundPaint.setStyle(Paint.Style.FILL);
    mBackgroundPaint.setColor(mBackgroundColor);

    mInnerRectF = new RectF();
}
 
开发者ID:broakenmedia,项目名称:MultiContactPicker,代码行数:32,代码来源:RoundLetterView.java

示例11: transform

import android.graphics.Paint; //导入方法依赖的package包/类
@Override
public Resource<Bitmap> transform(Resource<Bitmap> resource, int outWidth, int outHeight) {
    Bitmap source = resource.get();

    int width = source.getWidth();
    int height = source.getHeight();
    int scaledWidth = width / mSampling;
    int scaledHeight = height / mSampling;

    Bitmap bitmap = mBitmapPool.get(scaledWidth, scaledHeight, Bitmap.Config.ARGB_8888);
    if (bitmap == null) {
        bitmap = Bitmap.createBitmap(scaledWidth, scaledHeight, Bitmap.Config.ARGB_8888);
    }

    Canvas canvas = new Canvas(bitmap);
    canvas.scale(1 / (float) mSampling, 1 / (float) mSampling);
    Paint paint = new Paint();
    paint.setFlags(Paint.FILTER_BITMAP_FLAG);
    canvas.drawBitmap(source, 0, 0, paint);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        try {
            bitmap = RSBlur.blur(mContext, bitmap, mRadius);
        } catch (RSRuntimeException e) {
            bitmap = FastBlur.blur(bitmap, mRadius, true);
        }
    } else {
        bitmap = FastBlur.blur(bitmap, mRadius, true);
    }

    return BitmapResource.obtain(bitmap, mBitmapPool);
}
 
开发者ID:HanyeeWang,项目名称:GeekZone,代码行数:33,代码来源:BlurTransformation.java

示例12: init

import android.graphics.Paint; //导入方法依赖的package包/类
private void init(AttributeSet attrs, int defStyle) {
    mDensity = getContext().getResources().getDisplayMetrics().density;
    scaledDensity = getContext().getResources().getDisplayMetrics().scaledDensity;

    // Load attributes
    final TypedArray a = getContext().obtainStyledAttributes(
            attrs, R.styleable.RoundChoiceView, defStyle, 0);
    mUnCheckColor = a.getColor(R.styleable.RoundChoiceView_borderColor, mUnCheckColor);
    mCheckColor = a.getColor(R.styleable.RoundChoiceView_checkedColor, mCheckColor);
    mCrossColor = a.getColor(R.styleable.RoundChoiceView_crossColor, mCrossColor);
    mBgColor = a.getColor(R.styleable.RoundChoiceView_backgroundColor, mBgColor);
    mTextSize = a.getDimension(R.styleable.RoundChoiceView_textSize, mTextSize);
    int crossType = a.getInt(R.styleable.RoundChoiceView_crossType, TYPE_CROSS_CROSS);
    if (crossType == TYPE_CROSS_NUMBER) {
        mCrossType = TYPE_CROSS_NUMBER;
    } else {
        mCrossType = TYPE_CROSS_CROSS;
    }
    mBorderWidth = a.getDimension(R.styleable.RoundChoiceView_rippleBorderWidth, dp2px(2));
    mDuration = a.getInt(R.styleable.RoundChoiceView_rippleduration, mDuration);
    mChecked = a.getBoolean(R.styleable.RoundChoiceView_checked, mChecked);
    mNumber = a.getInt(R.styleable.RoundChoiceView_number, mNumber);
    a.recycle();
    mHookDuration = (int) (mDuration * 0.3);
    mCircleDuration = mDuration - mHookDuration;
    mUncheckPaint = new Paint();
    mUncheckPaint.setFlags(Paint.ANTI_ALIAS_FLAG);
    mUncheckPaint.setStrokeWidth(mBorderWidth);
    mUncheckPaint.setColor(mUnCheckColor);
    mUncheckPaint.setStyle(Paint.Style.STROKE);
    mCheckPaint = new Paint();
    mCheckPaint.setFlags(Paint.ANTI_ALIAS_FLAG);
    mCheckPaint.setColor(mCheckColor);
    mCheckPaint.setStyle(Paint.Style.STROKE);
    isHookShow = mChecked;
    mFraction = mChecked ? 1.0f : 0.0f;
}
 
开发者ID:klisly,项目名称:RoundChoiceView,代码行数:38,代码来源:RoundChoiceView.java

示例13: init

import android.graphics.Paint; //导入方法依赖的package包/类
private void init(Context context, AttributeSet attrs) {
    //init the value
    borderWidth = 0;
    borderColor = 0xddffffff;
    pressAlpha = 0x42;
    pressColor = 0x42000000;
    radius = 16;
    shapeType = 0;

    // get attribute of EaseImageView
    if (attrs != null) {
        TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.EaseImageView);
        borderColor = array.getColor(R.styleable.EaseImageView_ease_border_color, borderColor);
        borderWidth = array.getDimensionPixelOffset(R.styleable.EaseImageView_ease_border_width, borderWidth);
        pressAlpha = array.getInteger(R.styleable.EaseImageView_ease_press_alpha, pressAlpha);
        pressColor = array.getColor(R.styleable.EaseImageView_ease_press_color, pressColor);
        radius = array.getDimensionPixelOffset(R.styleable.EaseImageView_ease_radius, radius);
        shapeType = array.getInteger(R.styleable.EaseImageView_ease_shape_type, shapeType);
        array.recycle();
    }

    // set paint when pressed
    pressPaint = new Paint();
    pressPaint.setAntiAlias(true);
    pressPaint.setStyle(Paint.Style.FILL);
    pressPaint.setColor(pressColor);
    pressPaint.setAlpha(0);
    pressPaint.setFlags(Paint.ANTI_ALIAS_FLAG);

    setClickable(true);
    setDrawingCacheEnabled(true);
    setWillNotDraw(false);
}
 
开发者ID:Vicent9920,项目名称:FanChat,代码行数:34,代码来源:EaseImageView.java

示例14: saveFileAddedVoice

import android.graphics.Paint; //导入方法依赖的package包/类
private boolean saveFileAddedVoice(String path, String voice, String savePath) {
    LogInfo.log("fornia", "voice:" + voice);
    if (!new File(path).exists()) {
        return false;
    }
    Options options = new Options();
    options.inJustDecodeBounds = false;
    Bitmap bitmap0 = BitmapFactory.decodeFile(path, options);
    int width = options.outWidth;
    int height = options.outHeight;
    Bitmap bitmapPic = Bitmap.createBitmap(width, height, Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmapPic);
    canvas.drawBitmap(bitmap0, null, new Rect(0, 0, width, height), null);
    Rect targetBgRect = new Rect(0, height - getTextBgHeight(), width, height);
    if (!isOrigPicMode) {
        Paint voiceBgPaint = new Paint();
        voiceBgPaint.setColor(getResources().getColor(2131493164));
        voiceBgPaint.setStyle(Style.FILL);
        voiceBgPaint.setFlags(2);
        canvas.drawRect(targetBgRect, voiceBgPaint);
        voiceBgPaint.setColor(-1);
        voiceBgPaint.setTextSize((float) getTextSize());
        voiceBgPaint.setTextAlign(Align.CENTER);
        FontMetricsInt fontMetrics = voiceBgPaint.getFontMetricsInt();
        String str = voice;
        canvas.drawText(str, (float) targetBgRect.centerX(), (float) ((targetBgRect.top + ((((targetBgRect.bottom - targetBgRect.top) - fontMetrics.bottom) + fontMetrics.top) / 2)) - fontMetrics.top), voiceBgPaint);
    }
    return FileUtils.saveBitmapByUser(this.mContext, bitmapPic);
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:30,代码来源:VideoShotEditActivity.java

示例15: getBoxTakeBitmap

import android.graphics.Paint; //导入方法依赖的package包/类
/**
 * 子View 框取 父View的背景
 * @param root 一级父View
 * @param child 一级子View
 * @return Bitmap
 */
public Bitmap getBoxTakeBitmap(View root, View child){
    root.buildDrawingCache();
    Bitmap bmp = root.getDrawingCache();

    Bitmap bitmap = Bitmap.createBitmap(child.getWidth(),
            child.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    canvas.translate(-child.getLeft(), -child.getTop());
    canvas.scale(1, 1);
    Paint paint = new Paint();
    paint.setFlags(Paint.FILTER_BITMAP_FLAG);
    canvas.drawBitmap(bmp, 0, 0, paint);
    return bitmap;
}
 
开发者ID:A-Miracle,项目名称:QiangHongBao,代码行数:21,代码来源:ViewUtils.java


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