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


Java Paint.FILTER_BITMAP_FLAG属性代码示例

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


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

示例1: IconCache

public IconCache(Context context, InvariantDeviceProfile inv) {
    mContext = context;
    mPackageManager = context.getPackageManager();
    mUserManager = UserManagerCompat.getInstance(mContext);
    mLauncherApps = LauncherAppsCompat.getInstance(mContext);
    mIconDpi = inv.fillResIconDpi;
    mIconDb = new IconDB(context, inv.iconBitmapSize);
    mLowResCanvas = new Canvas();
    mLowResPaint = new Paint(Paint.FILTER_BITMAP_FLAG | Paint.ANTI_ALIAS_FLAG);

    mIconProvider = IconProvider.loadByName(context.getString(R.string.icon_provider_class),
            context);

    mWorkerHandler = new Handler(LauncherModel.getWorkerLooper());

    mActivityBgColor = context.getResources().getColor(R.color.quantum_panel_bg_color);
    TypedArray ta = context.obtainStyledAttributes(new int[]{R.attr.colorSecondary});
    mPackageBgColor = ta.getColor(0, 0);
    ta.recycle();
    mLowResOptions = new BitmapFactory.Options();
    // Always prefer RGB_565 config for low res. If the bitmap has transparency, it will
    // automatically be loaded as ALPHA_8888.
    mLowResOptions.inPreferredConfig = Bitmap.Config.RGB_565;
}
 
开发者ID:TeamBrainStorm,项目名称:SimpleUILauncher,代码行数:24,代码来源:IconCache.java

示例2: circleCrop

private static Bitmap circleCrop(BitmapPool pool, Bitmap source) {
    if (source == null) return null;

    int size = Math.min(source.getWidth(), source.getHeight());
    int x = (source.getWidth() - size) / 2;
    int y = (source.getHeight() - size) / 2;

    // TODO this could be acquired from the pool too
    Bitmap squared = Bitmap.createBitmap(source, x, y, size, size);

    Bitmap result = pool.get(size, size, Bitmap.Config.ARGB_8888);
    if (result == null) {
        result = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
    }

    Canvas canvas = new Canvas(result);
    Paint paint = new Paint(Paint.FILTER_BITMAP_FLAG | Paint.DITHER_FLAG | Paint
            .ANTI_ALIAS_FLAG);
    paint.setShader(new BitmapShader(squared, BitmapShader.TileMode.CLAMP, BitmapShader
            .TileMode.CLAMP));
    float r = size / 2f;
    canvas.drawCircle(r, r, r, paint);
    return result;
}
 
开发者ID:HanyeeWang,项目名称:GeekZone,代码行数:24,代码来源:CircleTransform.java

示例3: init

private void init() {
    Log.i(Tag, "init");

    mLineWidth = changeDp(1);
    mLineHeight = changeDp(3);
    mFixLineHeight = changeDp(6);
    mSunRadius = changeDp(12);
    mLineColor = Color.RED;
    mLineLevel = 30;

    //线的配置
    mLinePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mLinePaint.setColor(mLineColor);
    mLinePaint.setStyle(Paint.Style.FILL_AND_STROKE);
    // 设置画笔宽度
    mLinePaint.setStrokeWidth(mLineWidth);
    mDrawFilter = new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG
            | Paint.FILTER_BITMAP_FLAG);
    debugRect = new Rect();
    mouthRect = new RectF();
}
 
开发者ID:stytooldex,项目名称:stynico,代码行数:21,代码来源:SunLineView.java

示例4: dispatchDraw

@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,代码行数:25,代码来源:BuildLayerFrameLayout.java

示例5: CropView

public CropView(Context context, AttributeSet attrs) {
    super(context, attrs);
    mDetectorCompat = new GestureDetectorCompat(getContext(), new GestureListener());
    mScaleDetector = new ScaleGestureDetector(getContext(), new ScaleGestureListener());

    mBitmapOptions = new BitmapFactory.Options();

    mPaint = new Paint(Paint.FILTER_BITMAP_FLAG);
    mRectPaint = new Paint();
    mRectPaint.setStyle(Paint.Style.STROKE);
    mRectPaint.setStrokeWidth(1f);
    mBorderPaint = new Paint();
    mBorderPaint.setColor(Color.BLACK);

    mCanvasDrawRect = new Rect();
    mImageDrawRect = new Rect();
    mCacheRect = new Rect();
    mOutputRect = new Rect();

    mSmallImage = false;
    mImageOK = false;

    mLabelCollection = new LabelCollection();
}
 
开发者ID:olgamiller,项目名称:SSTVEncoder2,代码行数:24,代码来源:CropView.java

示例6: init

private void init(Context context, AttributeSet attrs, int defStyle) {
    TypedArray type = context.obtainStyledAttributes(attrs, R.styleable.ShadeTriangleTotalForRankView, 0, 0);
    duration = (long) type.getFloat(R.styleable.ShadeTriangleTotalForRankView_shade_duration, 18000f);
    mImageSource_total = type.getResourceId(R.styleable.ShadeTriangleTotalForRankView_image_total, R.drawable.mask_triangle_total);
    mTotal_bitmap = readBitMap(context, mImageSource_total);
    mPaint_Mask.setStyle(Paint.Style.FILL);
    mPaint_Mask.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
    mPaint_Pic.setFilterBitmap(true);
    pfd = new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);

    src = new Rect();
    dst = new Rect();
    path = new Path();

}
 
