Package org.robolectric.shadows
Class ShadowBitmap
- java.lang.Object
-
- org.robolectric.shadows.ShadowBitmap
-
@Implements(android.graphics.Bitmap.class) public class ShadowBitmap extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description ShadowBitmap()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidappendDescription(java.lang.String s)protected booleancompress(android.graphics.Bitmap.CompressFormat format, int quality, java.io.OutputStream stream)protected android.graphics.Bitmapcopy(android.graphics.Bitmap.Config config, boolean isMutable)protected voidcopyPixelsFromBuffer(java.nio.Buffer dst)protected voidcopyPixelsToBuffer(java.nio.Buffer dst)protected android.graphics.BitmapcreateAshmemBitmap()protected static android.graphics.BitmapcreateBitmap(int[] colors, int width, int height, android.graphics.Bitmap.Config config)protected static android.graphics.BitmapcreateBitmap(int width, int height, android.graphics.Bitmap.Config config)protected static android.graphics.BitmapcreateBitmap(android.graphics.Bitmap src)protected static android.graphics.BitmapcreateBitmap(android.graphics.Bitmap src, int x, int y, int width, int height)protected static android.graphics.BitmapcreateBitmap(android.graphics.Bitmap src, int x, int y, int width, int height, android.graphics.Matrix matrix, boolean filter)protected static android.graphics.BitmapcreateBitmap(android.util.DisplayMetrics displayMetrics, int width, int height, android.graphics.Bitmap.Config config)protected static android.graphics.BitmapcreateBitmap(android.util.DisplayMetrics displayMetrics, int width, int height, android.graphics.Bitmap.Config config, boolean hasAlpha)protected static android.graphics.BitmapcreateScaledBitmap(android.graphics.Bitmap src, int dstWidth, int dstHeight, boolean filter)protected voideraseColor(int color)protected android.graphics.BitmapextractAlpha()protected android.graphics.BitmapextractAlpha(android.graphics.Paint paint, int[] offsetXY)This shadow implementation ignores the given paint and offsetXY and simply callsextractAlpha().protected intgetAllocationByteCount()protected intgetByteCount()static intgetBytesPerPixel(android.graphics.Bitmap.Config config)protected android.graphics.Bitmap.ConfiggetConfig()android.graphics.BitmapgetCreatedFromBitmap()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.booleangetCreatedFromFilter()trueif this Bitmap was created with filtering.intgetCreatedFromHeight()Height fromgetCreatedFromX()withingetCreatedFromBitmap()of this Bitmap's content, or -1.android.graphics.MatrixgetCreatedFromMatrix()Matrix from which this Bitmap's content was transformed, ornull.java.lang.StringgetCreatedFromPath()Path from which this Bitmap was created.intgetCreatedFromResId()Resource ID from which this Bitmap was created.java.io.InputStreamgetCreatedFromStream()InputStreamfrom which this Bitmap was created.intgetCreatedFromWidth()Width fromgetCreatedFromX()withingetCreatedFromBitmap()of this Bitmap's content, or -1.intgetCreatedFromX()Horizontal offset withingetCreatedFromBitmap()of this Bitmap's content, or -1.intgetCreatedFromY()Vertical offset withingetCreatedFromBitmap()of this Bitmap's content, or -1.protected intgetDensity()java.lang.StringgetDescription()protected intgetGenerationId()protected intgetHeight()protected intgetPixel(int x, int y)protected voidgetPixels(int[] pixels, int offset, int stride, int x, int y, int width, int height)Note that this method will return a RuntimeException unless: -pixelshas the same length as the number of pixels of the bitmap.android.graphics.BitmapgetRealBitmap()protected intgetRowBytes()protected intgetWidth()protected booleanhasAlpha()protected booleanhasMipMap()protected booleanisMutable()protected booleanisPremultiplied()protected booleanisRecycled()protected static android.graphics.BitmapnativeCreateFromParcel(android.os.Parcel p)protected voidreconfigure(int width, int height, android.graphics.Bitmap.Config config)protected voidrecycle()protected booleansameAs(android.graphics.Bitmap other)protected voidsetConfig(android.graphics.Bitmap.Config config)voidsetCreatedFromResId(int resId, java.lang.String description)protected voidsetDensity(int density)voidsetDescription(java.lang.String s)protected voidsetHasAlpha(boolean hasAlpha)protected voidsetHasMipMap(boolean hasMipMap)protected voidsetHeight(int height)voidsetMutable(boolean mutable)protected voidsetPixel(int x, int y, int color)protected voidsetPixels(int[] pixels, int offset, int stride, int x, int y, int width, int height)protected voidsetPremultiplied(boolean isPremultiplied)protected voidsetWidth(int width)static java.lang.Stringvisualize(android.graphics.Bitmap bitmap)Returns a textual representation of the appearance of the object.protected voidwriteToParcel(android.os.Parcel p, int flags)
-
-
-
Method Detail
-
visualize
public static java.lang.String visualize(android.graphics.Bitmap bitmap)
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
public android.graphics.Bitmap getCreatedFromBitmap()
Reference to original Bitmap from which this Bitmap was created.nullif 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.0if this Bitmap was not created from a resource.- Returns:
- Resource ID from which this Bitmap was created.
-
getCreatedFromPath
public java.lang.String getCreatedFromPath()
Path from which this Bitmap was created.nullif this Bitmap was not create from a path.- Returns:
- Path from which this Bitmap was created.
-
getCreatedFromStream
public java.io.InputStream getCreatedFromStream()
InputStreamfrom which this Bitmap was created.nullif 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.nullif 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.nullif this Bitmap was not created from a color array.- Returns:
- Color array from which this Bitmap was created.
-
getCreatedFromMatrix
public android.graphics.Matrix 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()
trueif this Bitmap was created with filtering.- Returns:
trueif this Bitmap was created with filtering.
-
compress
@Implementation protected boolean compress(android.graphics.Bitmap.CompressFormat format, int quality, java.io.OutputStream stream)
-
createBitmap
@Implementation protected static android.graphics.Bitmap createBitmap(int width, int height, android.graphics.Bitmap.Config config)
-
createBitmap
@Implementation(minSdk=17) protected static android.graphics.Bitmap createBitmap(android.util.DisplayMetrics displayMetrics, int width, int height, android.graphics.Bitmap.Config config, boolean hasAlpha)
-
createBitmap
@Implementation(minSdk=17) protected static android.graphics.Bitmap createBitmap(android.util.DisplayMetrics displayMetrics, int width, int height, android.graphics.Bitmap.Config config)
-
createBitmap
@Implementation protected static android.graphics.Bitmap createBitmap(android.graphics.Bitmap src)
-
createScaledBitmap
@Implementation protected static android.graphics.Bitmap createScaledBitmap(android.graphics.Bitmap src, int dstWidth, int dstHeight, boolean filter)
-
createBitmap
@Implementation protected static android.graphics.Bitmap createBitmap(android.graphics.Bitmap src, int x, int y, int width, int height)
-
setPixels
@Implementation protected void setPixels(int[] pixels, int offset, int stride, int x, int y, int width, int height)
-
createBitmap
@Implementation protected static android.graphics.Bitmap createBitmap(android.graphics.Bitmap src, int x, int y, int width, int height, android.graphics.Matrix matrix, boolean filter)
-
createBitmap
@Implementation protected static android.graphics.Bitmap createBitmap(int[] colors, int width, int height, android.graphics.Bitmap.Config config)
-
getPixel
@Implementation protected int getPixel(int x, int y)
-
setPixel
@Implementation protected void setPixel(int x, int y, int color)
-
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: -pixelshas the same length as the number of pixels of the bitmap. -x = 0-y = 0-widthandheightheight match the current bitmap's dimensions.
-
getRowBytes
@Implementation protected int getRowBytes()
-
getByteCount
@Implementation protected int getByteCount()
-
recycle
@Implementation protected void recycle()
-
isRecycled
@Implementation protected final boolean isRecycled()
-
copy
@Implementation protected android.graphics.Bitmap copy(android.graphics.Bitmap.Config config, boolean isMutable)
-
getAllocationByteCount
@Implementation(minSdk=19) protected final int getAllocationByteCount()
-
getConfig
@Implementation protected final android.graphics.Bitmap.Config getConfig()
-
setConfig
@Implementation(minSdk=19) protected void setConfig(android.graphics.Bitmap.Config config)
-
isMutable
@Implementation protected final boolean isMutable()
-
setMutable
public void setMutable(boolean mutable)
-
appendDescription
public void appendDescription(java.lang.String s)
-
setDescription
public void setDescription(java.lang.String s)
-
getDescription
public java.lang.String getDescription()
-
hasAlpha
@Implementation protected final boolean hasAlpha()
-
setHasAlpha
@Implementation protected void setHasAlpha(boolean hasAlpha)
-
extractAlpha
@Implementation protected android.graphics.Bitmap extractAlpha()
-
extractAlpha
@Implementation protected android.graphics.Bitmap extractAlpha(android.graphics.Paint paint, int[] offsetXY)This shadow implementation ignores the given paint and offsetXY and simply callsextractAlpha().
-
hasMipMap
@Implementation(minSdk=17) protected final boolean hasMipMap()
-
setHasMipMap
@Implementation(minSdk=17) protected final void setHasMipMap(boolean hasMipMap)
-
setWidth
@Implementation(minSdk=19) protected void setWidth(int width)
-
getWidth
@Implementation protected int getWidth()
-
setHeight
@Implementation(minSdk=19) protected void setHeight(int height)
-
getHeight
@Implementation protected int getHeight()
-
setDensity
@Implementation protected void setDensity(int density)
-
getDensity
@Implementation protected int getDensity()
-
getGenerationId
@Implementation protected int getGenerationId()
-
createAshmemBitmap
@Implementation(minSdk=23) protected android.graphics.Bitmap createAshmemBitmap()
-
eraseColor
@Implementation protected void eraseColor(int color)
-
writeToParcel
@Implementation protected void writeToParcel(android.os.Parcel p, int flags)
-
nativeCreateFromParcel
@Implementation protected static android.graphics.Bitmap nativeCreateFromParcel(android.os.Parcel p)
-
copyPixelsFromBuffer
@Implementation protected void copyPixelsFromBuffer(java.nio.Buffer dst)
-
copyPixelsToBuffer
@Implementation protected void copyPixelsToBuffer(java.nio.Buffer dst)
-
reconfigure
@Implementation(minSdk=19) protected void reconfigure(int width, int height, android.graphics.Bitmap.Config config)
-
setPremultiplied
@Implementation(minSdk=19) protected void setPremultiplied(boolean isPremultiplied)
-
isPremultiplied
@Implementation(minSdk=19) protected boolean isPremultiplied()
-
sameAs
@Implementation protected boolean sameAs(android.graphics.Bitmap other)
-
getRealBitmap
public android.graphics.Bitmap getRealBitmap()
-
getBytesPerPixel
public static int getBytesPerPixel(android.graphics.Bitmap.Config config)
-
setCreatedFromResId
public void setCreatedFromResId(int resId, java.lang.String description)
-
-