public static Bitmap createScaledBitmap(Bitmap unscaledBitmap, int dstWidth, int dstHeight,
2012-09-07 11:27
746 查看
public static Bitmap createScaledBitmap(Bitmap unscaledBitmap, int dstWidth, int dstHeight,
ScalingLogic scalingLogic) {
if(unscaledBitmap ==null)
return null;
Rect srcRect = calculateSrcRect(unscaledBitmap.getWidth(), unscaledBitmap.getHeight(),
dstWidth, dstHeight, scalingLogic);
Rect dstRect = calculateDstRect(unscaledBitmap.getWidth(), unscaledBitmap.getHeight(),
dstWidth, dstHeight, scalingLogic);
Bitmap scaledBitmap = Bitmap.createBitmap(dstRect.width(), dstRect.height(),
Config.ARGB_8888);
Canvas canvas = new Canvas(scaledBitmap);
canvas.drawBitmap(unscaledBitmap, srcRect, dstRect, new Paint(Paint.FILTER_BITMAP_FLAG|Paint.ANTI_ALIAS_FLAG));
return scaledBitmap;
}
ScalingLogic scalingLogic) {
if(unscaledBitmap ==null)
return null;
Rect srcRect = calculateSrcRect(unscaledBitmap.getWidth(), unscaledBitmap.getHeight(),
dstWidth, dstHeight, scalingLogic);
Rect dstRect = calculateDstRect(unscaledBitmap.getWidth(), unscaledBitmap.getHeight(),
dstWidth, dstHeight, scalingLogic);
Bitmap scaledBitmap = Bitmap.createBitmap(dstRect.width(), dstRect.height(),
Config.ARGB_8888);
Canvas canvas = new Canvas(scaledBitmap);
canvas.drawBitmap(unscaledBitmap, srcRect, dstRect, new Paint(Paint.FILTER_BITMAP_FLAG|Paint.ANTI_ALIAS_FLAG));
return scaledBitmap;
}
相关文章推荐
- public static Bitmap createScaledBitmap(
- Bitmap.createBitmap java.lang.IllegalArgumentException: width and height must be > 0 问题解决
- Bitmap.createBitmap java.lang.IllegalArgumentException: width and height must be > 0 问题解决
- Bitmap android.graphics.Bitmap.createBitmap(int width, int height, Config config) Config参数的说明
- [转载内容]动态创建菜单,menustrip,根据权限显示菜单,控制菜单可用,反射,给窗体传值,反射对象传值,public static Object CreateInstance ( Type type, params Object[] args )
- public static Bitmap zoomIn(Bitmap bitmap, int maxW, int maxH)
- unresolved external symbol "public: static int CIDcardRecogizeDlg::h" (?h@CIDcardReco
- 'int android.graphics.Bitmap.getWidth()' on a null object reference
- bitmap 缩放 java.lang.IllegalArgumentException: width and height must be > 0
- Bitmap通过getWidth和getHeight获取尺寸不符
- 已知一个一维数组:BYTE imageArray[width * height], 怎样在VC++2008的MFC中,用GDI+,创建一个Bitmap对象,与该数组建立关联?
- android 控件中layout_width,layout_height与onMeasure(int widthMeasureSpec, int heightMeasureSpec)
- public static void fill(Object[] a, int fromIndex, int toIndex, Object val)
- Bitmap android.graphics.Bitmap.createBitmap(int width, int height, Config config) Config参数的说明
- 有一个一维整型数组int[]data保存的是一张宽为width,高为height的图片像素值信息。请写一个算法,将该图片所有的白色不透明(0xffffffff)像素点的透明度调整为50%。
- public static final int REMIN_REQUEST_CODE = 0x911 自己的大致理解
- View onMeasure(int widthMeasureSpec, int heightMeasureSpec)
- 7、利用泛型和反射,让public static <T> T findById(Class<T> clazz, int id)方法,更具一般性
- Bitmap.createScaledBitmap的陷阱
- 解决滑动冲突和自定义控件中对onMeasure(int widthMeasureSpec, int heightMeasureSpec)方法的理解