當前位置: 首頁>>代碼示例>>Java>>正文


Java BitmapDrawable.getBitmap方法代碼示例

本文整理匯總了Java中android.graphics.drawable.BitmapDrawable.getBitmap方法的典型用法代碼示例。如果您正苦於以下問題:Java BitmapDrawable.getBitmap方法的具體用法?Java BitmapDrawable.getBitmap怎麽用?Java BitmapDrawable.getBitmap使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.graphics.drawable.BitmapDrawable的用法示例。


在下文中一共展示了BitmapDrawable.getBitmap方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: drawableToBitmap

import android.graphics.drawable.BitmapDrawable; //導入方法依賴的package包/類
/**
 * Drawable轉Bitmap方法
 */
public static Bitmap drawableToBitmap(Drawable drawable) {

  Bitmap bitmap;

  if (drawable instanceof BitmapDrawable) {
    BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
    if (bitmapDrawable.getBitmap() != null) {
      return bitmapDrawable.getBitmap();
    }
  }

  if (drawable.getIntrinsicWidth() <= 0 || drawable.getIntrinsicHeight() <= 0) {
    bitmap = Bitmap.createBitmap(1, 1,
        Bitmap.Config.ARGB_8888);
  } else {
    bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(),
        Bitmap.Config.ARGB_8888);
  }

  Canvas canvas = new Canvas(bitmap);
  drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
  drawable.draw(canvas);
  return bitmap;
}
 
開發者ID:MUFCRyan,項目名稱:BilibiliClient,代碼行數:28,代碼來源:ImageBlurUtil.java

示例2: drawable2Bitmap

import android.graphics.drawable.BitmapDrawable; //導入方法依賴的package包/類
/**
 * drawable轉bitmap
 *
 * @param drawable drawable對象
 * @return bitmap
 */
public static Bitmap drawable2Bitmap(final Drawable drawable) {
	if (drawable instanceof BitmapDrawable) {
		BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
		if (bitmapDrawable.getBitmap() != null) {
			return bitmapDrawable.getBitmap();
		}
	}
	Bitmap bitmap;
	if (drawable.getIntrinsicWidth() <= 0 || drawable.getIntrinsicHeight() <= 0) {
		bitmap = Bitmap.createBitmap(1, 1,
				drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565);
	} else {
		bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(),
				drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565);
	}
	Canvas canvas = new Canvas(bitmap);
	drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
	drawable.draw(canvas);
	return bitmap;
}
 
開發者ID:MobClub,項目名稱:BBSSDK-for-Android,代碼行數:27,代碼來源:ImageUtils.java

示例3: drawableToBitMap

import android.graphics.drawable.BitmapDrawable; //導入方法依賴的package包/類
private static Bitmap drawableToBitMap(Drawable drawable) {
    if (drawable == null) {
        return null;
    }
    if (drawable instanceof BitmapDrawable) {
        BitmapDrawable bitmapDrawable = ((BitmapDrawable) drawable);
        return bitmapDrawable.getBitmap();
    } else {
        Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(),
                drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565);
        Canvas canvas = new Canvas(bitmap);
        drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
        drawable.draw(canvas);
        return bitmap;
    }
}
 
開發者ID:coding-dream,項目名稱:TPlayer,代碼行數:17,代碼來源:NotificationFixer.java

示例4: drawable2Bitmap

import android.graphics.drawable.BitmapDrawable; //導入方法依賴的package包/類
/**
 * drawable轉bitmap
 *
 * @param drawable drawable對象
 * @return bitmap
 */
public static Bitmap drawable2Bitmap(final Drawable drawable) {
    if (drawable instanceof BitmapDrawable) {
        BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
        if (bitmapDrawable.getBitmap() != null) {
            return bitmapDrawable.getBitmap();
        }
    }
    Bitmap bitmap;
    if (drawable.getIntrinsicWidth() <= 0 || drawable.getIntrinsicHeight() <= 0) {
        bitmap = Bitmap.createBitmap(1, 1,
                drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565);
    } else {
        bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(),
                drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565);
    }
    Canvas canvas = new Canvas(bitmap);
    drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
    drawable.draw(canvas);
    return bitmap;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:27,代碼來源:ConvertUtils.java

示例5: drawable2Bitmap

import android.graphics.drawable.BitmapDrawable; //導入方法依賴的package包/類
private Bitmap drawable2Bitmap(final Drawable drawable) {
    if (drawable instanceof BitmapDrawable) {
        BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
        if (bitmapDrawable.getBitmap() != null) {
            return bitmapDrawable.getBitmap();
        }
    }
    Bitmap bitmap;
    if (drawable.getIntrinsicWidth() <= 0 || drawable.getIntrinsicHeight() <= 0) {
        bitmap = Bitmap.createBitmap(1, 1,
                drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565);
    } else {
        bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(),
                drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565);
    }
    Canvas canvas = new Canvas(bitmap);
    drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
    drawable.draw(canvas);
    return bitmap;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:21,代碼來源:SpanUtils.java

