me.jfenn.androidutils.ImageUtils Java Examples

The following examples show how to use me.jfenn.androidutils.ImageUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NotificationData.java    From Status with Apache License 2.0 6 votes vote down vote up
/**
 * Get a full res icon of the notification.
 *
 * @param context           The current application context.
 * @return The created bitmap, or null if
 *                          things went wrong.
 */
@Nullable
public Bitmap getIcon(Context context) {
    if (icon == null) {
        Drawable drawable = null;
        if (iconRes != 0) drawable = getDrawable(context, iconRes, packageName);
        if (drawable == null && unloadedIcon != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
            drawable = unloadedIcon.loadDrawable(context);

        if (drawable != null) {
            Bitmap bitmap = ImageUtils.drawableToBitmap(drawable);
            if (bitmap != null) {
                icon = bitmap;
                scaledIcon = null;
            }
        }
    }
    return icon;
}
 
Example #2
Source File: CircleImageView.java    From ColorPickerDialog with Apache License 2.0 5 votes vote down vote up
@Override
public void onDraw(Canvas canvas) {
    Bitmap image = ImageUtils.drawableToBitmap(getDrawable());
    if (image != null) {
        int size = Math.min(getWidth(), getHeight());
        image = ThumbnailUtils.extractThumbnail(image, size, size);

        RoundedBitmapDrawable roundedBitmapDrawable = RoundedBitmapDrawableFactory.create(getResources(), image);

        roundedBitmapDrawable.setCornerRadius(size / 2);
        roundedBitmapDrawable.setAntiAlias(true);

        canvas.drawBitmap(ImageUtils.drawableToBitmap(roundedBitmapDrawable), 0, 0, paint);
    }
}
 
Example #3
Source File: IconStyleData.java    From Status with Apache License 2.0 5 votes vote down vote up
/**
 * Get a bitmap from the style at a particular index. This will
 * also cache the created bitmaps to increase performance of future
 * calls.
 *
 * @param context               The current application context.
 * @param value                 The index to obtain.
 * @return A created bitmap, or null if something
 *                              has gone horribly wrong.
 */
@Nullable
public Bitmap getBitmap(Context context, int value) {
    if (icons.containsKey(value))
        return icons.get(value);
    else {
        Drawable drawable = getDrawable(context, value);
        if (drawable != null) {
            Bitmap bitmap = ImageUtils.drawableToBitmap(drawable);
            icons.put(value, bitmap);
            return bitmap;
        } else return null;
    }
}
 
Example #4
Source File: SlideActionView.java    From SlideActionView with Apache License 2.0 2 votes vote down vote up
/**
 * Specifies the icon to display on the left side of the view,
 * as a Drawable. If it is just as easier to pass a Bitmap, you
 * should avoid using this method; all it does is convert the
 * drawable to a bitmap, then call the same method again.
 *
 * @param drawable          The Drawable to use as an icon.
 */
public void setLeftIcon(Drawable drawable) {
    setLeftIcon(ImageUtils.drawableToBitmap(drawable));
}
 
Example #5
Source File: SlideActionView.java    From SlideActionView with Apache License 2.0 2 votes vote down vote up
/**
 * Specifies the icon to display on the right side of the view,
 * as a Drawable. If it is just as easier to pass a Bitmap, you
 * should avoid using this method; all it does is convert the
 * drawable to a bitmap, then call the same method again.
 *
 * @param drawable          The Drawable to use as an icon.
 */
public void setRightIcon(Drawable drawable) {
    setRightIcon(ImageUtils.drawableToBitmap(drawable));
}