Add water effect on bitmap android

試著忘記壹切 提交于 2019-12-12 16:53:44

问题


How can i add water waves in bitmap image? i have found water ripple effect on touch event here: https://github.com/esteewhy/whater but can not implement on my single bitmap. can anyone help in making water wave effect on my bitmap? or should i go for image processing? Thank you in advance. Here is my sample code in which i have to make water reflection effect:

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;
}

来源:https://stackoverflow.com/questions/19029393/add-water-effect-on-bitmap-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!