@Override public RequestHandler.Result transform(RequestHandler.Result source) { Bitmap bitmap = source.getBitmap(); if (bitmap == null) { return source; } Bitmap result = createBitmap(bitmap.getWidth(), bitmap.getHeight(), bitmap.getConfig()); Bitmap noise; try { noise = picasso.load(R.drawable.noise).get(); } catch (IOException e) { throw new RuntimeException("Failed to apply transformation! Missing resource."); } BitmapShader shader = new BitmapShader(noise, REPEAT, REPEAT); ColorMatrix colorMatrix = new ColorMatrix(); colorMatrix.setSaturation(0); ColorMatrixColorFilter filter = new ColorMatrixColorFilter(colorMatrix); Paint paint = new Paint(ANTI_ALIAS_FLAG); paint.setColorFilter(filter); Canvas canvas = new Canvas(result); canvas.drawBitmap(bitmap, 0, 0, paint); paint.setColorFilter(null); paint.setShader(shader); paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.MULTIPLY)); canvas.drawRect(0, 0, canvas.getWidth(), canvas.getHeight(), paint); bitmap.recycle(); noise.recycle(); return new RequestHandler.Result(result, source.getLoadedFrom(), source.getExifRotation()); }
@NonNull @Override public RequestHandler.Result transform(@NonNull RequestHandler.Result source) { Bitmap bitmap = source.getBitmap(); if (bitmap == null) { return source; } bitmap = transformResult(data, bitmap, source.getExifRotation()); return new RequestHandler.Result(bitmap, source.getLoadedFrom(), source.getExifRotation()); }
if (data.needsMatrixTransform() || result.getExifRotation() != 0) { transformations.add(new MatrixTransformation(data));
@Override public RequestHandler.Result transform(RequestHandler.Result source) { Bitmap bitmap = source.getBitmap(); if (bitmap == null) { return source; } bitmap.recycle(); return new RequestHandler.Result(result, source.getLoadedFrom(), source.getExifRotation()); }