/** * * [图片缩放]<BR> * [功能详细描述] * * @param bitmapOrg * @param dstw * @param dsth * @return */ public static Bitmap resizeImage(Bitmap bitmapOrg, int dstw, int dsth) { Bitmap resizedBitmap; int srcw = bitmapOrg.getWidth(); int srch = bitmapOrg.getHeight(); // 如果长宽小于生成的目标图片,直接返回图片 if (srcw <= dstw && srch <= dsth) { return bitmapOrg; } // else if (srcw > dstw && srch < dsth) // { // // resizedBitmap // // // } float scaleWidth = ((float) dstw) / srcw; float scaleHeight = ((float) dsth) / srch; // create a matrix for the manipulation Matrix matrix = new Matrix(); // resize the Bitmap matrix.postScale(scaleWidth, scaleHeight); // if you want to rotate the Bitmap // matrix.postRotate(45); // recreate the new Bitmap resizedBitmap = Bitmap.createBitmap(bitmapOrg, 0, 0, srcw, srch, matrix, true); bitmapOrg.recycle(); // make a Drawable from Bitmap to allow to set the Bitmap // to the ImageView, ImageButton or what ever return resizedBitmap; } /** * * [ 图像圆角处理]<BR> * [功能详细描述] * * @param bitmap * @param roundPX * @return */ public static Bitmap getRCB(Bitmap bitmap, float roundPX) //RCB means Rounded Corner Bitmap { Bitmap dstbmp = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888); Canvas canvas = new Canvas(dstbmp); final int color = 0xff424242; final Paint paint = new Paint(); final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()); final RectF rectF = new RectF(rect); paint.setAntiAlias(true); canvas.drawARGB(0, 0, 0, 0); paint.setColor(color); canvas.drawRoundRect(rectF, roundPX, roundPX, paint); paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN)); canvas.drawBitmap(bitmap, rect, rect, paint); return dstbmp; }

更多相关文章

  1. android GPS JAVA 获取GPS功能是否禁用
  2. android典型代码系列(六)------drawable图片转换为48dip的bitmap
  3. Android 双击返回键退出功能的实现
  4. android 异步下载图片
  5. Android 把Layout变成图片
  6. android之ListView和adapter配合显示图片和文字列表
  7. Android实现更换皮肤功能
  8. android 上传图片到服务器

随机推荐

  1. Android:安卓资源引用符号的含义
  2. Android(安卓)中启动自己另一个程序的act
  3. Android(安卓)xml资源文件中@、@android:
  4. [Google Android] Android(安卓)SDK Tool
  5. 【转】Android(安卓)ADB命令集
  6. Android(安卓)studio使用笔记。。。
  7. Android学习路线图
  8. android 各种小项目
  9. Android: Android图形基础
  10. Android(安卓)API中文文档AccessibilityS