分享

android bitmap传入canvas 画的东西看不见

 quasiceo 2015-12-30
android中,我将一个bitmap传入canvas中,并且在上面画了一个圆,然后再将bitmap保存,保存出来的图片上面的确有个圆,但是我在模拟器上看不到圆,要怎么弄呢?
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());
        }
    }
}

 

    0
  • 平凡简单 平凡简单 3年前
    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);
    --- 共有 1 条评论 ---

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多