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

android Bit地图用法总结

2012-08-21 
android Bitmap用法总结Bitmap用法总结1、Drawable → Bitmap?2、从资源中获取Bitmap?6、将图片按自己的要求缩

android Bitmap用法总结

Bitmap用法总结
1、Drawable → Bitmap

?
2、从资源中获取Bitmap

?
6、将图片按自己的要求缩放

public static Bitmap createReflectionImageWithOrigin(Bitmap bitmap){final int reflectionGap = 4;int width = bitmap.getWidth();int height = bitmap.getHeight();Matrix matrix = new Matrix();matrix.preScale(1, -1);Bitmap reflectionImage = Bitmap.createBitmap(bitmap,0, height/2, width, height/2, matrix, false);Bitmap bitmapWithReflection = Bitmap.createBitmap(width, (height + height/2),Config.ARGB_8888);Canvas canvas = new Canvas(bitmapWithReflection);canvas.drawBitmap(bitmap, 0, 0, null);Paint deafalutPaint = new Paint();Generated by Foxit PDF Creator ? Foxit Softwarehttp://www.foxitsoftware.com For evaluation only.canvas.drawRect(0, height,width,height + reflectionGap,deafalutPaint);canvas.drawBitmap(reflectionImage, 0, height + reflectionGap, null);Paint paint = new Paint();LinearGradient shader = new LinearGradient(0,bitmap.getHeight(), 0, bitmapWithReflection.getHeight()+ reflectionGap, 0x70ffffff, 0x00ffffff, TileMode.CLAMP);paint.setShader(shader);// Set the Transfer mode to be porter duff and destination inpaint.setXfermode(new PorterDuffXfermode(Mode.DST_IN));// Draw a rectangle using the paint with our linear gradientcanvas.drawRect(0, height, width, bitmapWithReflection.getHeight()+ reflectionGap, paint);return bitmapWithReflection;}}

?

From :?http://blog.csdn.net/zhou699/article/details/6439100

热点排行