预览加载中,请您耐心等待几秒...
1/7
2/7
3/7
4/7
5/7
6/7
7/7

在线预览结束,喜欢就下载吧,查找使用更方便

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

packagecom.xikang.android.slimcoach.utils; importjava.io.ByteArrayOutputStream; importjava.io.File; importjava.io.FileNotFoundException; importjava.io.FileOutputStream; importjava.io.IOException; importcom.xikang.android.slimcoach.Conf; importandroid.app.Activity; importandroid.content.ContentResolver; importandroid.database.Cursor; importandroid.graphics.Bitmap; importandroid.graphics.BitmapFactory; importandroid.graphics.BitmapFactory.Options; importandroid.graphics.Matrix; importandroid.net.Uri; importandroid.provider.MediaStore; importandroid.util.FloatMath; importandroid.util.Log; importandroid.widget.ImageView; importandroid.widget.Toast; publicclassImageUtils{ privatestaticfinalStringTAG="ImageUtils"; publicstaticvoidloadImage(Activityactivity,ImageViewimageView,Uriuri){ if(Conf.INFO) Log.i(TAG,"loadImage:localuri="+uri); if(uri!=null&&!uri.toString().startsWith("content://")){ return; } try{ //MediaStore String[]pojo={MediaStore.Images.Media.DATA}; Cursorcursor=activity.managedQuery(uri,pojo,null,null,null); if(cursor!=null&&cursor.moveToFirst()){ ContentResolvercr=activity.getContentResolver(); intcolunm_index=cursor .getColumnIndexOrThrow(MediaStore.Images.Media.DATA); Stringpath=cursor.getString(colunm_index); if(Conf.INFO) Log.i(TAG,"loadImage:path="+path); if(path.endsWith(".jpg")||path.endsWith(".png")){ Bitmapbitmap=BitmapFactory.decodeStream(cr .openInputStream(uri)); //imageView.setImageBitmap(getBitmap(path,100,200)); imageView.setImageBitmap(getCompredBitmap(path)); }else{ Toast.makeText(activity,"Pleaseselectimage...", Toast.LENGTH_SHORT).show(); } } }catch(Exceptione){ e.printStackTrace(); } } publicstaticBitmapgetCompredBitmap(StringsrcPath){ returncompressDef(getResizeBitmap(srcPath)); } /** *getbitmapcompressedto100kb *@parambitmap *@return */ publicstaticBitmapgetCompredDefBitmap(Bitmapbitmap){ returngetCompred