Code example for Bitmap

Methods: eraseColorgetHeightgetWidth

0
		postInvalidate();
	} 
	public Bitmap getGraphBitmap() {
		Bitmap bitmap;
	 
		if (graphBitmap != null && (int)(getWidth() - AXIS_PADDING) == graphBitmap.getWidth() && 
				getHeight()-AXIS_PADDING == graphBitmap.getHeight()) {
			graphBitmap.eraseColor(Color.BLACK);
			bitmap = graphBitmap; 
		} else { 
			bitmap = Bitmap.createBitmap((int)(getWidth() - AXIS_PADDING), getHeight()-AXIS_PADDING, Bitmap.Config.ARGB_8888);
		} 
		Canvas c = new Canvas(bitmap);
		RectF area = graph.getModifyRect();
		float l = area.left;
		float r = area.right;
		float w = r-l;
		 
	 
		float deltaMove = mMoveX*w/bitmap.getWidth();
		if (graph.getWidth() < w) {
			l = graph.getLeftX();
			deltaMove = 0; 
		} else  
		if (graph.getLeftX() > l + deltaMove) {
			deltaMove = -l + graph.getLeftX();
		} else  
		if (graph.getRightX() < r + deltaMove) {
			deltaMove = graph.getRightX() - r;
		} 
		 
		graph.setDx(l+ deltaMove, r+ deltaMove);
		 
		float b = area.bottom;
		float t = area.top;
		w = b - t;
		 
		 
		deltaMove = mMoveY*w/bitmap.getHeight();
		graph.setEy(t - deltaMove, b - deltaMove);