首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Android >

Android Bit地图 改变大小

2012-08-22 
AndroidBitmap 改变大小/** * Returns a Bitmap representing the thumbnail of the specified Bitmap. *

Android Bitmap 改变大小

/** * Returns a Bitmap representing the thumbnail of the specified Bitmap. * The size of the thumbnail is defined by the dimension * android.R.dimen.launcher_application_icon_size. * * This method is not thread-safe and should be invoked on the UI thread only. * * @param bitmap The bitmap to get a thumbnail of. * @param context The application's context. * * @return A thumbnail for the specified bitmap or the bitmap itself if the *         thumbnail could not be created. */public static Bitmap createBitmapThumbnail(Bitmap bitmap, Context context){ if(FusionField.iconWidth == -1&&(FusionField.screenWidth == 800 && FusionField.screenHeight == 480)){FusionField.iconWidth = 80;FusionField.iconHeight = 98;}else if (FusionField.iconWidth == -1){FusionField.iconWidth = 60;FusionField.iconHeight = 82;}final int bitmapWidth = bitmap.getWidth();final int bitmapHeight = bitmap.getHeight();Log.e("dean xiang", "" + bitmapWidth + ":" + bitmapHeight);if (FusionField.iconWidth > 0 && FusionField.iconHeight > 0){final Bitmap.Config c = Bitmap.Config.ARGB_8888;final Bitmap thumb = Bitmap.createBitmap(FusionField.iconWidth, FusionField.iconHeight, c);final Canvas canvas = sCanvas;final Paint paint = sPaint;canvas.setBitmap(thumb);paint.setDither(false);paint.setFilterBitmap(true);//int offsetX = Math.abs(sIconWidth - bitmapWidth) / 2;//int offsetY = Math.abs(sIconHeight - bitmapHeight) / 2;////sBounds.set(offsetX, offsetY, bitmapWidth + offsetX,//bitmapHeight + offsetY);//sOldBounds.set(0, 0, bitmapWidth, bitmapHeight);//canvas.drawBitmap(bitmap, sOldBounds, sBounds, paint);sBounds.set(0, 0, FusionField.iconWidth, FusionField.iconHeight);sOldBounds.set(0, 0, bitmapWidth, bitmapHeight);canvas.drawBitmap(bitmap, sOldBounds, sBounds, paint);return thumb;}return bitmap;}

热点排行