use of android.graphics.Bitmap in project ADWLauncher2 by boombuler.
the class Utilities method drawSelectedAllAppsBitmap.
static void drawSelectedAllAppsBitmap(Canvas dest, int destWidth, int destHeight, boolean pressed, Bitmap src) {
synchronized (sCanvas) {
// we share the statics :-(
if (sIconWidth == -1) {
//initStatics(context);
throw new RuntimeException("Assertion failed: Utilities not initialized");
}
dest.drawColor(0, PorterDuff.Mode.CLEAR);
int[] xy = new int[2];
Bitmap mask = src.extractAlpha(sBlurPaint, xy);
float px = (destWidth - src.getWidth()) / 2;
float py = (destHeight - src.getHeight()) / 2;
dest.drawBitmap(mask, px + xy[0], py + xy[1], pressed ? sGlowColorPressedPaint : sGlowColorFocusedPaint);
mask.recycle();
}
}
use of android.graphics.Bitmap in project ADWLauncher2 by boombuler.
the class IconCache method makeDefaultIcon.
private Bitmap makeDefaultIcon() {
Drawable d = mPackageManager.getDefaultActivityIcon();
Bitmap b = Bitmap.createBitmap(Math.max(d.getIntrinsicWidth(), 1), Math.max(d.getIntrinsicHeight(), 1), Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(b);
d.setBounds(0, 0, b.getWidth(), b.getHeight());
d.draw(c);
return b;
}
use of android.graphics.Bitmap in project VirtualApp by asLody.
the class NotificationFixer method fixNotificationIcon.
private static void fixNotificationIcon(Context context, Notification notification, Notification.Builder builder) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
//noinspection deprecation
builder.setSmallIcon(notification.icon);
//noinspection deprecation
builder.setLargeIcon(notification.largeIcon);
} else {
Icon icon = notification.getSmallIcon();
if (icon != null) {
Bitmap bitmap = drawableToBitMap(icon.loadDrawable(context));
if (bitmap != null) {
Icon newIcon = Icon.createWithBitmap(bitmap);
builder.setSmallIcon(newIcon);
}
}
Icon largeIcon = notification.getLargeIcon();
if (largeIcon != null) {
Bitmap bitmap = drawableToBitMap(largeIcon.loadDrawable(context));
if (bitmap != null) {
Icon newIcon = Icon.createWithBitmap(bitmap);
builder.setLargeIcon(newIcon);
}
}
}
}
use of android.graphics.Bitmap in project VirtualApp by asLody.
the class DrawableUtils method drawableToBitMap.
public 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;
}
}
use of android.graphics.Bitmap in project baker-android by bakerframework.
the class MagazineThumb method renderCover.
/**
* Sets an image file as the cover of this instance of an issue.
*/
private void renderCover() {
String path;
Bitmap bmp;
Log.d(this.getClass().getName(), "Will render cover for magazine " + this.magazine.getName());
try {
if (this.magazine.isStandalone()) {
boolean fromAssets = !(this.getContext().getResources().getBoolean(R.bool.sa_read_from_custom_directory));
if (fromAssets) {
String books = this.getContext().getString(R.string.sa_books_directory);
path = books.concat(File.separator).concat(this.magazine.getName()).concat(File.separator).concat(this.magazine.getCover());
AssetManager assetManager = this.getContext().getAssets();
bmp = BitmapFactory.decodeStream(assetManager.open(path));
} else {
path = Configuration.getMagazinesDirectory(this.getContext()).concat(File.separator).concat(this.magazine.getName()).concat(File.separator).concat(this.magazine.getCover());
bmp = BitmapFactory.decodeFile(path);
}
} else {
path = Configuration.getCacheDirectory(this.getContext()).concat(File.separator).concat(this.magazine.getName());
bmp = BitmapFactory.decodeFile(path);
}
((ImageView) findViewById(R.id.imgCover)).setImageBitmap(bmp);
} catch (IOException ex) {
Log.e(this.getClass().getName(), "Could not render cover for " + this.magazine.getName(), ex);
}
}
Aggregations