public class SimpleBitmap extends Object
Bitmap bitmap1 = SimpleBitmap.with(context).get(R.drawable.foo); Bitmap bitmap2 = SimpleBitmap.with(context).scale(R.drawable.foo, getWidth()/2, getHeight()/2);
Modifier and Type | Method and Description |
---|---|
Bitmap |
get(int id)
Returns the bitmap image for the resource file with the given ID.
|
Bitmap |
get(int id,
float width,
float height)
Returns the bitmap that corresponds to the given resource ID,
scaled to the given width and height.
|
Bitmap |
get(String url)
Returns the bitmap image for the file located at the given web URL.
|
Bitmap |
get(URL url)
Returns the bitmap image for the file located at the given web URL.
|
ArrayList<Bitmap> |
getAll(int... ids)
Returns a list of the bitmap images for the resource files with the given IDs.
|
ArrayList<Bitmap> |
getAllScaled(float width,
float height,
int... ids)
Returns a list of the bitmap images for the resource files with the given IDs,
scaled to the given width and height.
|
ArrayList<Bitmap> |
getAllScaled(float scaleFactor,
int... ids)
Returns a list of the bitmap images for the resource files with the given IDs,
scaled by the given factor.
|
boolean |
isFiltered()
Whether we filter bitmaps on scale/rotate for smoothness.
|
Bitmap |
rotate(Bitmap bitmap,
float degrees)
Returns a new bitmap based on the given bitmap but rotated by the given number of degrees
clockwise about its center point.
|
Bitmap |
rotate(Bitmap bitmap,
float degrees,
float rx,
float ry)
Returns a new bitmap based on the given bitmap but rotated by the given number of degrees
clockwise about the point (rx, ry).
|
Bitmap |
rotate(int id,
float degrees)
Returns a new bitmap based on the given bitmap but rotated by the given number of degrees
clockwise about its center point.
|
Bitmap |
rotate(int id,
float degrees,
float rx,
float ry)
Returns a new bitmap based on the given bitmap but rotated by the given number of degrees
clockwise about the point (rx, ry).
|
Bitmap |
rotateLeft(Bitmap bitmap)
Returns a new bitmap based on the given bitmap but rotated counter-clockwise by 90 degrees
about its center point.
|
Bitmap |
rotateLeft(int id)
Returns a new bitmap based on the given bitmap but rotated counter-clockwise by 90 degrees
about its center point.
|
Bitmap |
rotateRight(Bitmap bitmap)
Returns a new bitmap based on the given bitmap but rotated clockwise by 90 degrees
about its center point.
|
Bitmap |
rotateRight(int id)
Returns a new bitmap based on the given bitmap but rotated clockwise by 90 degrees
about its center point.
|
Bitmap |
scale(Bitmap bitmap,
float scaleFactor)
Returns a new bitmap which is the given bitmap resized by the given
factor.
|
Bitmap |
scale(Bitmap bitmap,
float width,
float height)
Returns a new bitmap which is the given bitmap resized to the given size.
|
Bitmap |
scale(int id,
float scaleFactor)
Returns a new bitmap which is the given bitmap resized by the given
factor.
|
Bitmap |
scale(int id,
float width,
float height)
Returns the bitmap that corresponds to the given resource ID.
|
Bitmap |
scaleToFit(Bitmap bitmap,
Canvas canvas)
Returns a new bitmap which is the given bitmap resized to the largest size
that can fit within the given canvas's width/height while maintaining its aspect ratio.
|
Bitmap |
scaleToFit(Bitmap bitmap,
float width,
float height)
Returns a new bitmap which is the given bitmap resized to the largest size
that can fit within the given width/height while maintaining its aspect ratio.
|
Bitmap |
scaleToFit(Bitmap bitmap,
View view)
Returns a new bitmap which is the given bitmap resized to the largest size
that can fit within the given view's width/height while maintaining its aspect ratio.
|
Bitmap |
scaleToFit(int id,
Canvas canvas)
Returns a new bitmap which is the given bitmap resized to the largest size
that can fit within the given canvas's width/height while maintaining its aspect ratio.
|
Bitmap |
scaleToFit(int id,
float width,
float height)
Returns a new bitmap which is the given bitmap resized to the largest size
that can fit within the given width/height while maintaining its aspect ratio.
|
Bitmap |
scaleToFit(int id,
View view)
Returns a new bitmap which is the given bitmap resized to the largest size
that can fit within the given view's width/height while maintaining its aspect ratio.
|
Bitmap |
scaleToHeight(Bitmap bitmap,
float height)
Returns a new bitmap which is the given bitmap resized to have
the given height, and a proportionally scaled width to match.
|
Bitmap |
scaleToHeight(int id,
float height)
Returns the bitmap that corresponds to the given resource ID.
|
Bitmap |
scaleToWidth(Bitmap bitmap,
float width)
Returns a new bitmap which is the given bitmap resized to have
the given width, and a proportionally scaled height to match.
|
Bitmap |
scaleToWidth(int id,
float width)
Returns the bitmap that corresponds to the given resource ID.
|
SimpleBitmap |
setFiltered(boolean filter)
Whether we filter bitmaps on scale/rotate for smoothness.
|
static SimpleBitmap |
with(Context context)
Returns a singleton SimpleBitmap instance bound to the given context.
|
static SimpleBitmap |
with(View context)
Returns a singleton SimpleBitmap instance bound to the given view's context.
|
public static SimpleBitmap with(Context context)
public static SimpleBitmap with(View context)
public Bitmap get(@DrawableRes int id)
NullPointerException
- if the image is missing or cannot be loaded.public Bitmap get(String url)
IORuntimeException
- if the URL cannot be read or is not a valid image.NullPointerException
- if the image is missing or cannot be loaded.public Bitmap get(URL url)
IORuntimeException
- if the URL cannot be read or is not a valid image.NullPointerException
- if the image is missing or cannot be loaded.public Bitmap get(@DrawableRes int id, float width, float height)
NullPointerException
- if the image is missing or cannot be loaded.public ArrayList<Bitmap> getAll(@DrawableRes int... ids)
NullPointerException
- if any image is missing or cannot be loaded.public ArrayList<Bitmap> getAllScaled(float scaleFactor, @DrawableRes int... ids)
NullPointerException
- if any image is missing or cannot be loaded.public ArrayList<Bitmap> getAllScaled(float width, float height, @DrawableRes int... ids)
NullPointerException
- if any image is missing or cannot be loaded.public boolean isFiltered()
public Bitmap rotate(Bitmap bitmap, float degrees)
public Bitmap rotate(@DrawableRes int id, float degrees)
public Bitmap rotate(Bitmap bitmap, float degrees, float rx, float ry)
public Bitmap rotate(@DrawableRes int id, float degrees, float rx, float ry)
public Bitmap rotateLeft(Bitmap bitmap)
public Bitmap rotateLeft(@DrawableRes int id)
public Bitmap rotateRight(Bitmap bitmap)
public Bitmap rotateRight(@DrawableRes int id)
public Bitmap scale(Bitmap bitmap, float width, float height)
NullPointerException
- if the image is missing or cannot be scaled.public Bitmap scale(@DrawableRes int id, float width, float height)
public Bitmap scale(Bitmap bitmap, float scaleFactor)
public Bitmap scale(@DrawableRes int id, float scaleFactor)
public Bitmap scaleToFit(Bitmap bitmap, float width, float height)
public Bitmap scaleToFit(@DrawableRes int id, float width, float height)
public Bitmap scaleToFit(Bitmap bitmap, View view)
public Bitmap scaleToFit(@DrawableRes int id, View view)
public Bitmap scaleToFit(Bitmap bitmap, Canvas canvas)
public Bitmap scaleToFit(@DrawableRes int id, Canvas canvas)
public Bitmap scaleToHeight(Bitmap bitmap, float height)
public Bitmap scaleToHeight(@DrawableRes int id, float height)
public Bitmap scaleToWidth(Bitmap bitmap, float width)
public Bitmap scaleToWidth(@DrawableRes int id, float width)
public SimpleBitmap setFiltered(boolean filter)