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

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -