zoukankan      html  css  js  c++  java
  • android将drawable下的图片转换成bitmap

    将drawable下的图片转换成bitmap

    1、 Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.xxx);

    2、Resources r = this.getContext().getResources();
          Inputstream is = r.openRawResource(R.drawable.xxx);
          BitmapDrawable  bmpDraw = new BitmapDrawable(is);
          Bitmap bmp = bmpDraw.getBitmap();

    3、Resources r = this.getContext().getResources();

          Bitmap bmp=BitmapFactory.decodeResource(r, R.drawable.icon);
          Bitmap bmp = Bitmap.createBitmap( 300, 300, Config.ARGB_8888 );

    将drawable下的图片转换成Drawable

    Resources resources = mContext.getResources();
    Drawable drawable = resources.getDrawable(R.drawable.a);
    imageview.setBackground(drawable);

  • 相关阅读:
    swift
    swift
    ios
    Swift
    swift
    swift
    /var/log/cron
    Django 数据传递
    HTML 属性
    HTML 元素
  • 原文地址:https://www.cnblogs.com/JLZT1223/p/6692243.html
Copyright © 2011-2022 走看看