当前位置: 首页>>代码示例>>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;未经允许,请勿转载。