算是一个比较实用的东西喽,直接上函数。。:)
1 public static Bitmap createReflectionImage(Bitmap bitmap) { 2 3 int width = bitmap.getWidth(); 4 int height = bitmap.getHeight(); 5 6 Matrix matrix = new Matrix(); 7 matrix.preScale(1, -1); 8 9 Bitmap reflectionImage = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, false); 10 Bitmap newBitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888); 11 12 Canvas canvas = new Canvas(newBitmap); 13 canvas.drawBitmap(reflectionImage, 0, 0, null); 14 15 Paint paint = new Paint(); 16 LinearGradient shader = new LinearGradient(0, 0, 0, height, 0xacffffff, 0x00ffffff, 17 TileMode.CLAMP); 18 paint.setShader(shader); 19 // Set the Transfer mode to be porter duff and destination in 20 paint.setXfermode(new PorterDuffXfermode(Mode.DST_IN)); 21 // Draw a rectangle using the paint with our linear gradient 22 canvas.drawRect(0, 0, width, height, paint); 23 24 return newBitmap; 25 }
(整一篇先充充数,嘿嘿。)
浙公网安备 33010602011771号