开发者ID:NickKJ,项目名称:Mask-Animation,代码行数:15,代码来源:ShadeTriangleTotalForRankView.java

示例7: ShadowGenerator

private ShadowGenerator(Context context) {
    mIconSize = LauncherAppState.getIDP(context).iconBitmapSize;
    mCanvas = new Canvas();
    mBlurPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
    mBlurPaint.setMaskFilter(new BlurMaskFilter(mIconSize * BLUR_FACTOR, Blur.NORMAL));
    mDrawPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:7,代码来源:ShadowGenerator.java

示例8: resizeBitmapByScale

public static Bitmap resizeBitmapByScale(
        Bitmap bitmap, float scale, boolean recycle) {
    int width = Math.round(bitmap.getWidth() * scale);
    int height = Math.round(bitmap.getHeight() * scale);
    if (width == bitmap.getWidth()
            && height == bitmap.getHeight()) return bitmap;
    Bitmap target = Bitmap.createBitmap(width, height, getConfig(bitmap));
    Canvas canvas = new Canvas(target);
    canvas.scale(scale, scale);
    Paint paint = new Paint(Paint.FILTER_BITMAP_FLAG | Paint.DITHER_FLAG);
    canvas.drawBitmap(bitmap, 0, 0, paint);
    if (recycle) bitmap.recycle();
    return target;
}
 
开发者ID:mayurkaul,项目名称:medialibrary,代码行数:14,代码来源:BitmapUtils.java

示例9: ClickShadowView

public ClickShadowView(Context context) {
    super(context);
    mPaint = new Paint(Paint.FILTER_BITMAP_FLAG);
    mPaint.setColor(Color.BLACK);

    mShadowPadding = getResources().getDimension(R.dimen.blur_size_click_shadow);
    mShadowOffset = getResources().getDimension(R.dimen.click_shadow_high_shift);
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:8,代码来源:ClickShadowView.java

示例10: fastBlur

/**
 * 快速模糊图片
 * <p>先缩小原图,对小图进行模糊,再放大回原先尺寸</p>
 *
 * @param src     源图片
 * @param scale   缩放比例(0...1)
 * @param radius  模糊半径
 * @param recycle 是否回收
 * @return 模糊后的图片
 */
public static Bitmap fastBlur(Bitmap src, float scale, float radius, boolean recycle) {
    if (isEmptyBitmap(src)) return null;
    int width = src.getWidth();
    int height = src.getHeight();
    int scaleWidth = (int) (width * scale + 0.5f);
    int scaleHeight = (int) (height * scale + 0.5f);
    if (scaleWidth == 0 || scaleHeight == 0) return null;
    Bitmap scaleBitmap = Bitmap.createScaledBitmap(src, scaleWidth, scaleHeight, true);
    Paint paint = new Paint(Paint.FILTER_BITMAP_FLAG | Paint.ANTI_ALIAS_FLAG);
    Canvas canvas = new Canvas();
    PorterDuffColorFilter filter = new PorterDuffColorFilter(
            Color.TRANSPARENT, PorterDuff.Mode.SRC_ATOP);
    paint.setColorFilter(filter);
    canvas.scale(scale, scale);
    canvas.drawBitmap(scaleBitmap, 0, 0, paint);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        scaleBitmap = renderScriptBlur(Utils.getContext(), scaleBitmap, radius);
    } else {
        scaleBitmap = stackBlur(scaleBitmap, (int) radius, recycle);
    }
    if (scale == 1) return scaleBitmap;
    Bitmap ret = Bitmap.createScaledBitmap(scaleBitmap, width, height, true);
    if (scaleBitmap != null && !scaleBitmap.isRecycled()) scaleBitmap.recycle();
    if (recycle && !src.isRecycled()) src.recycle();
    return ret;
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:36,代码来源:ImageUtils.java

示例11: PercentClipHelper

PercentClipHelper(@NonNull View view, @Nullable AttributeSet attrs) {
    this.view = view;
    this.params = new ClipParams(view.getContext(), attrs);
    this.paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    this.maskPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
    this.maskPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
    view.setWillNotDraw(false);
}
 
开发者ID:pine,项目名称:PercentClipView,代码行数:8,代码来源:PercentClipHelper.java

示例12: SwitchDrawable

SwitchDrawable(
        @Nonnull Bitmap startBitmap,
        @Nonnull Rect startBitmapSrcBounds,
        float startFontSize,
        @Nonnull Bitmap endBitmap,
        @Nonnull Rect endBitmapSrcBounds,
        float endFontSize) {
    currentBitmap = startBitmap;
    currentBitmapSrcBounds = startBitmapSrcBounds;
    this.endBitmap = endBitmap;
    this.endBitmapSrcBounds = endBitmapSrcBounds;
    switchThreshold = startFontSize / (startFontSize + endFontSize);
    paint = new Paint(Paint.FILTER_BITMAP_FLAG | Paint.DITHER_FLAG);
}
 
开发者ID:shazam,项目名称:reflow-animator,代码行数:14,代码来源:SwitchDrawable.java

示例13: upscaleToScreenSize

private Bitmap upscaleToScreenSize(Bitmap bitmap) {
    WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    display.getRealMetrics(mDisplayMetrics);

    int width = mDisplayMetrics.widthPixels, height = mDisplayMetrics.heightPixels;

    float widthFactor = 0f, heightFactor = 0f;
    if (width > bitmap.getWidth()) {
        widthFactor = ((float) width) / bitmap.getWidth();
    }
    if (height > bitmap.getHeight()) {
        heightFactor = ((float) height) / bitmap.getHeight();
    }

    float upscaleFactor = Math.max(widthFactor, heightFactor);
    if (upscaleFactor <= 0) {
        return bitmap;
    }

    int scaledWidth = (int) (bitmap.getWidth() * upscaleFactor);
    int scaledHeight = (int) (bitmap.getHeight() * upscaleFactor);
    Bitmap scaled = Bitmap.createScaledBitmap(
            bitmap,
            scaledWidth,
            scaledHeight, false);

    Bitmap result = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas();
    canvas.setBitmap(result);

    Paint paint = new Paint(Paint.FILTER_BITMAP_FLAG | Paint.ANTI_ALIAS_FLAG);
    if (widthFactor > heightFactor) {
        canvas.drawBitmap(scaled, 0, (height - scaledHeight) / 2, paint);
    } else {
        canvas.drawBitmap(scaled, (width - scaledWidth) / 2, 0, paint);
    }

    return result;
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:40,代码来源:BlurWallpaperProvider.java

示例14: init

private void init() {
    rectPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
    loaderView.setRectColor(rectPaint);
    setValueAnimator(0.5f, 1, ObjectAnimator.INFINITE);
}
 
开发者ID:sathishmscict,项目名称:loaderviewlibrary-shading,代码行数:5,代码来源:LoaderController.java

示例15: init

private void init(Context context, AttributeSet attrs) {
    //抗锯齿和位图滤波
    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);

    //读取xml文件中的配置
    if (attrs != null) {
        TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.PowerfulEditText);
        for (int i = 0; i < array.getIndexCount(); i++) {
            int attr = array.getIndex(i);

            switch (attr) {
                case R.styleable.PowerfulEditText_clearDrawable:
                    mClearResId = array.getResourceId(attr, DEFAULT_CLEAR_RES);
                    break;

                case R.styleable.PowerfulEditText_visibleDrawable:
                    mVisibleResId = array.getResourceId(attr, DEFAULT_VISIBLE_RES);
                    break;

                case R.styleable.PowerfulEditText_invisibleDrawable:
                    mInvisibleResId = array.getResourceId(attr, DEFAULT_INVISIBLE_RES);
                    break;

                case R.styleable.PowerfulEditText_BtnWidth:
                    mBtnWidth = array.getDimensionPixelSize(attr, DEFAULT_BUTTON_WIDTH);
                    break;

                case R.styleable.PowerfulEditText_BtnSpacing:
                    mBtnPadding = array.getDimensionPixelSize(attr, DEFAULT_BUTTON_PADDING);
                    break;

                case R.styleable.PowerfulEditText_borderStyle:
                    mBorderStyle = array.getString(attr);
                    break;

                case R.styleable.PowerfulEditText_styleColor:
                    mStyleColor = array.getColor(attr, DEFAULT_STYLE_COLOR);
                    break;
            }
        }
        array.recycle();
    }

    //初始化按钮显示的Bitmap
    mBitmapClear = createBitmap(context, mClearResId, DEFAULT_CLEAR_RES);
    mBitmapVisible = createBitmap(context, mVisibleResId, DEFAULT_VISIBLE_RES);
    mBitmapInvisible = createBitmap(context, mInvisibleResId, DEFAULT_INVISIBLE_RES);
    //如果自定义,则使用自定义的值,否则使用默认值
    if (mBtnPadding == 0) {
        mBtnPadding = DEFAULT_BUTTON_PADDING;
    }
    if (mBtnWidth == 0) {
        mBtnWidth = DEFAULT_BUTTON_WIDTH;
    }
    //给文字设置一个padding,避免文字和按钮重叠了
    mTextPaddingRight = mBtnPadding * 4 + mBtnWidth * 2;

    //按钮出现和消失的动画
    mGoneAnimator = ValueAnimator.ofFloat(1f, 0f).setDuration(ANIMATOR_TIME);
    mVisibleAnimator = ValueAnimator.ofFloat(0f, 1f).setDuration(ANIMATOR_TIME);

    //是否是密码样式
    isPassword =
            getInputType() == (InputType.TYPE_TEXT_VARIATION_PASSWORD | InputType.TYPE_CLASS_TEXT);

}
 
开发者ID:AndroidWJC,项目名称:PowerfulEditText,代码行数:66,代码来源:PowerfulEditText.java


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