示例6: drawable2Bitmap

import android.graphics.drawable.BitmapDrawable; //導入方法依賴的package包/類
private static Bitmap drawable2Bitmap(final Drawable drawable) {
    if (drawable instanceof BitmapDrawable) {
        BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
        if (bitmapDrawable.getBitmap() != null) {
            return bitmapDrawable.getBitmap();
        }
    }
    Bitmap bitmap;
    if (drawable.getIntrinsicWidth() <= 0 || drawable.getIntrinsicHeight() <= 0) {
        bitmap = Bitmap.createBitmap(1, 1,
                drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565);
    } else {
        bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(),
                drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565);
    }
    Canvas canvas = new Canvas(bitmap);
    drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
    drawable.draw(canvas);
    return bitmap;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:21,代碼來源:CacheUtils.java

示例7: drawableToBitmap

import android.graphics.drawable.BitmapDrawable; //導入方法依賴的package包/類
private static Bitmap drawableToBitmap(Drawable drawable) {
    Bitmap bitmap;
    if (drawable instanceof BitmapDrawable) {
        BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
        if (bitmapDrawable.getBitmap() != null) {
            return bitmapDrawable.getBitmap();
        }
    }
    if (drawable.getIntrinsicWidth() <= 0 || drawable.getIntrinsicHeight() <= 0) {
        bitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888);
    } else {
        bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
    }
    Bitmap bitmapResized = Bitmap.createScaledBitmap(bitmap, 40, 40, false);
    Canvas canvas = new Canvas(bitmapResized);
    drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
    drawable.draw(canvas);
    return bitmapResized;
}
 
開發者ID:sarbajitsaha,項目名稱:Batch-Uninstaller,代碼行數:20,代碼來源:PackageUtils.java

示例8: initCofig

import android.graphics.drawable.BitmapDrawable; //導入方法依賴的package包/類
void initCofig(Context context, AttributeSet attrs) {
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CircleButton);
    mColorNormal = a.getColor(R.styleable.CircleButton_pb_color, Color.parseColor("#ffffff"));
    mColorChecked = a.getColor(R.styleable.CircleButton_pb_color_checked, Color.parseColor("#FFFF000D"));
    mTextOn = a.getString(R.styleable.CircleButton_pb_text_on);
    mTextOff = a.getString(R.styleable.CircleButton_pb_text_off);
    BitmapDrawable bdmBackgroundChecked = (BitmapDrawable) a.getDrawable(R.styleable.CircleButton_pb_background_checked);
    mCheckable = a.getBoolean(R.styleable.CircleButton_pb_checkable, false);

    if (bdmBackgroundChecked != null)
        mBackgroundChecked = bdmBackgroundChecked.getBitmap();

    BitmapDrawable bdmBackground = (BitmapDrawable) a.getDrawable(R.styleable.CircleButton_pb_background);
    if (bdmBackground != null)
        mBackground = bdmBackground.getBitmap();

    a.recycle();
}
 
開發者ID:panshen,項目名稱:PopupCircleMenu,代碼行數:19,代碼來源:PopupButton.java

示例9: drawableToBitmap

import android.graphics.drawable.BitmapDrawable; //導入方法依賴的package包/類
private static Bitmap drawableToBitmap(Drawable drawable) {
    Bitmap bitmap;

    if (drawable instanceof BitmapDrawable) {
        BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
        if (bitmapDrawable.getBitmap() != null) {
            return bitmapDrawable.getBitmap();
        }
    }

    if (drawable.getIntrinsicWidth() <= 0 || drawable.getIntrinsicHeight() <= 0) {
        bitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888); // Single color bitmap will be created of 1x1 pixel
    } else {
        bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
    }

    Canvas canvas = new Canvas(bitmap);
    drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
    drawable.draw(canvas);
    return bitmap;
}
 
開發者ID:OhMyLob,項目名稱:Paper-Launcher,代碼行數:22,代碼來源:IconUtil.java

示例10: drawableToBitmap

