Code example for Picture

Methods: beginRecordingendRecording

0
        // mScale); 
        final int picBorderWidthAndHeight = (int) ((mCompassRadius + 5) * 2);
        final int center = picBorderWidthAndHeight / 2;
 
        // Record Rose 
        Picture mCompassRose = new Picture();
        final Canvas canvas = mCompassRose.beginRecording(picBorderWidthAndHeight, picBorderWidthAndHeight);
 
        // Blue triangle pointing north 
        final Path pathNorth = new Path();
        pathNorth.moveTo(center, center - (mCompassRadius - 3) * displayDensity);
        pathNorth.lineTo(center + 4 * displayDensity, center);
        pathNorth.lineTo(center - 4 * displayDensity, center);
        pathNorth.lineTo(center, center - (mCompassRadius - 3) * displayDensity);
        pathNorth.close();
        canvas.drawPath(pathNorth, northPaint);
 
        // Red triangle pointing south 
        final Path pathSouth = new Path();
        pathSouth.moveTo(center, center + (mCompassRadius - 3) * displayDensity);
        pathSouth.lineTo(center + 4 * displayDensity, center);
        pathSouth.lineTo(center - 4 * displayDensity, center);
        pathSouth.lineTo(center, center + (mCompassRadius - 3) * displayDensity);
        pathSouth.close();
        canvas.drawPath(pathSouth, southPaint);
 
        // Draw a little white dot in the middle 
        canvas.drawCircle(center, center, 2, centerPaint);
 
        mCompassRose.endRecording();
        return mCompassRose;
 
    } 
 
    public static Bitmap createCompassRoseBitmap(final int mCompassRadius, final float displayDensity) {
Contextual code suggestions in your IDE  Get Codota for Java