very little has been discussed about DrawFilter over the net, so i couldnt find a decent answer for the following question:
it has been documanted here that:
A DrawFilter subclass can be installed in a Canvas. When it is present, it can modify the paint that is used to draw (temporarily). With this, a filter can disable/enable antialiasing, or change the color for everything this is drawn.
So i do want to use this feature in order to change the color things are drawn in my canvas to black, but how is it done? since this class has no methods to override its a ridle how i should subclass it to acheive what is documanted…
BTW, to whoever never seen it, canvas has a method canvas.setDrawFilter(DrawFilter) that should be used, i tried to look at the open source code but i didnt get a clue there…
any ideas?
The only available subclass of
DrawFilterseems to be exclusively for tweaking bits inPaintflags:setDrawFilter(new PaintFlagsDrawFilter(Paint.ANTI_ALIAS_FLAG,Paint.DITHER_FLAG))So, I doubt it is of much use.
Also, check out
ColorFilter. AndsetSaturation()ofColorMatrix. That might help drawing in grayscale.Example: to draw an colored image (
inImg) as black and white (outImgof sizesize) on a canvas: