Example usage for android.graphics Paint DITHER_FLAG

List of usage examples for android.graphics Paint DITHER_FLAG

Introduction

In this page you can find the example usage for android.graphics Paint DITHER_FLAG.

Prototype

int DITHER_FLAG

To view the source code for android.graphics Paint DITHER_FLAG.

Click Source Link

Document

Paint flag that enables dithering when blitting.

Usage

From source file:com.jaspersoft.android.jaspermobile.widget.AnnotationView.java

private void addPath() {
    Paint annotationPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
    annotationPaint.setColor(mColor);//from w  w  w . j  a v a  2s  .  com
    annotationPaint.setStyle(Paint.Style.STROKE);
    annotationPaint.setStrokeJoin(Paint.Join.ROUND);
    annotationPaint.setStrokeCap(Paint.Cap.ROUND);

    DisplayMetrics metrics = getContext().getResources().getDisplayMetrics();
    int strokeSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, mSize, metrics);
    annotationPaint.setStrokeWidth(strokeSize);

    Path annotationPath = new Path();
    annotationPath.moveTo(mStartX, mStartY);

    mDrawingCache.add(new Pair<>(annotationPaint, annotationPath));
}

From source file:com.ichi2.anki.Whiteboard.java

public Whiteboard(AnkiActivity context, boolean inverted, boolean monochrome) {
    super(context, null);
    mActivity = new WeakReference<>(context);
    mInvertedColors = inverted;// w  w  w . j  a  v a 2 s. co  m
    mMonochrome = monochrome;

    int foregroundColor;
    if (!mInvertedColors) {
        if (mMonochrome) {
            foregroundColor = Color.BLACK;
        } else {
            foregroundColor = ContextCompat.getColor(context, R.color.wb_fg_color);
        }
    } else {
        if (mMonochrome) {
            foregroundColor = Color.WHITE;
        } else {
            foregroundColor = ContextCompat.getColor(context, R.color.wb_fg_color_inv);
        }
    }

    mPaint = new Paint();
    mPaint.setAntiAlias(true);
    mPaint.setDither(true);
    mPaint.setColor(foregroundColor);
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setStrokeJoin(Paint.Join.ROUND);
    mPaint.setStrokeCap(Paint.Cap.ROUND);
    int wbStrokeWidth = AnkiDroidApp.getSharedPrefs(context).getInt("whiteBoardStrokeWidth", 6);
    mPaint.setStrokeWidth((float) wbStrokeWidth);
    createBitmap();
    mPath = new Path();
    mBitmapPaint = new Paint(Paint.DITHER_FLAG);
}

From source file:com.cooltechworks.views.ScratchTextView.java

/**
 * Initialises the paint drawing elements.
 *///from   w  w w.  j a v  a  2s .  c  o  m
private void init() {

    mTouchPath = new Path();

    mErasePaint = new Paint();
    mErasePaint.setAntiAlias(true);
    mErasePaint.setDither(true);
    mErasePaint.setColor(0xFFFF0000);
    mErasePaint.setStyle(Paint.Style.STROKE);
    mErasePaint.setStrokeJoin(Paint.Join.BEVEL);
    mErasePaint.setStrokeCap(Paint.Cap.ROUND);
    mErasePaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
    setStrokeWidth(6);

    mGradientBgPaint = new Paint();

    mErasePath = new Path();
    mBitmapPaint = new Paint(Paint.DITHER_FLAG);

    Bitmap scratchBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_scratch_pattern);
    mDrawable = new BitmapDrawable(getResources(), scratchBitmap);
    mDrawable.setTileModeXY(Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);

}

From source file:com.example.scratchview.ScratchImageView.java

/**
 * Initialises the paint drawing elements.
 *//*w  ww .  ja  v a2 s  . c  om*/
private void init() {

    mTouchPath = new Path();

    mErasePaint = new Paint();
    mErasePaint.setAntiAlias(true);
    mErasePaint.setDither(true);
    mErasePaint.setColor(0xFFFF0000);
    mErasePaint.setStyle(Paint.Style.STROKE);
    mErasePaint.setStrokeJoin(Paint.Join.BEVEL);
    mErasePaint.setStrokeCap(Paint.Cap.ROUND);
    setStrokeWidth(6);

    mGradientBgPaint = new Paint();

    mErasePath = new Path();
    mBitmapPaint = new Paint(Paint.DITHER_FLAG);

    Bitmap scratchBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_scratch_pattern);
    mDrawable = new BitmapDrawable(getResources(), scratchBitmap);
    mDrawable.setTileModeXY(Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);

    setEraserMode();

}

