
안녕하세요. Imageview에 BlendMode.Screen 설정 관련하여 문의 드립니다.
위의 원본 이미지 처럼 BlendMode.Screen설정이 되어있는 이미지를 ImageView에 불러오고
필터효과를 주어 완료 이미지 처럼 보여주려고 합니다.
3개의 방법으로 적용해 보았고 소스는 아래와 같습니다.
1. android.graphics.BlendMode (https://developer.android.com/reference/android/graphics/BlendMode)
xml 방법으로도 해보았습니다.
ColorStateList csl = AppCompatResources.getColorStateList(context, R.color.color_transparent); // #00000000
instances.stickerImageView.setImageTintList(csl);
instances.stickerImageView.setImageTintBlendMode(BlendMode.SCREEN);
2. ColorFilter 적용
BitmapDrawable drawable = (BitmapDrawable) imageView.getDrawable();
drawable.setColorFilter(Color.parseColor("#00000000"), PorterDuff.Mode.SCREEN);
3. android.graphics.PorterDuff (https://developer.android.com/reference/android/graphics/PorterDuff.Mode)
Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.filter_7);
Bitmap output = Bitmap.createBitmap(
bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(output);
Paint paint = new Paint();
Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
PorterDuff.Mode mode = PorterDuff.Mode.SCREEN;
paint.setXfermode(new PorterDuffXfermode(mode));
canvas.drawBitmap(bitmap, rect, rect, paint);
특이한점은 1, 2번 방법은 색상을 지정 (빨간색)하면 필터효과가 적용됩니다. 위의 빨간 이미지 처럼요.
하지만 저는 색상지정을 하지 않고 처리가 되어야 합니다. 투명값 (#00000000)을 지정한 이유도 이러한 이유 입니다.
3번 방법은 아무런 효과가 적용되지 않았습니다.
어떤점이 잘못된 것일까요...몇일째 시도중이만 해결을 못하고 있습니다.
작은 조언이라도 좋으니 아시는 부분이 있으면 조언 부탁 드립니다.
감사합니다.