• 图片_ _ Bitmap_Drawable_Image?


    ===== 2 

    ==== 1  

    b、读取res/drawable目录下的 png或者bmp

    Resources r = this.getContext().getResources();
    //以数据流的方式读取资源
    Inputstream is = r.openRawResource(R.drawable.mm_image);
    BitmapDrawable bmpDraw = new BitmapDrawable(is);
    Bitmap bmp = bmpDraw.getBitmap();

    如果需要利用图片解码器,如下使用:
    InputStream is = getResources().openRawResource(R.drawable.icon);
    Bitmap mBitmap = BitmapFactory.decodeStream(is);
    Paint mPaint = new Paint();
    canvas.drawBitmap(mBitmap, 40, 40, mPaint);

    用 Bitmap  bm = BitmapFactory.decodeResource(this.getResources(), R.drawable.splash);
    BitmapDrawable  bd = new BitmapDrawable(this.getResources(), bm);
    mBtn.setBackgroundDrawable(bd);         来代替  mBtn.setBackgroundResource(R.drawable.splash)。

  • 相关阅读:
    Vue入门
    吃透SprinngBoot
    SSM整合详解
    Linux查找端口并关闭
    接入腾讯云的OCR识别身份证信息
    IDEA 快捷键《宋红康版》
    Mysql详解
    docker常见命令
    SpringBoot集成Redis
    使用mybatis出现异常
  • 原文地址:https://www.cnblogs.com/awkflf11/p/5366233.html
Copyright © 2020-2023  润新知