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