Let's start with a brief description of the drawing:
Due to Canvas.drawbitmap (bitmap, SRC, DST, paint), there are four parameters so there are roughly four or five steps.
1, through the GetResource () method to get the Bitmapdrawable type object in the Drawable folder
2. Convert the bitmapdrawable type to an object of type bitmap
3, create SRC, DST, two rectangles, SRC refers to the original graphics truncated pictures, DST refers to the target location of the rectangle.
4, the picture of the brush is generally null.
5. Call Canvas.drawbitmap (bitmap, SRC, DST, paint) method.
It then shows how to rotate the picture:
Primarily through matrix matrices.
1. Creating a Matrix Object
2. Determine the direction of rotation
3. Canvas Set Matrix
Note : Any graphics in the canvas after Canvas.setmatrix (matrix) will rotate.
When you finish drawing the image you want to rotate, call Canvas.setmatrix (null), and cancel the rotation of the canvas.
Instance code:
/* * Insert Picture */bitmapdrawable drawable = (bitmapdrawable) getresources (). getdrawable (R.drawable.girls); Bitmap Bitmap = Drawable.getbitmap (); Rect src = new rect (0,0,440,320); Rect dst = new rect (Maxleft, MaxUp, Maxright, Maxbottom); Matrix matrix = new Matrix (matrix.setrotate, 0, 0), Canvas.setmatrix (Matrix), Canvas.drawbitmap (bitmap, SRC, DST, NULL);//canvas.setmatrix (null);
Thank you ~
"Android Get started ten" draw pictures and picture rotation