private Canvas buildCanvas ( ) { Canvas canvas = new Canvas ( ) ; Dimension dimension = getSize ( ) ; Point point = coordinates . inViewPort ( ) ; int x = point . x ; int y = point . y ; // Avoid internal error by making sure we have some width and height int w = Math . max ( dimension . width , 1 ) ; int h = Math . max ( dimension . height , 1 ) ; canvas . setX ( x ) ; canvas . setY ( y ) ; canvas . setHeight ( h ) ; canvas . setWidth ( w ) ; canvas . setViewPortRelative ( true ) ; return canvas ; }
Create a canvas which is an object that specifies a rectangle to take a screenshot of .