打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
android bitmap传入canvas 画的东西看不见
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 条评论 ---
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
关于魔法攻击的简单实现-游戏开发基础
【代码】android截屏功能实现
8.2.1 Bitmap(位图)全解析 Part 1
Android画图之Bitmap(一)
利用OpenCV在Android上DIY相机——第二届 Google 暑期大学生博客分享大...
android Bitmap学习总结
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服