public static void drawEdgeContours ( List < EdgeContour > contours , int color , Bitmap output , byte [ ] storage ) { if ( output . getConfig ( ) != Bitmap . Config . ARGB_8888 ) throw new IllegalArgumentException ( "Only ARGB_8888 is supported" ) ; if ( storage == null ) storage = declareStorage ( output , null ) ; else Arrays . fill ( storage , ( byte ) 0 ) ; byte r = ( byte ) ( ( color >> 16 ) & 0xFF ) ; byte g = ( byte ) ( ( color >> 8 ) & 0xFF ) ; byte b = ( byte ) ( color ) ; for ( int i = 0 ; i < contours . size ( ) ; i ++ ) { EdgeContour e = contours . get ( i ) ; for ( int j = 0 ; j < e . segments . size ( ) ; j ++ ) { EdgeSegment s = e . segments . get ( j ) ; for ( int k = 0 ; k < s . points . size ( ) ; k ++ ) { Point2D_I32 p = s . points . get ( k ) ; int index = p . y * 4 * output . getWidth ( ) + p . x * 4 ; storage [ index ++ ] = b ; storage [ index ++ ] = g ; storage [ index ++ ] = r ; storage [ index ] = ( byte ) 0xFF ; } } } output . copyPixelsFromBuffer ( ByteBuffer . wrap ( storage ) ) ; }
Draws each contour using a single color .