Search in sources :

Example 56 with Bitmap

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();
    }
}
Also used : Bitmap(android.graphics.Bitmap)

Example 57 with Bitmap

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;
}
Also used : Bitmap(android.graphics.Bitmap) Canvas(android.graphics.Canvas) Drawable(android.graphics.drawable.Drawable)

Example 58 with Bitmap

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);
            }
        }
    }
}
Also used : Bitmap(android.graphics.Bitmap) Icon(android.graphics.drawable.Icon)

Example 59 with Bitmap

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;
    }
}
Also used : Bitmap(android.graphics.Bitmap) Canvas(android.graphics.Canvas) BitmapDrawable(android.graphics.drawable.BitmapDrawable)

Example 60 with 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);
    }
}
Also used : Bitmap(android.graphics.Bitmap) AssetManager(android.content.res.AssetManager) ImageView(android.widget.ImageView) IOException(java.io.IOException)

Aggregations

Bitmap (android.graphics.Bitmap)3746 Canvas (android.graphics.Canvas)889 Paint (android.graphics.Paint)709 BitmapDrawable (android.graphics.drawable.BitmapDrawable)461 IOException (java.io.IOException)394 Rect (android.graphics.Rect)341 File (java.io.File)262 Test (org.junit.Test)255 Matrix (android.graphics.Matrix)254 Drawable (android.graphics.drawable.Drawable)243 BitmapFactory (android.graphics.BitmapFactory)240 View (android.view.View)225 ImageView (android.widget.ImageView)210 Intent (android.content.Intent)187 FileOutputStream (java.io.FileOutputStream)186 InputStream (java.io.InputStream)171 RectF (android.graphics.RectF)150 FileNotFoundException (java.io.FileNotFoundException)150 Point (android.graphics.Point)148 Uri (android.net.Uri)128