List of usage examples for android.graphics Canvas ALL_SAVE_FLAG
int ALL_SAVE_FLAG
To view the source code for android.graphics Canvas ALL_SAVE_FLAG.
Click Source Link
From source file:com.google.android.apps.muzei.settings.ChooseSourceFragment.java
private Bitmap generateSourceImage(Drawable image) { Bitmap bitmap = Bitmap.createBitmap(mItemImageSize, mItemImageSize, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); mTempRectF.set(0, 0, mItemImageSize, mItemImageSize); canvas.drawOval(mTempRectF, mImageFillPaint); if (image != null) { canvas.saveLayer(0, 0, mItemImageSize, mItemImageSize, mAlphaPaint, Canvas.ALL_SAVE_FLAG); image.setBounds(0, 0, mItemImageSize, mItemImageSize); image.draw(canvas);/*from w ww . j av a2s . c om*/ canvas.restore(); } return bitmap; }
From source file:com.shouhuan.view.ResideLayout.java
@Override protected boolean drawChild(Canvas canvas, View child, long drawingTime) { final LayoutParams lp = (LayoutParams) child.getLayoutParams(); boolean result; final int save = canvas.save(Canvas.ALL_SAVE_FLAG); if (mCanSlide && !lp.slideable && mSlideableView != null) { // Clip against the slider; no sense drawing what will immediately // be covered. canvas.scale(1.2f - 0.2f * mSlideOffset, 1.2f - 0.2f * mSlideOffset, child.getRight(), getHeight() / 2); } else {//from w w w . jav a 2s .c om assert mSlideableView != null; canvas.scale(1 - mSlideOffset / 3, 1 - mSlideOffset / 3, mSlideableView.getLeft(), getHeight() / 2); // ViewCompat.setRotationY(child, -10 * mSlideOffset); } if (!lp.slideable && mSlideOffset == 0) { result = true; } else { if (Build.VERSION.SDK_INT >= 11) { // HC result = super.drawChild(canvas, child, drawingTime); } else { if (lp.dimWhenOffset && mSlideOffset > 0) { if (!child.isDrawingCacheEnabled()) { child.setDrawingCacheEnabled(true); } final Bitmap cache = child.getDrawingCache(); if (cache != null) { canvas.drawBitmap(cache, child.getLeft(), child.getTop(), lp.dimPaint); result = false; } else { Log.e(TAG, "drawChild: child view " + child + " returned null drawing cache"); result = super.drawChild(canvas, child, drawingTime); } } else { if (child.isDrawingCacheEnabled()) { child.setDrawingCacheEnabled(false); } result = super.drawChild(canvas, child, drawingTime); } } } canvas.restoreToCount(save); return result; }
From source file:com.bright.cloudutils.view.ResideLayout.java
@Override protected boolean drawChild(@NonNull Canvas canvas, @NonNull View child, long drawingTime) { final LayoutParams lp = (LayoutParams) child.getLayoutParams(); boolean result; final int save = canvas.save(Canvas.ALL_SAVE_FLAG); if (mCanSlide && !lp.slideable && mSlideableView != null) { // Clip against the slider; no sense drawing what will immediately // be covered. canvas.scale(1.2f - 0.2f * mSlideOffset, 1.2f - 0.2f * mSlideOffset, child.getRight(), getHeight() / 2); } else {/*from ww w . jav a2 s.c o m*/ assert mSlideableView != null; canvas.scale(1 - mSlideOffset / 3, 1 - mSlideOffset / 3, mSlideableView.getLeft(), getHeight() / 2); ViewCompat.setRotationY(child, -10 * mSlideOffset); } if (!lp.slideable && mSlideOffset == 0) { result = true; } else { if (Build.VERSION.SDK_INT >= 11) { // HC result = super.drawChild(canvas, child, drawingTime); } else { if (lp.dimWhenOffset && mSlideOffset > 0) { if (!child.isDrawingCacheEnabled()) { child.setDrawingCacheEnabled(true); } final Bitmap cache = child.getDrawingCache(); if (cache != null) { canvas.drawBitmap(cache, child.getLeft(), child.getTop(), lp.dimPaint); result = false; } else { Log.e(TAG, "drawChild: child view " + child + " returned null drawing cache"); result = super.drawChild(canvas, child, drawingTime); } } else { if (child.isDrawingCacheEnabled()) { child.setDrawingCacheEnabled(false); } result = super.drawChild(canvas, child, drawingTime); } } } canvas.restoreToCount(save); return result; }