Code example for Picture

Methods: beginRecording, draw, endRecording, getHeight, getWidth

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) * mScale);
		pathNorth.lineTo(center + 4 * mScale, center);
		pathNorth.lineTo(center - 4 * mScale, center);
		pathNorth.lineTo(center, center - (mCompassRadius - 3) * mScale);
		pathNorth.close();
		canvas.drawPath(pathNorth, northPaint);
 
		// Red triangle pointing south 
		final Path pathSouth = new Path();
		pathSouth.moveTo(center, center + (mCompassRadius - 3) * mScale);
		pathSouth.lineTo(center + 4 * mScale, center);
		pathSouth.lineTo(center - 4 * mScale, center);
		pathSouth.lineTo(center, center + (mCompassRadius - 3) * mScale);
		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(int mCompassRadius, final float mScale) {
		Picture mCompassRose = createCompassRosePicture(mCompassRadius, mScale);
		// Convert As BitMap 
				Bitmap bm = Bitmap.createBitmap(mCompassRose.getWidth(), mCompassRose.getHeight(), Bitmap.Config.ARGB_8888);
				Canvas c = new Canvas(bm);
				mCompassRose.draw(c);
				return bm;
	} 
}