In this blog implement the shadow effect on image.explain below
you have to create main.xml class and drop one ImageView show ....
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#1a496e"
tools:context=".Splase" >
<!-- you can drop ImageView Widgets -->
<ImageView
android:id="@+id/imageView1"
android:layout_width="300dip"
android:layout_height="300dip"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:padding="6dp"
/>
</RelativeLayout>
Create MainActivity.java inside src folder....
..............................................................................................................................................
package com.webnetware.slcm;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.BlurMaskFilter;
import android.graphics.BlurMaskFilter.Blur;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.os.Bundle;
import android.os.Handler;
import android.view.Window;
import android.widget.ImageView;
import android.graphics.PorterDuff;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splase);
ImageView im=(ImageView)findViewById(R.id.imageView1);
// set the Bitmap method in ImageView
im.setImageBitmap(highlightImage(BitmapFactory.decodeResource(getResources(), R.drawable.imge)));
}
public Bitmap highlightImage(Bitmap src) {
// create new bitmap, which will be painted
Bitmap imageView = Bitmap.createBitmap(src.getWidth(), src.getHeight(), Bitmap.Config.ARGB_8888);
// canvas for painting
Canvas canvas = new Canvas(imageView);
// default color
canvas.drawColor(0, PorterDuff.Mode.CLEAR);
// create a blur paint for capturing alpha
Paint imageViewglow = new Paint();
imageViewglow.setMaskFilter(new BlurMaskFilter(15, Blur.NORMAL));
int[] offsetXY = new int[2];
// capture alpha into a bitmap
Bitmap BitmapAlpha = src.extractAlpha(imageViewglow, offsetXY);
// create a color paint
Paint imageViewAlphaColor = new Paint();
imageViewAlphaColor.setColor(0xFFFFFFFF);
// paint color for captured alpha region (bitmap)
canvas.drawBitmap(BitmapAlpha, offsetXY[0], offsetXY[1], imageViewAlphaColor);
// free memory
BitmapAlpha.recycle();
// paint the image source
canvas.drawBitmap(src, 0, 0, null);
// return imageView out final image
return imageView;
}
}
you have to create main.xml class and drop one ImageView show ....
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#1a496e"
tools:context=".Splase" >
<!-- you can drop ImageView Widgets -->
<ImageView
android:id="@+id/imageView1"
android:layout_width="300dip"
android:layout_height="300dip"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:padding="6dp"
/>
</RelativeLayout>
Create MainActivity.java inside src folder....
..............................................................................................................................................
package com.webnetware.slcm;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.BlurMaskFilter;
import android.graphics.BlurMaskFilter.Blur;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.os.Bundle;
import android.os.Handler;
import android.view.Window;
import android.widget.ImageView;
import android.graphics.PorterDuff;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splase);
ImageView im=(ImageView)findViewById(R.id.imageView1);
// set the Bitmap method in ImageView
im.setImageBitmap(highlightImage(BitmapFactory.decodeResource(getResources(), R.drawable.imge)));
}
public Bitmap highlightImage(Bitmap src) {
// create new bitmap, which will be painted
Bitmap imageView = Bitmap.createBitmap(src.getWidth(), src.getHeight(), Bitmap.Config.ARGB_8888);
// canvas for painting
Canvas canvas = new Canvas(imageView);
// default color
canvas.drawColor(0, PorterDuff.Mode.CLEAR);
// create a blur paint for capturing alpha
Paint imageViewglow = new Paint();
imageViewglow.setMaskFilter(new BlurMaskFilter(15, Blur.NORMAL));
int[] offsetXY = new int[2];
// capture alpha into a bitmap
Bitmap BitmapAlpha = src.extractAlpha(imageViewglow, offsetXY);
// create a color paint
Paint imageViewAlphaColor = new Paint();
imageViewAlphaColor.setColor(0xFFFFFFFF);
// paint color for captured alpha region (bitmap)
canvas.drawBitmap(BitmapAlpha, offsetXY[0], offsetXY[1], imageViewAlphaColor);
// free memory
BitmapAlpha.recycle();
// paint the image source
canvas.drawBitmap(src, 0, 0, null);
// return imageView out final image
return imageView;
}
}
Image Background glow effect .....try this code.
http://androidbeginnerpoint.blogspot.in/2015/11/glow-effect-on-imageview-in-android.html
0 comments