本文整理汇总了Java中android.graphics.drawable.BitmapDrawable.getIntrinsicWidth方法的典型用法代码示例。如果您正苦于以下问题:Java BitmapDrawable.getIntrinsicWidth方法的具体用法?Java BitmapDrawable.getIntrinsicWidth怎么用?Java BitmapDrawable.getIntrinsicWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.graphics.drawable.BitmapDrawable
的用法示例。
在下文中一共展示了BitmapDrawable.getIntrinsicWidth方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: load
import android.graphics.drawable.BitmapDrawable; //导入方法依赖的package包/类
private void load(Context context, @DrawableRes int drawableRes, int textSize, String url) {
if (!nativeLoad(handle, url)) {
nativeClose(handle);
throw new RuntimeException("not gif");
} else {
frameNum = nativeGetFrameCount(handle);
for (int i = 0; i < frameNum; i++) {
BitmapDrawable drawable = new BitmapDrawable(context.getResources(), nativeGetFrame(handle, i));
int width = (textSize * drawable.getIntrinsicWidth()) / drawable.getIntrinsicHeight();
drawable.setBounds(0, 0, width, textSize);
EmoticonCache.saveDrawable(drawableRes, i, drawable);
delay = nativeGetDelay(handle, i);
}
nativeClose(handle);
}
}
示例2: updateScale
import android.graphics.drawable.BitmapDrawable; //导入方法依赖的package包/类
private void updateScale() {
Drawable d = getDrawable();
if(d instanceof BitmapDrawable) {
BitmapDrawable bd = (BitmapDrawable) d;
// Don't upscale if more than 2x larger
if (getWidth() > mMaxScale * bd.getIntrinsicWidth()
&& getHeight() > mMaxScale * bd.getIntrinsicHeight()) {
setScaleType(ScaleType.MATRIX);
Matrix trans = new Matrix();
Matrix scale = new Matrix();
trans.setTranslate((getWidth() - mMaxScale * bd.getIntrinsicWidth())/2, (getHeight() - mMaxScale * bd.getIntrinsicHeight())/2);
scale.setScale(mMaxScale, mMaxScale);
Matrix m = new Matrix();
if(isInEditMode()) {
// WTF? Edit mode consider inversed matrix??
m.setConcat(scale, trans);
}else {
m.setConcat(trans, scale);
}
setImageMatrix(m);
}else {
setScaleType(ScaleType.CENTER_CROP);
}
}
}