use of android.graphics.BlurMaskFilter in project Highlight by hongyangAndroid.
the class CircleLightShape method drawShape.
@Override
protected void drawShape(Bitmap bitmap, HighLight.ViewPosInfo viewPosInfo) {
Canvas canvas = new Canvas(bitmap);
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setDither(true);
paint.setAntiAlias(true);
paint.setMaskFilter(new BlurMaskFilter(15, BlurMaskFilter.Blur.SOLID));
RectF rectF = viewPosInfo.rectF;
canvas.drawCircle(rectF.left + (rectF.width() / 2), rectF.top + (rectF.height() / 2), Math.max(rectF.width(), rectF.height()) / 2, paint);
}
use of android.graphics.BlurMaskFilter in project Highlight by hongyangAndroid.
the class RectLightShape method drawShape.
@Override
protected void drawShape(Bitmap bitmap, HighLight.ViewPosInfo viewPosInfo) {
Canvas canvas = new Canvas(bitmap);
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setDither(true);
paint.setAntiAlias(true);
paint.setMaskFilter(new BlurMaskFilter(15, BlurMaskFilter.Blur.SOLID));
canvas.drawRoundRect(viewPosInfo.rectF, 6, 6, paint);
}
use of android.graphics.BlurMaskFilter in project Fairphone by Kwamecorp.
the class HolographicOutlineHelper method applyExpensiveOutlineWithBlur.
void applyExpensiveOutlineWithBlur(Bitmap srcDst, Canvas srcDstCanvas, int color, int outlineColor, boolean clipAlpha, int thickness) {
// other types of partial transparency when defining the shape of the object
if (clipAlpha) {
int[] srcBuffer = new int[srcDst.getWidth() * srcDst.getHeight()];
srcDst.getPixels(srcBuffer, 0, srcDst.getWidth(), 0, 0, srcDst.getWidth(), srcDst.getHeight());
for (int i = 0; i < srcBuffer.length; i++) {
final int alpha = srcBuffer[i] >>> 24;
if (alpha < 188) {
srcBuffer[i] = 0;
}
}
srcDst.setPixels(srcBuffer, 0, srcDst.getWidth(), 0, 0, srcDst.getWidth(), srcDst.getHeight());
}
Bitmap glowShape = srcDst.extractAlpha();
// calculate the outer blur first
BlurMaskFilter outerBlurMaskFilter;
switch(thickness) {
case EXTRA_THICK:
outerBlurMaskFilter = sExtraThickOuterBlurMaskFilter;
break;
case THICK:
outerBlurMaskFilter = sThickOuterBlurMaskFilter;
break;
case MEDIUM:
outerBlurMaskFilter = sMediumOuterBlurMaskFilter;
break;
default:
throw new RuntimeException("Invalid blur thickness");
}
mBlurPaint.setMaskFilter(outerBlurMaskFilter);
int[] outerBlurOffset = new int[2];
Bitmap thickOuterBlur = glowShape.extractAlpha(mBlurPaint, outerBlurOffset);
if (thickness == EXTRA_THICK) {
mBlurPaint.setMaskFilter(sMediumOuterBlurMaskFilter);
} else {
mBlurPaint.setMaskFilter(sThinOuterBlurMaskFilter);
}
int[] brightOutlineOffset = new int[2];
Bitmap brightOutline = glowShape.extractAlpha(mBlurPaint, brightOutlineOffset);
// calculate the inner blur
srcDstCanvas.setBitmap(glowShape);
srcDstCanvas.drawColor(0xFF000000, PorterDuff.Mode.SRC_OUT);
BlurMaskFilter innerBlurMaskFilter;
switch(thickness) {
case EXTRA_THICK:
innerBlurMaskFilter = sExtraThickInnerBlurMaskFilter;
break;
case THICK:
innerBlurMaskFilter = sThickInnerBlurMaskFilter;
break;
case MEDIUM:
innerBlurMaskFilter = sMediumInnerBlurMaskFilter;
break;
default:
throw new RuntimeException("Invalid blur thickness");
}
mBlurPaint.setMaskFilter(innerBlurMaskFilter);
int[] thickInnerBlurOffset = new int[2];
Bitmap thickInnerBlur = glowShape.extractAlpha(mBlurPaint, thickInnerBlurOffset);
// mask out the inner blur
srcDstCanvas.setBitmap(thickInnerBlur);
srcDstCanvas.drawBitmap(glowShape, -thickInnerBlurOffset[0], -thickInnerBlurOffset[1], mErasePaint);
srcDstCanvas.drawRect(0, 0, -thickInnerBlurOffset[0], thickInnerBlur.getHeight(), mErasePaint);
srcDstCanvas.drawRect(0, 0, thickInnerBlur.getWidth(), -thickInnerBlurOffset[1], mErasePaint);
// draw the inner and outer blur
srcDstCanvas.setBitmap(srcDst);
srcDstCanvas.drawColor(0, PorterDuff.Mode.CLEAR);
mHolographicPaint.setColor(color);
srcDstCanvas.drawBitmap(thickInnerBlur, thickInnerBlurOffset[0], thickInnerBlurOffset[1], mHolographicPaint);
srcDstCanvas.drawBitmap(thickOuterBlur, outerBlurOffset[0], outerBlurOffset[1], mHolographicPaint);
// draw the bright outline
mHolographicPaint.setColor(outlineColor);
srcDstCanvas.drawBitmap(brightOutline, brightOutlineOffset[0], brightOutlineOffset[1], mHolographicPaint);
// cleanup
srcDstCanvas.setBitmap(null);
brightOutline.recycle();
thickOuterBlur.recycle();
thickInnerBlur.recycle();
glowShape.recycle();
}
use of android.graphics.BlurMaskFilter in project mobile-android by photo.
the class ImageViewDrawableOverlay method onDragEnter.
@Override
public void onDragEnter(DragSource source, int x, int y, int xOffset, int yOffset, DragView dragView, Object dragInfo) {
mDropPaint = new Paint();
mDropPaint.setColor(0xff33b5e5);
mDropPaint.setStrokeWidth(2);
mDropPaint.setMaskFilter(new BlurMaskFilter(4.0f, Blur.NORMAL));
mDropPaint.setStyle(Paint.Style.STROKE);
invalidate();
}
use of android.graphics.BlurMaskFilter in project mobile-android by photo.
the class DrawingPanel method onActivate.
/*
* (non-Javadoc)
*
* @see com.aviary.android.feather.effects.AbstractEffectPanel#onActivate()
*/
@Override
public void onActivate() {
super.onActivate();
disableHapticIsNecessary(mGalleryColor, mGallerySize);
initToast();
mGallerySize.setOnItemsScrollListener(new OnItemsScrollListener() {
@Override
public void onScrollFinished(AdapterView<?> parent, View view, int position, long id) {
mSize = (Integer) mGallerySize.getAdapter().getItem(position);
final boolean soft = ((GallerySizeAdapter) mGallerySize.getAdapter()).getIsSoft(position);
if (soft)
mPaint.setMaskFilter(new BlurMaskFilter(mBlur, Blur.NORMAL));
else
mPaint.setMaskFilter(null);
updatePaint();
updateSelectedSize(view, position);
hideToastPreview();
}
@Override
public void onScrollStarted(AdapterView<?> parent, View view, int position, long id) {
showToastPreview();
if (getSelectedTool() == DrawinTool.Zoom) {
setSelectedTool(DrawinTool.Draw);
}
}
@Override
public void onScroll(AdapterView<?> parent, View view, int position, long id) {
GallerySizeAdapter adapter = (GallerySizeAdapter) parent.getAdapter();
int size = (Integer) adapter.getItem(position);
int blur = adapter.getIsSoft(position) ? mBlur : 0;
boolean is_eraser = mGalleryColor.getSelectedItemPosition() == 0 || mGalleryColor.getSelectedItemPosition() == mGalleryColor.getAdapter().getCount() - 1;
if (is_eraser) {
updateToastPreview(size, Color.WHITE, blur, true);
} else {
updateToastPreview(size, mColor, blur, false);
}
}
});
mGalleryColor.setOnItemsScrollListener(new OnItemsScrollListener() {
@Override
public void onScrollFinished(AdapterView<?> parent, View view, int position, long id) {
mColor = (Integer) parent.getAdapter().getItem(position);
final boolean is_eraser = position == 0 || (position == parent.getAdapter().getCount() - 1);
if (is_eraser) {
mColor = 0;
}
mPaint.setColor(mColor);
if (getSelectedTool() == DrawinTool.Zoom) {
if (is_eraser)
setSelectedTool(DrawinTool.Erase);
else
setSelectedTool(DrawinTool.Draw);
} else {
if (is_eraser && getSelectedTool() != DrawinTool.Erase)
setSelectedTool(DrawinTool.Erase);
else if (!is_eraser && getSelectedTool() != DrawinTool.Draw)
setSelectedTool(DrawinTool.Draw);
}
updatePaint();
updateSelectedColor(view, position);
hideToastPreview();
}
@Override
public void onScrollStarted(AdapterView<?> parent, View view, int position, long id) {
showToastPreview();
if (getSelectedTool() == DrawinTool.Zoom) {
setSelectedTool(DrawinTool.Draw);
}
}
@Override
public void onScroll(AdapterView<?> parent, View view, int position, long id) {
final boolean is_eraser = position == 0 || (position == parent.getAdapter().getCount() - 1);
if (is_eraser) {
updateToastPreview(mSize, Color.WHITE, mBlur, true);
} else {
updateToastPreview(mSize, mBrushColors[position], mBlur, false);
}
}
});
mLensButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
boolean selected = arg0.isSelected();
arg0.setSelected(!selected);
if (arg0.isSelected()) {
setSelectedTool(DrawinTool.Zoom);
} else {
if (mGalleryColor.getSelectedItemPosition() == 0) {
setSelectedTool(DrawinTool.Erase);
} else {
setSelectedTool(DrawinTool.Draw);
}
updatePaint();
}
}
});
setSelectedTool(DrawinTool.Draw);
updatePaint();
updateSelectedSize((View) mGallerySize.getSelectedView(), mGallerySize.getSelectedItemPosition());
updateSelectedColor((View) mGalleryColor.getSelectedView(), mGalleryColor.getSelectedItemPosition());
((ImageViewTouchAndDraw) mImageView).setOnDrawStartListener(this);
((ImageViewTouchAndDraw) mImageView).setOnDrawPathListener(this);
mLensButton.setVisibility(View.VISIBLE);
getContentView().setVisibility(View.VISIBLE);
contentReady();
}
Aggregations