import android.graphics.drawable.BitmapDrawable; //導入方法依賴的package包/類
private static Bitmap drawableToBitmap(final Drawable drawable) {
  if (drawable instanceof BitmapDrawable) {
    final BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
    if (bitmapDrawable.getBitmap() != null) {
      return bitmapDrawable.getBitmap();
    }
  }

  final Bitmap bitmap;
  if (drawable.getIntrinsicWidth() <= 0 || drawable.getIntrinsicHeight() <= 0) {
    bitmap = Bitmap.createBitmap(FRAME_WIDTH, FRAME_HEIGHT, Bitmap.Config.ARGB_8888);
  } else {
    bitmap =
        Bitmap.createBitmap(
            drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
  }

  final Canvas canvas = new Canvas(bitmap);
  drawable.draw(canvas);
  return bitmap;
}
 
開發者ID:uber,項目名稱:RIBs,代碼行數:22,代碼來源:XRay.java

示例11: drawableToBitmap

import android.graphics.drawable.BitmapDrawable; //導入方法依賴的package包/類
private static Bitmap drawableToBitmap (Drawable drawable) {
    Bitmap bitmap = null;

    if (drawable instanceof BitmapDrawable) {
        BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
        if(bitmapDrawable.getBitmap() != null) {
            return bitmapDrawable.getBitmap();
        }
    }

    if(drawable.getIntrinsicWidth() <= 0 || drawable.getIntrinsicHeight() <= 0) {
        bitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888); // Single color bitmap will be created of 1x1 pixel
    } else {
        bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
    }

    Canvas canvas = new Canvas(bitmap);
    drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
    drawable.draw(canvas);
    return bitmap;
}
 
開發者ID:michelelacorte,項目名稱:FlickLauncher,代碼行數:22,代碼來源:ShortcutsManager.java

示例12: drawableToBitmap

import android.graphics.drawable.BitmapDrawable; //導入方法依賴的package包/類
/**
 * Creates a Bitmap object from a Drawable object.
 */
private static Bitmap drawableToBitmap(Drawable dr) {
    // Attempt to retrieve any existing Bitmap, if possible
    if (dr instanceof BitmapDrawable) {
        BitmapDrawable bDr = (BitmapDrawable)dr;
        if (bDr.getBitmap() != null) {
            return bDr.getBitmap();
        }
    }

    // Create a valid blank Bitmap
    final Bitmap bitmap;
    if (dr.getIntrinsicWidth() <= 0 || dr.getIntrinsicHeight() <= 0) {
        // Single color bitmap will be create of 1x1 pixel
        bitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888);
    } else {
        bitmap = Bitmap.createBitmap(dr.getIntrinsicWidth(),
                dr.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
    }

    // Use our Canvas to draw the Drawable onto the Bitmap
    Canvas canvas = new Canvas(bitmap);
    dr.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
    dr.draw(canvas);
    return bitmap;
}
 
開發者ID:tylersuehr7,項目名稱:chips-input-layout,代碼行數:29,代碼來源:LetterTileProvider.java

示例13: DirectionView

import android.graphics.drawable.BitmapDrawable; //導入方法依賴的package包/類
public DirectionView(Context context, AttributeSet attrs) {
    super(context, attrs);

    BitmapDrawable drawble = (BitmapDrawable) ContextCompat.getDrawable(getContext(),
            R.drawable.direction);
    image = drawble.getBitmap();
}
 
開發者ID:Twelvelines,項目名稱:AndroidMuseumBleManager,代碼行數:8,代碼來源:DirectionView.java

示例14: drawableToBitMap

import android.graphics.drawable.BitmapDrawable; //導入方法依賴的package包/類
private Bitmap drawableToBitMap(Drawable drawable) {
    if (drawable instanceof BitmapDrawable) {
        BitmapDrawable bitmapDrawable = ((BitmapDrawable) drawable);
        return bitmapDrawable.getBitmap();
    } else {
        Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565);
        Canvas canvas = new Canvas(bitmap);
        drawable.setBounds(0, 0, drawable.getIntrinsicWidth(),
                drawable.getIntrinsicHeight());
        drawable.draw(canvas);
        return bitmap;
    }
}
 
開發者ID:amikey,項目名稱:DroidPlugin,代碼行數:14,代碼來源:INotificationManagerHookHandle.java

示例15: releaseTargetDrawable

import android.graphics.drawable.BitmapDrawable; //導入方法依賴的package包/類
private void releaseTargetDrawable() {
    if (!frescoEnable && targetDrawable != null && targetDrawable instanceof BitmapDrawable) {
        BitmapDrawable bitmapDrawable = (BitmapDrawable) targetDrawable;
        Bitmap bitmap = bitmapDrawable.getBitmap();
        if (!bitmap.isRecycled()) {
            bitmap.isRecycled();
        }
        targetDrawable = null;
    }
}
 
開發者ID:Bleoo,項目名稱:WindowImageView,代碼行數:11,代碼來源:DrawableController.java


注:本文中的android.graphics.drawable.BitmapDrawable.getBitmap方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。