From source file:com.azhansy.linky.view.PagerSlidingIndicator.java

public PagerSlidingIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    setFillViewport(true);//from w  ww. j  av a  2  s .c  o  m
    setWillNotDraw(false);

    DisplayMetrics dm = getResources().getDisplayMetrics();

    scrollOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm);

    backgroundStrokeWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, backgroundStrokeWidth,
            dm);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PagerSlidingIndicator);

    shouldExpand = a.getBoolean(R.styleable.PagerSlidingIndicator_shouldExpand, shouldExpand);
    scrollOffset = a.getDimensionPixelSize(R.styleable.PagerSlidingIndicator_scrollOffset, scrollOffset);

    backgroundStrokeColor = a.getColor(R.styleable.PagerSlidingIndicator_background_stroke_color,
            backgroundStrokeColor);
    backgroundStrokeWidth = a.getDimensionPixelSize(R.styleable.PagerSlidingIndicator_background_stroke_width,
            backgroundStrokeWidth);

    backgroundColor = a.getColor(R.styleable.PagerSlidingIndicator_background_color, backgroundColor);

    checkedBackgroundColor = a.getColor(R.styleable.PagerSlidingIndicator_checked_background_color,
            checkedBackgroundColor);

    a.recycle();

    // 
    backgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
    backgroundPaint.setColor(backgroundColor);
    backgroundPaint.setStyle(Style.FILL);

    // 
    checkedBackgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
    checkedBackgroundPaint.setColor(checkedBackgroundColor);
    checkedBackgroundPaint.setStyle(Style.FILL);

    defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.MATCH_PARENT);
    expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f);

}

From source file:com.cooltechworks.views.ScratchImageView.java

/**
 * Initialises the paint drawing elements.
 *///from   w w  w . jav  a2 s.com
private void init() {

    mTouchPath = new Path();

    mErasePaint = new Paint();
    mErasePaint.setAntiAlias(true);
    mErasePaint.setDither(true);
    mErasePaint.setColor(0xFFFF0000);
    mErasePaint.setStyle(Paint.Style.STROKE);
    mErasePaint.setStrokeJoin(Paint.Join.BEVEL);
    mErasePaint.setStrokeCap(Paint.Cap.ROUND);
    setStrokeWidth(6);

    mGradientBgPaint = new Paint();

    mErasePath = new Path();
    mBitmapPaint = new Paint(Paint.DITHER_FLAG);

    Bitmap scratchBitmap;
    if (mCustomScrachView != null) {
        scratchBitmap = ((BitmapDrawable) mCustomScrachView).getBitmap();
    } else {
        scratchBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_scratch_pattern);
    }

    mDrawable = new BitmapDrawable(getResources(), scratchBitmap);
    mDrawable.setTileModeXY(Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);

    setEraserMode();

}

From source file:com.example.SmartBoard.DrawingView.java

private void setupDrawing() {
    //get drawing area setup for interaction
    drawPath = new Path();
    drawPathRecv = new Path();
    drawPaint = new Paint();
    drawPaint.setDither(true);//  w ww.ja  v a 2  s . c om
    drawPaint.setPathEffect(new CornerPathEffect(10));
    drawPaint.setColor(paintColor);
    drawPaint.setAntiAlias(true);
    drawPaint.setStrokeWidth(strokeWidth);
    drawPaint.setStyle(Paint.Style.STROKE);
    drawPaint.setStrokeJoin(Paint.Join.ROUND);
    drawPaint.setStrokeCap(Paint.Cap.ROUND);
    canvasPaint = new Paint(Paint.DITHER_FLAG);

    drawPaintSender = new Paint();
    drawPaintSender.setDither(true);
    drawPaintSender.setPathEffect(new CornerPathEffect(10));
    drawPaintSender.setColor(paintColor);
    drawPaintSender.setAntiAlias(true);
    drawPaintSender.setStrokeWidth(strokeWidth);
    drawPaintSender.setStyle(Paint.Style.STROKE);
    drawPaintSender.setStrokeJoin(Paint.Join.ROUND);
    drawPaintSender.setStrokeCap(Paint.Cap.ROUND);
    client = MQTTHandler.getInstance().getClientHandle();
}

