Android Beginner 78th Day
16_cameraintent
Code Criminalintentpictureutils.java
Package com.bignerdranch.android.criminalintent;import android.app.Activity;import Android.graphics.Bitmap;import android.graphics.BitmapFactory;import Android.graphics.Point; Public classpictureutils { Public StaticBitmapGetscaledbitmap(String path, activity activity) {Point size =NewPoint (); Activity.Getwindowmanager().Getdefaultdisplay() .GetSize(size);return Getscaledbitmap(Path, size.x, size.y); } Public StaticBitmapGetscaledbitmap(String Path,intDestwidth,intDestheight) {//Read in the dimensions of the image on diskBitmapfactory.OptionsOptions =NewBitmapfactory.Options(); Options.Injustdecodebounds=true; Bitmapfactory.DecodeFile(Path, options);floatSrcwidth = options.Outwidth;floatSrcheight = options.Outheight;// figure out how much intInsamplesize =1;if(Srcheight > Destheight | | srcwidth > Destwidth) {floatHeightscale = Srcheight/destheight;floatWidthscale = Srcwidth/destwidth; Insamplesize = Math.round(Heightscale > Widthscale heightscale:widthscale); } options =NewBitmapfactory.Options(); Options.insamplesize= Insamplesize;//Read in and create final bitmap returnBitmapfactory.DecodeFile(Path, options); }}
Android Beginner 78th Day