Package org.robolectric.shadows
Class ShadowBitmap
java.lang.Object
org.robolectric.shadows.ShadowBitmap
@Implements(android.graphics.Bitmap.class) public class ShadowBitmap extends Object
-
Constructor Summary
Constructors Constructor Description ShadowBitmap()
-
Method Summary
Modifier and Type Method Description void
appendDescription(String s)
protected boolean
compress(Bitmap.CompressFormat format, int quality, OutputStream stream)
protected Bitmap
copy(Bitmap.Config config, boolean isMutable)
protected void
copyPixelsFromBuffer(Buffer dst)
protected void
copyPixelsToBuffer(Buffer dst)
protected Bitmap
createAshmemBitmap()
protected static Bitmap
createBitmap(int[] colors, int offset, int stride, int width, int height, Bitmap.Config config)
protected static Bitmap
createBitmap(int width, int height, Bitmap.Config config)
protected static Bitmap
createBitmap(Bitmap src, int x, int y, int width, int height, Matrix matrix, boolean filter)
protected static Bitmap
createBitmap(DisplayMetrics displayMetrics, int[] colors, int offset, int stride, int width, int height, Bitmap.Config config)
protected static Bitmap
createBitmap(DisplayMetrics displayMetrics, int width, int height, Bitmap.Config config)
protected static Bitmap
createBitmap(DisplayMetrics displayMetrics, int width, int height, Bitmap.Config config, boolean hasAlpha)
protected static Bitmap
createScaledBitmap(Bitmap src, int dstWidth, int dstHeight, boolean filter)
protected void
eraseColor(int color)
protected Bitmap
extractAlpha()
protected Bitmap
extractAlpha(Paint paint, int[] offsetXY)
This shadow implementation ignores the given paint and offsetXY and simply callsextractAlpha()
.protected int
getAllocationByteCount()
protected int
getByteCount()
static int
getBytesPerPixel(Bitmap.Config config)
protected Bitmap.Config
getConfig()
Bitmap
getCreatedFromBitmap()
Reference to original Bitmap from which this Bitmap was created.byte[]
getCreatedFromBytes()
Bytes from which this Bitmap was created.int[]
getCreatedFromColors()
Color array from which this Bitmap was created.boolean
getCreatedFromFilter()
true
if this Bitmap was created with filtering.int
getCreatedFromHeight()
Height fromgetCreatedFromX()
withingetCreatedFromBitmap()
of this Bitmap's content, or -1.Matrix
getCreatedFromMatrix()
Matrix from which this Bitmap's content was transformed, ornull
.String
getCreatedFromPath()
Path from which this Bitmap was created.int
getCreatedFromResId()
Resource ID from which this Bitmap was created.InputStream
getCreatedFromStream()
InputStream
from which this Bitmap was created.int
getCreatedFromWidth()
Width fromgetCreatedFromX()
withingetCreatedFromBitmap()
of this Bitmap's content, or -1.int
getCreatedFromX()
Horizontal offset withingetCreatedFromBitmap()
of this Bitmap's content, or -1.int
getCreatedFromY()
Vertical offset withingetCreatedFromBitmap()
of this Bitmap's content, or -1.String
getDescription()
protected int
getGenerationId()
protected int
getHeight()
protected int
getPixel(int x, int y)
protected void
getPixels(int[] pixels, int offset, int stride, int x, int y, int width, int height)
Note that this method will return a RuntimeException unless: -pixels
has the same length as the number of pixels of the bitmap.Bitmap
getRealBitmap()
protected int
getRowBytes()
protected int
getWidth()
protected boolean
hasAlpha()
protected boolean
hasMipMap()
protected boolean
isMutable()
protected boolean
isPremultiplied()
protected boolean
isRecycled()
protected static Bitmap
nativeCreateFromParcel(Parcel p)
protected void
reconfigure(int width, int height, Bitmap.Config config)
protected void
recycle()
protected boolean
sameAs(Bitmap other)
protected void
setConfig(Bitmap.Config config)
void
setCreatedFromResId(int resId, String description)
void
setDescription(String s)
protected void
setHasAlpha(boolean hasAlpha)
protected void
setHasMipMap(boolean hasMipMap)
protected void
setHeight(int height)
void
setMutable(boolean mutable)
protected void
setPixel(int x, int y, int color)
protected void
setPixels(int[] pixels, int offset, int stride, int x, int y, int width, int height)
protected void
setPremultiplied(boolean isPremultiplied)
protected void
setWidth(int width)
static String
visualize(Bitmap bitmap)
Returns a textual representation of the appearance of the object.protected void
writeToParcel(Parcel p, int flags)
-
Constructor Details
-
ShadowBitmap
public ShadowBitmap()
-
-
Method Details
-
visualize
Returns a textual representation of the appearance of the object.- Parameters:
bitmap
- the bitmap to visualize- Returns:
- Textual representation of the appearance of the object.
-
getCreatedFromBitmap
Reference to original Bitmap from which this Bitmap was created.null
if this Bitmap was not copied from another instance.- Returns:
- Original Bitmap from which this Bitmap was created.
-
getCreatedFromResId
public int getCreatedFromResId()Resource ID from which this Bitmap was created.0
if this Bitmap was not created from a resource.- Returns:
- Resource ID from which this Bitmap was created.
-
getCreatedFromPath
Path from which this Bitmap was created.null
if this Bitmap was not create from a path.- Returns:
- Path from which this Bitmap was created.
-
getCreatedFromStream
InputStream
from which this Bitmap was created.null
if this Bitmap was not created from a stream.- Returns:
- InputStream from which this Bitmap was created.
-
getCreatedFromBytes
public byte[] getCreatedFromBytes()Bytes from which this Bitmap was created.null
if this Bitmap was not created from bytes.- Returns:
- Bytes from which this Bitmap was created.
-
getCreatedFromX
public int getCreatedFromX()Horizontal offset withingetCreatedFromBitmap()
of this Bitmap's content, or -1.- Returns:
- Horizontal offset within
getCreatedFromBitmap()
.
-
getCreatedFromY
public int getCreatedFromY()Vertical offset withingetCreatedFromBitmap()
of this Bitmap's content, or -1.- Returns:
- Vertical offset within
getCreatedFromBitmap()
of this Bitmap's content, or -1.
-
getCreatedFromWidth
public int getCreatedFromWidth()Width fromgetCreatedFromX()
withingetCreatedFromBitmap()
of this Bitmap's content, or -1.- Returns:
- Width from
getCreatedFromX()
withingetCreatedFromBitmap()
of this Bitmap's content, or -1.
-
getCreatedFromHeight
public int getCreatedFromHeight()Height fromgetCreatedFromX()
withingetCreatedFromBitmap()
of this Bitmap's content, or -1.- Returns:
- Height from
getCreatedFromX()
withingetCreatedFromBitmap()
of this Bitmap's content, or -1.
-
getCreatedFromColors
public int[] getCreatedFromColors()Color array from which this Bitmap was created.null
if this Bitmap was not created from a color array.- Returns:
- Color array from which this Bitmap was created.
-
getCreatedFromMatrix
Matrix from which this Bitmap's content was transformed, ornull
.- Returns:
- Matrix from which this Bitmap's content was transformed, or
null
.
-
getCreatedFromFilter
public boolean getCreatedFromFilter()true
if this Bitmap was created with filtering.- Returns:
true
if this Bitmap was created with filtering.
-
compress
@Implementation protected boolean compress(Bitmap.CompressFormat format, int quality, OutputStream stream) -
createBitmap
-
createBitmap
@Implementation(minSdk=17) protected static Bitmap createBitmap(DisplayMetrics displayMetrics, int width, int height, Bitmap.Config config, boolean hasAlpha) -
createBitmap
@Implementation(minSdk=17) protected static Bitmap createBitmap(DisplayMetrics displayMetrics, int width, int height, Bitmap.Config config) -
createBitmap
@Implementation protected static Bitmap createBitmap(Bitmap src, int x, int y, int width, int height, Matrix matrix, boolean filter) -
createBitmap
@Implementation(minSdk=17) protected static Bitmap createBitmap(DisplayMetrics displayMetrics, int[] colors, int offset, int stride, int width, int height, Bitmap.Config config) -
createBitmap
@Implementation protected static Bitmap createBitmap(int[] colors, int offset, int stride, int width, int height, Bitmap.Config config) -
createScaledBitmap
@Implementation protected static Bitmap createScaledBitmap(Bitmap src, int dstWidth, int dstHeight, boolean filter) -
setPixels
@Implementation protected void setPixels(int[] pixels, int offset, int stride, int x, int y, int width, int height) -
getPixel
-
setPixel
-
getPixels
@Implementation protected void getPixels(int[] pixels, int offset, int stride, int x, int y, int width, int height)Note that this method will return a RuntimeException unless: -pixels
has the same length as the number of pixels of the bitmap. -x = 0
-y = 0
-width
andheight
height match the current bitmap's dimensions. -
getRowBytes
-
getByteCount
-
recycle
-
isRecycled
-
copy
-
getAllocationByteCount
-
getConfig
-
setConfig
-
isMutable
-
setMutable
public void setMutable(boolean mutable) -
appendDescription
-
setDescription
-
getDescription
-
hasAlpha
-
setHasAlpha
-
extractAlpha
-
extractAlpha
This shadow implementation ignores the given paint and offsetXY and simply callsextractAlpha()
. -
hasMipMap
-
setHasMipMap
-
setWidth
-
getWidth
-
setHeight
-
getHeight
-
getGenerationId
-
createAshmemBitmap
-
eraseColor
-
writeToParcel
-
nativeCreateFromParcel
-
copyPixelsFromBuffer
-
copyPixelsToBuffer
-
reconfigure
-
setPremultiplied
-
isPremultiplied
-
sameAs
-
getRealBitmap
-
getBytesPerPixel
-
setCreatedFromResId
-