From source file:Main.java

/**
 * This is only used when the launcher shortcut is created.
 *
 * @param bitmap The artist, album, genre, or playlist image that's going to
 *               be cropped.//  w w w  .  j  av a 2 s. com
 * @param size   The new size.
 * @return A {@link Bitmap} that has been resized and cropped for a launcher
 * shortcut.
 */
public static final Bitmap resizeAndCropCenter(final Bitmap bitmap, final int size) {
    final int w = bitmap.getWidth();
    final int h = bitmap.getHeight();
    if (w == size && h == size) {
        return bitmap;
    }

    final float mScale = (float) size / Math.min(w, h);

    final Bitmap mTarget = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
    final int mWidth = Math.round(mScale * bitmap.getWidth());
    final int mHeight = Math.round(mScale * bitmap.getHeight());
    final Canvas mCanvas = new Canvas(mTarget);
    mCanvas.translate((size - mWidth) / 2f, (size - mHeight) / 2f);
    mCanvas.scale(mScale, mScale);
    final Paint paint = new Paint(Paint.FILTER_BITMAP_FLAG | Paint.DITHER_FLAG);
    mCanvas.drawBitmap(bitmap, 0, 0, paint);
    return mTarget;
}

From source file:com.hippo.drawerlayout.DrawerLayout.java

private void init(Context context) {
    mLeftOpened = false;/* w  w  w  .j  a  va  2s  .  co m*/
    mRightOpened = false;
    mLeftState = STATE_CLOSED;
    mRightState = STATE_CLOSED;
    mLeftPercent = 0.0f;
    mRightPercent = 0.0f;
    mMinDrawerMargin = (int) (MIN_DRAWER_MARGIN * context.getResources().getDisplayMetrics().density + 0.5f);
    mDragHelper = ViewDragHelper.create(this, 0.5f, new DragHelperCallback());
    mAnimator = new ValueAnimator();
    mAnimator.setFloatValues(0.0f, 1.0f);
    mAnimator.addUpdateListener(this);
    mAnimator.addListener(this);
    mAnimator.setInterpolator(DRAWER_INTERPOLATOR);
    mCancelAnimation = false;
    mStatusBarPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
    mStatusBarPaint.setColor(mStatusBarColor);
    mNavigationBarPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
    mNavigationBarPaint.setColor(mNavigationBarColor);

    setWillNotDraw(false);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        if (ViewCompat.getFitsSystemWindows(this)) {
            // Now set the sys ui flags to enable us to lay out in the window insets
            setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
        }
    }
}

From source file:com.cssn.samplesdk.MainActivity.java

/**
 *
 *///from   w  w  w .j a  va  2s.  c  o  m
