在位图android上添加水效果

时间:2013-09-26 13:16:43

标签: android image-processing bitmap effect

如何在位图图像中添加水波? 我在触摸事件中发现了水波纹效应:https://github.com/esteewhy/whater但无法在我的单个位图上实现。 任何人都可以帮助我的位图制作水波效果? 或者我应该去图像处理? 先感谢您。 这是我的示例代码,其中我必须使水反射效果:

public static Bitmap reflection(Bitmap mainImage) {
       int width = mainImage.getWidth();
       int height = mainImage.getHeight();

       Matrix matrix = new Matrix();
       matrix.preScale(1, -1);

       reflectionImage = Bitmap.createBitmap(mainImage, 0,
               0, width, height , matrix, false);

        reflectedBitmap = Bitmap.createBitmap(width,
               (height + height), Config.ARGB_8888);

       Canvas canvas = new Canvas(reflectedBitmap);
       canvas.drawBitmap(mainImage, 0, 0, null);
       Paint defaultPaint = new Paint();
       canvas.drawRect(0, height, width, height, defaultPaint);

       canvas.drawBitmap(reflectionImage, 0, height-6 , null);
       Paint paint = new Paint();
       LinearGradient shader = new LinearGradient(0,
               mainImage.getHeight(), 0, reflectedBitmap.getHeight()
                       , 0x70ffffff, 0x00ffffff, TileMode.CLAMP);
       paint.setShader(shader);
       paint.setXfermode(new PorterDuffXfermode(Mode.DST_IN));
       canvas.drawRect(0, height, width, reflectedBitmap.getHeight()
                , paint);
           return reflectedBitmap;
}

0 个答案:

没有答案