List of usage examples for android.graphics BlurMaskFilter BlurMaskFilter
public BlurMaskFilter(float radius, Blur style)
From source file:Main.java
public static Bitmap setShadow(Bitmap bitmap, int radius) { BlurMaskFilter blurFilter = new BlurMaskFilter(radius, BlurMaskFilter.Blur.OUTER); Paint shadowPaint = new Paint(); shadowPaint.setAlpha(50);/*from ww w .j a v a2s . c om*/ shadowPaint.setColor(0xff424242); shadowPaint.setMaskFilter(blurFilter); int[] offsetXY = new int[2]; Bitmap shadowBitmap = bitmap.extractAlpha(shadowPaint, offsetXY); Bitmap shadowImage32 = shadowBitmap.copy(Bitmap.Config.ARGB_8888, true); Canvas c = new Canvas(shadowImage32); c.drawBitmap(bitmap, -offsetXY[0], -offsetXY[1], null); return shadowImage32; }
From source file:com.example.android.apis.graphics.FingerPaint.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bitmap loadedBitmap = loadBitmap();/* w ww . j a va 2s .c o m*/ myView = new MyView(this, loadedBitmap); setContentView(myView); mPaint = new Paint(); mPaint.setAntiAlias(true); mPaint.setDither(true); mPaint.setColor(0xFFFF0000); mPaint.setStyle(Paint.Style.STROKE); mPaint.setStrokeJoin(Paint.Join.ROUND); mPaint.setStrokeCap(Paint.Cap.ROUND); mPaint.setStrokeWidth(12); mEmboss = new EmbossMaskFilter(new float[] { 1, 1, 1 }, 0.4f, 6, 3.5f); mBlur = new BlurMaskFilter(8, BlurMaskFilter.Blur.NORMAL); setTitle(R.string.paint_text); }
From source file:com.androidmapsextensions.DefaultClusterOptionsProvider.java
private Paint createCirclePaint(Resources resources) { Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); blurRadius = resources.getDimension(R.dimen.ame_default_cluster_circle_blur_radius); if (blurRadius > 0.0f) { BlurMaskFilter maskFilter = new BlurMaskFilter(blurRadius, BlurMaskFilter.Blur.SOLID); paint.setMaskFilter(maskFilter); }/* www . ja va 2s . c o m*/ return paint; }
From source file:jp.envision.android.cloudfingerpaint.CloudFingerPaint.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); myView = new MyView(this); setContentView(myView);//from ww w. ja v a 2s . c om mPaint = new Paint(); mPaint.setAntiAlias(true); mPaint.setDither(true); //mPaint.setColor(0xFFFF0000); mPaint.setColor(0xFF000000); mPaint.setStyle(Paint.Style.STROKE); mPaint.setStrokeJoin(Paint.Join.ROUND); mPaint.setStrokeCap(Paint.Cap.ROUND); mPaint.setStrokeWidth(5); mEmboss = new EmbossMaskFilter(new float[] { 1, 1, 1 }, 0.4f, 6, 3.5f); mBlur = new BlurMaskFilter(8, BlurMaskFilter.Blur.NORMAL); alertDialogBuilder = new AlertDialog.Builder(this); }
From source file:com.graphics.FingerPaint.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // ///////////// aChatApp = (MyaChatApplication) getApplication(); xmppManager = aChatApp.getXmppManager(); connection = xmppManager.returnConnection(); secondUser = getIntent().getExtras().getString("username").toString(); Log.d(TAG, "got user is:" + secondUser); // start listening to new msg mPaint = new Paint(); mPaint.setAntiAlias(true);/*from ww w .j a va2 s. c o m*/ mPaint.setDither(true); mPaint.setColor(0xFFFF0000); mPaint.setStyle(Paint.Style.STROKE); mPaint.setStrokeJoin(Paint.Join.ROUND); mPaint.setStrokeCap(Paint.Cap.ROUND); mPaint.setStrokeWidth(12); mEmboss = new EmbossMaskFilter(new float[] { 1, 1, 1 }, 0.4f, 6, 3.5f); mBlur = new BlurMaskFilter(8, BlurMaskFilter.Blur.NORMAL); // setContentView(new MyView(this)); myView = new MyView(this); // final MyView myView = new MyView(this); // myView.fingerPaintMsgListener(); setContentView(myView); // startListenter(); localCoArray = new LocalCoArray(mPaint.getColor()); // ////////////////// }
From source file:jp.co.recruit_lifestyle.android.widget.ColoringLoadingView.java
private void initPaint() { mCharacterPaint = new Paint(); mCharacterPaint.setColor(Color.BLACK); mCharacterPaint.setStyle(Paint.Style.STROKE); mCharacterPaint.setStrokeWidth(20);/*from w w w. j ava2 s .c o m*/ mCharacterPaint.setStrokeCap(Paint.Cap.ROUND); mCharacterPaint.setPathEffect(new CornerPathEffect(10)); mCharacterPaint.setAntiAlias(true); mLoadingPaint = new Paint(); mLoadingPaint.setColor(Color.BLACK); mLoadingPaint.setStrokeWidth(10); mLoadingPaint.setStyle(Paint.Style.STROKE); mLoadingPaint.setStrokeCap(Paint.Cap.ROUND); mLoadingPaint.setPathEffect(new CornerPathEffect(10)); mLoadingPaint.setAntiAlias(true); mPencilPaint = new Paint(); mPencilPaint.setStyle(Paint.Style.FILL); mPencilPaint.setColor(Color.BLACK); mPencilPaint.setAntiAlias(true); mColoringPaint = new Paint(); mColoringPaint.setStyle(Paint.Style.STROKE); mColoringPaint.setStrokeWidth(30); mColoringPaint.setStrokeCap(Paint.Cap.ROUND); mColoringPaint.setAntiAlias(true); mColoringPaint.setColor(0xffF8C92C); mBackgroundPaint = new Paint(); mBackgroundPaint.setStyle(Paint.Style.FILL); mBackgroundPaint.setAntiAlias(true); mBackgroundPaint.setColor(Color.WHITE); mShadowPaint = new Paint(); mShadowPaint.setStyle(Paint.Style.FILL); mShadowPaint.setColor(0x70000000); mShadowPaint.setMaskFilter(new BlurMaskFilter(16, BlurMaskFilter.Blur.NORMAL)); }
From source file:com.hctrom.romcontrol.licenseadapter.LicenseDialogoAlerta.java
public void applyBlurMaskFilter(TextView tv, BlurMaskFilter.Blur style) { /*//from w w w . jav a2 s . c o m MaskFilter Known Direct Subclasses BlurMaskFilter, EmbossMaskFilter MaskFilter is the base class for object that perform transformations on an alpha-channel mask before drawing it. A subclass of MaskFilter may be installed into a Paint. Blur and emboss are implemented as subclasses of MaskFilter. */ /* BlurMaskFilter This takes a mask, and blurs its edge by the specified radius. Whether or or not to include the original mask, and whether the blur goes outside, inside, or straddles, the original mask's border, is controlled by the Blur enum. */ /* public BlurMaskFilter (float radius, BlurMaskFilter.Blur style) Create a blur maskfilter. Parameters radius : The radius to extend the blur from the original mask. Must be > 0. style : The Blur to use Returns The new blur maskfilter */ /* BlurMaskFilter.Blur INNER : Blur inside the border, draw nothing outside. NORMAL : Blur inside and outside the original border. OUTER : Draw nothing inside the border, blur outside. SOLID : Draw solid inside the border, blur outside. */ /* public float getTextSize () Returns the size (in pixels) of the default text size in this TextView. */ // Define the blur effect radius float radius = tv.getTextSize() / 10; // Initialize a new BlurMaskFilter instance BlurMaskFilter filter = new BlurMaskFilter(radius, style); /* public void setLayerType (int layerType, Paint paint) Specifies the type of layer backing this view. The layer can be LAYER_TYPE_NONE, LAYER_TYPE_SOFTWARE or LAYER_TYPE_HARDWARE. A layer is associated with an optional Paint instance that controls how the layer is composed on screen. Parameters layerType : The type of layer to use with this view, must be one of LAYER_TYPE_NONE, LAYER_TYPE_SOFTWARE or LAYER_TYPE_HARDWARE paint : The paint used to compose the layer. This argument is optional and can be null. It is ignored when the layer type is LAYER_TYPE_NONE */ /* public static final int LAYER_TYPE_SOFTWARE Indicates that the view has a software layer. A software layer is backed by a bitmap and causes the view to be rendered using Android's software rendering pipeline, even if hardware acceleration is enabled. */ // Set the TextView layer type tv.setLayerType(View.LAYER_TYPE_SOFTWARE, null); /* public MaskFilter setMaskFilter (MaskFilter maskfilter) Set or clear the maskfilter object. Pass null to clear any previous maskfilter. As a convenience, the parameter passed is also returned. Parameters maskfilter : May be null. The maskfilter to be installed in the paint Returns maskfilter */ // Finally, apply the blur effect on TextView text tv.getPaint().setMaskFilter(filter); }
From source file:net.evendanan.android.hagarfingerpainting.HagarFingerpaintingActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); setContentView(R.layout.main);/* w w w .j av a2 s . c o m*/ mWhiteboard = (Whiteboard) findViewById(R.id.whiteboard); mPainterName = (TextView) findViewById(R.id.painter_name_text); mAdView = (AdView) findViewById(R.id.adView); mBackground = (ImageView) findViewById(R.id.background_image); mSettingsIcons = (SettingsIconsView) findViewById(R.id.settings_icons); mSettingsIcons.setOnSettingsIconsTouchedListener(this); mToolbox = (ViewGroup) findViewById(R.id.toolbox); for (View innerView : mToolbox.getTouchables()) { if (innerView instanceof ImageView) { if (innerView.getId() == R.id.toolbox_eraser) { mEraserToolBoxIcon = (ImageView) innerView; } innerView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { onToolboxClicked(v.getId()); } }); } } mInAnimation = AnimationUtils.loadAnimation(getApplicationContext(), android.R.anim.fade_in); mOutAnimation = AnimationUtils.loadAnimation(getApplicationContext(), android.R.anim.slide_out_right); mOutAnimation.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { mToolbox.setVisibility(View.GONE); mSettingsIcons.setVisibility(View.VISIBLE); } }); SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); sp.registerOnSharedPreferenceChangeListener(this); mBackgroundPaper = savedInstanceState == null ? null : (IntentDrivenPaperBackground) savedInstanceState.getSerializable(PAPER_INTENT_OBJECT_KEY); mPaperCreated = false; Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/schoolbell.ttf"); mPainterName.setTypeface(tf); mBlur = new BlurMaskFilter(2, BlurMaskFilter.Blur.NORMAL); readyPaperTools(); }
From source file:edu.mum.ml.group7.guessasketch.android.EasyPaint.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // it removes the title from the actionbar(more space for icons?) // this.getActionBar().setDisplayShowTitleEnabled(false); pixels5 = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 5, getResources().getDisplayMetrics()); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); LinearLayout parent = new LinearLayout(this); parent.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); parent.setOrientation(LinearLayout.VERTICAL); LinearLayout scrollViewParent = new LinearLayout(this); scrollViewParent.setLayoutParams(//from w w w . jav a2 s. c o m new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); scrollViewParent.setOrientation(LinearLayout.HORIZONTAL); HorizontalScrollView predictionsHorizontalScrollView = new HorizontalScrollView(this); //predictionsHorizontalScrollView.setLayoutParams(new ViewGroup.LayoutParams()); predictions = new LinearLayout(this); LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); params.gravity = Gravity.CENTER_VERTICAL; predictions.setLayoutParams(params); predictions.setOrientation(LinearLayout.HORIZONTAL); resetPredictionsView(predictions, true); predictionsHorizontalScrollView.addView(predictions); saveButton = new Button(this); saveButton.setText("Send Feedback"); predictionsHorizontalScrollView.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 10.0f)); saveButton.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT, 1.0f)); saveButton.setVisibility(View.INVISIBLE); FrameLayout frameLayout = new FrameLayout(this); frameLayout .setLayoutParams(new ViewGroup.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT)); frameLayout.addView(saveButton); loader = new ProgressBar(this); loader.setLayoutParams(new ViewGroup.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); loader.setIndeterminate(true); loader.setVisibility(ProgressBar.INVISIBLE); frameLayout.addView(loader); scrollViewParent.addView(predictionsHorizontalScrollView); scrollViewParent.addView(frameLayout); contentView = new MyView(this); parent.addView(scrollViewParent); parent.addView(contentView); setContentView(parent); otherLabelOnClickListener = new View.OnClickListener() { @Override public void onClick(View view) { Log.e("Clicked", "Other Label label '" + (String) view.getTag() + "'"); sendScreenshot(false, feedbackType, (String) view.getTag()); } }; mPaint = new Paint(); mPaint.setAntiAlias(true); mPaint.setDither(true); mPaint.setColor(Color.BLACK); mPaint.setStyle(Paint.Style.STROKE); mPaint.setStrokeJoin(Paint.Join.ROUND); mPaint.setStrokeCap(Paint.Cap.ROUND); mPaint.setStrokeWidth(DEFAULT_BRUSH_SIZE); // Where did these magic numbers come from? What do they mean? Can I change them? ~TheOpenSourceNinja // Absolutely random numbers in order to see the emboss. asd! ~Valerio mEmboss = new EmbossMaskFilter(new float[] { 1, 1, 1 }, 0.4f, 6, 3.5f); mBlur = new BlurMaskFilter(5, BlurMaskFilter.Blur.NORMAL); if (isFirstTime()) { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle(R.string.app_name); alert.setMessage(R.string.app_description); alert.setNegativeButton(R.string.continue_button, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { Toast.makeText(getApplicationContext(), R.string.here_is_your_canvas, Toast.LENGTH_SHORT) .show(); } }); alert.show(); } else { Toast.makeText(getApplicationContext(), R.string.here_is_your_canvas, Toast.LENGTH_SHORT).show(); } loadFromIntents(); }
From source file:com.tafayor.selfcamerashot.taflib.helpers.GraphicsHelper.java
public static Bitmap addGlow(Bitmap src, int glowColor, float radius) { float DEFAULT_GLOW_RADIUS_FACTOR = 0.1f; // An added margin to the initial image int margin;// w ww . j av a2 s. c om int glowRadius; int midSize = (src.getWidth() + src.getHeight()) / 2; if (radius > 0 && radius < 1) glowRadius = (int) (midSize * radius); else if (radius >= 1) glowRadius = (int) radius; else glowRadius = (int) (midSize * DEFAULT_GLOW_RADIUS_FACTOR); margin = (int) (glowRadius); Bitmap alpha = src.extractAlpha(); // The output bitmap (with the icon + glow) Bitmap bmp = Bitmap.createBitmap(src.getWidth() + margin * 2, src.getHeight() + margin * 2, Bitmap.Config.ARGB_8888); //LogHelper.log("glow new size : " + (src.getWidth() + margin*2)); // The canvas to paint on the image Canvas canvas = new Canvas(bmp); Paint paint = new Paint(); paint.setColor(glowColor); // outer glow paint.setMaskFilter(new BlurMaskFilter(glowRadius, BlurMaskFilter.Blur.OUTER)); canvas.drawBitmap(alpha, margin, margin, paint); // original icon canvas.drawBitmap(src, margin, margin, null); return bmp; }