PostProcessor
public
interface
PostProcessor
Helper interface for adding custom processing to an image.
The image being processed may be a Drawable, a Bitmap, or
a frame of an AnimatedImageDrawable produced by ImageDecoder.
This is called before the requested object is returned.
This custom processing can even be applied to images that will be returned
as immutable objects, such as a Bitmap with Config
Bitmap.Config.HARDWARE returned by ImageDecoder.
On an AnimatedImageDrawable, the callback will only be called once,
but the drawing commands will be applied to each frame, as if the Canvas
had been returned by Picture.beginRecording.
Supplied to ImageDecoder via setPostProcessor.
Summary
Public methods | |
|---|---|
abstract
int
|
onPostProcess(Canvas canvas)
Do any processing after (for example) decoding. |
Public methods
onPostProcess
public abstract int onPostProcess (Canvas canvas)
Do any processing after (for example) decoding.
Drawing to the Canvas will behave as if the initial processing
(e.g. decoding) already exists in the Canvas. An implementation can draw
effects on top of this, or it can even draw behind it using
PorterDuff.Mode.DST_OVER. A common
effect is to add transparency to the corners to achieve rounded corners.
That can be done with the following code:
Path path = new Path(); path.setFillType(Path.FillType.INVERSE_EVEN_ODD); int width = canvas.getWidth(); int height = canvas.getHeight(); path.addRoundRect(0, 0, width, height, 20, 20, Path.Direction.CW); Paint paint = new Paint(); paint.setAntiAlias(true); paint.setColor(Color.TRANSPARENT); paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC)); canvas.drawPath(path, paint); return PixelFormat.TRANSLUCENT;
| Parameters | |
|---|---|
canvas |
Canvas: The Canvas to draw to.
This value cannot be null. |
