1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | public class GameView extends View { public GameView(Context context) { super (context); } @Override protected void onDraw(Canvas canvas) { super .onDraw(canvas); Bitmap bmp = Bitmap.createBitmap( 480 , 800 , Config.ARGB_8888); canvas = new Canvas(bmp); Paint myPaint = new Paint(); myPaint.setColor(Color.RED); myPaint.setAntiAlias( true ); canvas.drawCircle( 50 , 50 , 50 , myPaint); File file = new File( "/sdcard/test/" ); if (!file.exists()){ file.mkdirs(); } try { FileOutputStream fos = new FileOutputStream(file.getPath() + "/1.jpg" ); bmp.compress(Bitmap.CompressFormat.JPEG, 100 , fos); fos.close(); } catch (Exception e) { Log.e( "Error" , e.toString()); } } } |
1 2 3 4 5 6 7 8 9 | Bitmap bmp = Bitmap.createBitmap( 480 , 800 , Config.ARGB_8888); // canvas = new Canvas(bmp); Paint myPaint = new Paint(); myPaint.setColor(Color.RED); myPaint.setAntiAlias( true ); Canvas c = new Canvas(bmp); c.drawCircle( 50 , 50 , 50 , myPaint); Matrix m = new Matrix(); canvas.drawBitmap(bmp, m, myPaint); |
联系客服