@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    if (Util.LOG_ENABLED) {
        Utils.appendLog(TAG, "protected void onCreate(Bundle savedInstanceState)");
    }

    // load the model
    if (savedInstanceState == null) {
        if (Util.LOG_ENABLED) {
            Utils.appendLog(TAG, "if (savedInstanceState == null)");
        }
        mainActivityModel = new MainActivityModel();
    } else {
        if (Util.LOG_ENABLED) {
            Utils.appendLog(TAG, "if (savedInstanceState != null)");
        }
        mainActivityModel = DataContext.getInstance().getMainActivityModel();
        // if coming from background and kill the app, restart the model
        if (mainActivityModel == null) {
            mainActivityModel = new MainActivityModel();
        }
    }
    DataContext.getInstance().setContext(getApplicationContext());

    String licenseKey = DataContext.getInstance().getLicenseKey();

    // load the controller instance
    acuantAndroidMobileSdkControllerInstance = AcuantAndroidMobileSDKController.getInstance(this, licenseKey);
    if (!Util.isTablet(this)) {
        acuantAndroidMobileSdkControllerInstance
                .setPdf417BarcodeImageDrawable(getResources().getDrawable(R.drawable.barcode));
    }

    acuantAndroidMobileSdkControllerInstance.setWebServiceListener(this);
    acuantAndroidMobileSdkControllerInstance.setCloudUrl("cssnwebservices.com");
    acuantAndroidMobileSdkControllerInstance.setWatermarkText("Powered By Acuant", 0, 0, 30, 0);
    DisplayMetrics metrics = this.getResources().getDisplayMetrics();

    DisplayMetrics displaymetrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
    int height = displaymetrics.heightPixels;
    int width = displaymetrics.widthPixels;
    int minLength = (int) (Math.min(width, height) * 0.9);
    int maxLength = (int) (minLength * 1.5);
    int left = minLength / 2 - 50;
    int top = maxLength / 2 - 100;
    Paint textPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
    Typeface currentTypeFace = textPaint.getTypeface();
    Typeface bold = Typeface.create(currentTypeFace, Typeface.BOLD);
    textPaint.setColor(Color.WHITE);
    textPaint.setTextSize(50);
    textPaint.setTextAlign(Paint.Align.LEFT);
    textPaint.setTypeface(bold);
    Paint.FontMetrics metric = textPaint.getFontMetrics();
    acuantAndroidMobileSdkControllerInstance.setInstructionText("Blink Slowly", left, top, textPaint);
    //acuantAndroidMobileSdkControllerInstance.setShowActionBar(false);
    //acuantAndroidMobileSdkControllerInstance.setShowStatusBar(false);
    acuantAndroidMobileSdkControllerInstance.setFlashlight(false);
    //acuantAndroidMobileSdkControllerInstance.setFlashlight(0,0,50,0);
    //acuantAndroidMobileSdkControllerInstance.setFlashlightImageDrawable(getResources().getDrawable(R.drawable.lighton), getResources().getDrawable(R.drawable.lightoff));
    //acuantAndroidMobileSdkControllerInstance.setShowInitialMessage(true);
    //acuantAndroidMobileSdkControllerInstance.setCropBarcode(true);
    //acuantAndroidMobileSdkControllerInstance.setPdf417BarcodeDialogWaitingBarcode("AcuantAndroidMobileSampleSDK","ALIGN AND TAP", 10, "Try Again", "Yes");
    acuantAndroidMobileSdkControllerInstance.setCanShowBracketsOnTablet(true);
    // load several member variables
    setContentView(R.layout.activity_main);

    layoutCards = (LinearLayout) findViewById(R.id.cardImagesLayout);
    layoutBackImage = (RelativeLayout) findViewById(R.id.relativeLayoutBackImage);
    layoutFrontImage = (RelativeLayout) findViewById(R.id.relativeLayoutFrontImage);

    frontImageView = (ImageView) findViewById(R.id.frontImageView);
    backImageView = (ImageView) findViewById(R.id.backImageView);

    editTextLicense = (EditText) findViewById(R.id.editTextLicenceKey);
    editTextLicense.setText(DataContext.getInstance().getLicenseKey());

    txtTapToCaptureFront = (TextView) findViewById(R.id.txtTapToCaptureFront);
    txtTapToCaptureBack = (TextView) findViewById(R.id.txtTapToCaptureBack);

    activateLicenseButton = (Button) findViewById(R.id.activateLicenseButton);

    processCardButton = (Button) findViewById(R.id.processCardButton);
    processCardButton.setVisibility(View.INVISIBLE);

    editTextLicense.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            validateLicenseKey(editTextLicense.getText().toString());
            DataContext.getInstance().setLicenseKey(editTextLicense.getText().toString());
            return true;
        }
    });

    // it is necessary to use a post UI call, because of the previous set text on 'editTextLicense'
    new Handler().post(new Runnable() {
        @Override
        public void run() {
            editTextLicense.addTextChangedListener(new TextWatcher() {
                public void afterTextChanged(Editable s) {
                    mainActivityModel.setState(State.NO_VALIDATED);
                    updateActivateLicenseButtonFromModel();
                }

                public void beforeTextChanged(CharSequence s, int start, int count, int after) {

                }

                public void onTextChanged(CharSequence s, int start, int before, int count) {

                }
            });
        }
    });

    editTextLicense.setOnFocusChangeListener(new OnFocusChangeListener() {
        public void onFocusChange(View v, boolean hasFocus) {
            if (!hasFocus) {
                hideVirtualKeyboard();
            }
        }
    });

    // update the UI from the model
    updateUI();
    acuantAndroidMobileSdkControllerInstance.setCardCroppingListener(this);
    acuantAndroidMobileSdkControllerInstance.setAcuantErrorListener(this);
    if (Utils.LOG_ENABLED) {
        Utils.appendLog(TAG, "getScreenOrientation()=" + Util.getScreenOrientation(this));
    }
}