android - How to use Canvas.clipRects to highlight face rects? -
i have bitmap multiple faces. want highlight each face such that, face rects have original color , rest of area blacked out.
i did like,
for(int i=0; i<getnumfaces(); i++) { rect rect = getrect(); canvas = new canvas(mutablebitmap); canvas.cliprect(rect, region.op.difference); canvas.drawcolor(color.black, mode.src_atop); } confirmationview.setimagebitmap(mutablebitmap);
but makes entire image black. kinda know reason not able figure out solution.
there might better way, try this:
canvas = new canvas(mutablebitmap); for(int i=0; i<getnumfaces(); i++) { rect rect = getrect(); canvas.cliprect(rect, region.op.union); } rect = new rect(0,0,mutablebitmap.getwidth(), mutablebitmap.getheight()); canvas.cliprect(all , region.op.difference); canvas.drawcolor(color.black); confirmationview.setimagebitmap(mutablebitmap);
note: haven't run this. building 1 big clipping region consisting of rects want keep. creating clip consisting of bitmap except areas want keep. coloring part don't want keep in.
Comments
Post a Comment