public final class Bitmap extends Object implements Parcelable
Modifier and Type | Class and Description |
---|---|
static class |
Bitmap.CompressFormat
Specifies the known formats a bitmap can be compressed into
|
static class |
Bitmap.Config
Possible bitmap configurations.
|
Parcelable.ClassLoaderCreator<T>, Parcelable.Creator<T>
Modifier and Type | Field and Description |
---|---|
static Parcelable.Creator<Bitmap> |
CREATOR |
static int |
DENSITY_NONE
Indicates that the bitmap was created for an unknown pixel density.
|
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_ELIDE_DUPLICATES, PARCELABLE_WRITE_RETURN_VALUE
Modifier and Type | Method and Description |
---|---|
boolean |
compress(Bitmap.CompressFormat format,
int quality,
OutputStream stream)
Write a compressed version of the bitmap to the specified outputstream.
|
Bitmap |
copy(Bitmap.Config config,
boolean isMutable)
Tries to make a new bitmap based on the dimensions of this bitmap,
setting the new bitmap's config to the one specified, and then copying
this bitmap's pixels into the new bitmap.
|
void |
copyPixelsFromBuffer(Buffer src)
Copy the pixels from the buffer, beginning at the current position,
overwriting the bitmap's pixels.
|
void |
copyPixelsToBuffer(Buffer dst)
Copy the bitmap's pixels into the specified buffer (allocated by the
caller).
|
Bitmap |
createAshmemBitmap()
Creates a new immutable bitmap backed by ashmem which can efficiently
be passed between processes.
|
Bitmap |
createAshmemBitmap(Bitmap.Config config)
Creates a new immutable bitmap backed by ashmem which can efficiently
be passed between processes.
|
static Bitmap |
createBitmap(Bitmap src)
Returns an immutable bitmap from the source bitmap.
|
static Bitmap |
createBitmap(Bitmap source,
int x,
int y,
int width,
int height)
Returns an immutable bitmap from the specified subset of the source
bitmap.
|
static Bitmap |
createBitmap(Bitmap source,
int x,
int y,
int width,
int height,
Matrix m,
boolean filter)
Returns an immutable bitmap from subset of the source bitmap,
transformed by the optional matrix.
|
static Bitmap |
createBitmap(DisplayMetrics display,
int[] colors,
int width,
int height,
Bitmap.Config config)
Returns a immutable bitmap with the specified width and height, with each
pixel value set to the corresponding value in the colors array.
|
static Bitmap |
createBitmap(DisplayMetrics display,
int[] colors,
int offset,
int stride,
int width,
int height,
Bitmap.Config config)
Returns a immutable bitmap with the specified width and height, with each
pixel value set to the corresponding value in the colors array.
|
static Bitmap |
createBitmap(DisplayMetrics display,
int width,
int height,
Bitmap.Config config)
Returns a mutable bitmap with the specified width and height.
|
static Bitmap |
createBitmap(int[] colors,
int width,
int height,
Bitmap.Config config)
Returns a immutable bitmap with the specified width and height, with each
pixel value set to the corresponding value in the colors array.
|
static Bitmap |
createBitmap(int[] colors,
int offset,
int stride,
int width,
int height,
Bitmap.Config config)
Returns a immutable bitmap with the specified width and height, with each
pixel value set to the corresponding value in the colors array.
|
static Bitmap |
createBitmap(int width,
int height,
Bitmap.Config config)
Returns a mutable bitmap with the specified width and height.
|
static Bitmap |
createScaledBitmap(Bitmap src,
int dstWidth,
int dstHeight,
boolean filter)
Creates a new bitmap, scaled from an existing bitmap, when possible.
|
int |
describeContents()
No special parcel contents.
|
void |
eraseColor(int c)
Fills the bitmap's pixels with the specified
Color . |
Bitmap |
extractAlpha()
Returns a new bitmap that captures the alpha values of the original.
|
Bitmap |
extractAlpha(Paint paint,
int[] offsetXY)
Returns a new bitmap that captures the alpha values of the original.
|
int |
getAllocationByteCount()
Returns the size of the allocated memory used to store this bitmap's pixels.
|
int |
getByteCount()
Returns the minimum number of bytes that can be used to store this bitmap's pixels.
|
Bitmap.Config |
getConfig()
If the bitmap's internal config is in one of the public formats, return
that config, otherwise return null.
|
int |
getDensity()
Returns the density for this bitmap.
|
int |
getGenerationId()
Returns the generation ID of this bitmap.
|
int |
getHeight()
Returns the bitmap's height
|
byte[] |
getNinePatchChunk()
Returns an optional array of private data, used by the UI system for
some bitmaps.
|
NinePatch.InsetStruct |
getNinePatchInsets() |
void |
getOpticalInsets(Rect outInsets)
Populates a rectangle with the bitmap's optical insets.
|
int |
getPixel(int x,
int y)
Returns the
Color at the specified location. |
void |
getPixels(int[] pixels,
int offset,
int stride,
int x,
int y,
int width,
int height)
Returns in pixels[] a copy of the data in the bitmap.
|
int |
getRowBytes()
Return the number of bytes between rows in the bitmap's pixels.
|
int |
getScaledHeight(Canvas canvas)
Convenience for calling
getScaledHeight(int) with the target
density of the given Canvas . |
int |
getScaledHeight(DisplayMetrics metrics)
Convenience for calling
getScaledHeight(int) with the target
density of the given DisplayMetrics . |
int |
getScaledHeight(int targetDensity)
Convenience method that returns the height of this bitmap divided
by the density scale factor.
|
int |
getScaledWidth(Canvas canvas)
Convenience for calling
getScaledWidth(int) with the target
density of the given Canvas . |
int |
getScaledWidth(DisplayMetrics metrics)
Convenience for calling
getScaledWidth(int) with the target
density of the given DisplayMetrics . |
int |
getScaledWidth(int targetDensity)
Convenience method that returns the width of this bitmap divided
by the density scale factor.
|
int |
getWidth()
Returns the bitmap's width
|
boolean |
hasAlpha()
Returns true if the bitmap's config supports per-pixel alpha, and
if the pixels may contain non-opaque alpha values.
|
boolean |
hasMipMap()
Indicates whether the renderer responsible for drawing this
bitmap should attempt to use mipmaps when this bitmap is drawn
scaled down.
|
boolean |
isMutable()
Returns true if the bitmap is marked as mutable (i.e.
|
boolean |
isPremultiplied()
Indicates whether pixels stored in this bitmaps are stored pre-multiplied.
|
boolean |
isRecycled()
Returns true if this bitmap has been recycled.
|
void |
prepareToDraw()
Rebuilds any caches associated with the bitmap that are used for
drawing it.
|
void |
reconfigure(int width,
int height,
Bitmap.Config config)
Modifies the bitmap to have a specified width, height, and
Bitmap.Config , without affecting the underlying allocation backing the bitmap. |
void |
recycle()
Free the native object associated with this bitmap, and clear the
reference to the pixel data.
|
long |
refSkPixelRef()
Refs the underlying SkPixelRef and returns a pointer to it.
|
boolean |
sameAs(Bitmap other)
Given another bitmap, return true if it has the same dimensions, config,
and pixel data as this bitmap.
|
static int |
scaleFromDensity(int size,
int sdensity,
int tdensity) |
void |
setConfig(Bitmap.Config config)
Convenience method for calling
reconfigure(int, int, Config)
with the current height and width. |
static void |
setDefaultDensity(int density)
For backwards compatibility, allows the app layer to change the default
density when running old apps.
|
void |
setDensity(int density)
Specifies the density for this bitmap.
|
void |
setHasAlpha(boolean hasAlpha)
Tell the bitmap if all of the pixels are known to be opaque (false)
or if some of the pixels may contain non-opaque alpha values (true).
|
void |
setHasMipMap(boolean hasMipMap)
Set a hint for the renderer responsible for drawing this bitmap
indicating that it should attempt to use mipmaps when this bitmap
is drawn scaled down.
|
void |
setHeight(int height)
Convenience method for calling
reconfigure(int, int, Config)
with the current width and config. |
void |
setNinePatchChunk(byte[] chunk)
Sets the nine patch chunk.
|
void |
setPixel(int x,
int y,
int color)
Write the specified
Color into the bitmap (assuming it is
mutable) at the x,y coordinate. |
void |
setPixels(int[] pixels,
int offset,
int stride,
int x,
int y,
int width,
int height)
Replace pixels in the bitmap with the colors in the array.
|
void |
setPremultiplied(boolean premultiplied)
Sets whether the bitmap should treat its data as pre-multiplied.
|
void |
setWidth(int width)
Convenience method for calling
reconfigure(int, int, Config)
with the current height and config. |
void |
writeToParcel(Parcel p,
int flags)
Write the bitmap and its pixels to the parcel.
|
public static final int DENSITY_NONE
getDensity()
,
setDensity(int)
,
Constant Field Valuespublic static final Parcelable.Creator<Bitmap> CREATOR
public static void setDefaultDensity(int density)
public int getDensity()
Returns the density for this bitmap.
The default density is the same density as the current display,
unless the current application does not support different screen
densities in which case it is
DisplayMetrics.DENSITY_DEFAULT
. Note that
compatibility mode is determined by the application that was initially
loaded into a process -- applications that share the same process should
all have the same compatibility, or ensure they explicitly set the
density of their bitmaps appropriately.
DENSITY_NONE
if the scaling factor is unknown.setDensity(int)
,
DisplayMetrics.DENSITY_DEFAULT
,
DisplayMetrics.densityDpi
,
DENSITY_NONE
public void setDensity(int density)
Specifies the density for this bitmap. When the bitmap is drawn to a Canvas that also has a density, it will be scaled appropriately.
density
- The density scaling factor to use with this bitmap or
DENSITY_NONE
if the density is unknown.getDensity()
,
DisplayMetrics.DENSITY_DEFAULT
,
DisplayMetrics.densityDpi
,
DENSITY_NONE
public void reconfigure(int width, int height, Bitmap.Config config)
Modifies the bitmap to have a specified width, height, and Bitmap.Config
, without affecting the underlying allocation backing the bitmap.
Bitmap pixel data is not re-initialized for the new configuration.
This method can be used to avoid allocating a new bitmap, instead reusing an existing bitmap's allocation for a new configuration of equal or lesser size. If the Bitmap's allocation isn't large enough to support the new configuration, an IllegalArgumentException will be thrown and the bitmap will not be modified.
The result of getByteCount()
will reflect the new configuration,
while getAllocationByteCount()
will reflect that of the initial
configuration.
Note: This may change this result of hasAlpha(). When converting to 565, the new bitmap will always be considered opaque. When converting from 565, the new bitmap will be considered non-opaque, and will respect the value set by setPremultiplied().
WARNING: This method should NOT be called on a bitmap currently in use by the view system, Canvas, or the AndroidBitmap NDK API. It does not make guarantees about how the underlying pixel buffer is remapped to the new config, just that the allocation is reused. Additionally, the view system does not account for bitmap properties being modifying during use, e.g. while attached to drawables.
In order to safely ensure that a Bitmap is no longer in use by the View system it is necessary to wait for a draw pass to occur after invalidate()'ing any view that had previously drawn the Bitmap in the last draw pass due to hardware acceleration's caching of draw commands. As an example, here is how this can be done for an ImageView:
ImageView myImageView = ...; final Bitmap myBitmap = ...; myImageView.setImageDrawable(null); myImageView.post(new Runnable() { public void run() { // myBitmap is now no longer in use by the ImageView // and can be safely reconfigured. myBitmap.reconfigure(...); } });
setWidth(int)
,
setHeight(int)
,
setConfig(Config)
public void setWidth(int width)
Convenience method for calling reconfigure(int, int, Config)
with the current height and config.
WARNING: this method should not be used on bitmaps currently used by
the view system, see reconfigure(int, int, Config)
for more
details.
public void setHeight(int height)
Convenience method for calling reconfigure(int, int, Config)
with the current width and config.
WARNING: this method should not be used on bitmaps currently used by
the view system, see reconfigure(int, int, Config)
for more
details.
public void setConfig(Bitmap.Config config)
Convenience method for calling reconfigure(int, int, Config)
with the current height and width.
WARNING: this method should not be used on bitmaps currently used by
the view system, see reconfigure(int, int, Config)
for more
details.
reconfigure(int, int, Config)
,
setWidth(int)
,
setHeight(int)
public void setNinePatchChunk(byte[] chunk)
chunk
- The definition of the nine patchpublic void recycle()
public final boolean isRecycled()
public int getGenerationId()
public void copyPixelsToBuffer(Buffer dst)
Copy the bitmap's pixels into the specified buffer (allocated by the caller). An exception is thrown if the buffer is not large enough to hold all of the pixels (taking into account the number of bytes per pixel) or if the Buffer subclass is not one of the support types (ByteBuffer, ShortBuffer, IntBuffer).
The content of the bitmap is copied into the buffer as-is. This means
that if this bitmap stores its pixels pre-multiplied
(see isPremultiplied()
, the values in the buffer will also be
pre-multiplied.
After this method returns, the current position of the buffer is updated: the position is incremented by the number of elements written in the buffer.
public void copyPixelsFromBuffer(Buffer src)
Copy the pixels from the buffer, beginning at the current position, overwriting the bitmap's pixels. The data in the buffer is not changed in any way (unlike setPixels(), which converts from unpremultipled 32bit to whatever the bitmap's native format is.
After this method returns, the current position of the buffer is updated: the position is incremented by the number of elements read from the buffer. If you need to read the bitmap from the buffer again you must first rewind the buffer.
public Bitmap copy(Bitmap.Config config, boolean isMutable)
config
- The desired config for the resulting bitmapisMutable
- True if the resulting bitmap should be mutable (i.e.
its pixels can be modified)public Bitmap createAshmemBitmap()
public Bitmap createAshmemBitmap(Bitmap.Config config)
public static Bitmap createScaledBitmap(Bitmap src, int dstWidth, int dstHeight, boolean filter)
src
- The source bitmap.dstWidth
- The new bitmap's desired width.dstHeight
- The new bitmap's desired height.filter
- true if the source should be filtered.IllegalArgumentException
- if width is <= 0, or height is <= 0public static Bitmap createBitmap(Bitmap src)
public static Bitmap createBitmap(Bitmap source, int x, int y, int width, int height)
source
- The bitmap we are subsettingx
- The x coordinate of the first pixel in sourcey
- The y coordinate of the first pixel in sourcewidth
- The number of pixels in each rowheight
- The number of rowsIllegalArgumentException
- if the x, y, width, height values are
outside of the dimensions of the source bitmap, or width is <= 0,
or height is <= 0public static Bitmap createBitmap(Bitmap source, int x, int y, int width, int height, Matrix m, boolean filter)
source
- The bitmap we are subsettingx
- The x coordinate of the first pixel in sourcey
- The y coordinate of the first pixel in sourcewidth
- The number of pixels in each rowheight
- The number of rowsm
- Optional matrix to be applied to the pixelsfilter
- true if the source should be filtered.
Only applies if the matrix contains more than just
translation.IllegalArgumentException
- if the x, y, width, height values are
outside of the dimensions of the source bitmap, or width is <= 0,
or height is <= 0public static Bitmap createBitmap(int width, int height, Bitmap.Config config)
getDensity()
.width
- The width of the bitmapheight
- The height of the bitmapconfig
- The bitmap config to create.IllegalArgumentException
- if the width or height are <= 0public static Bitmap createBitmap(DisplayMetrics display, int width, int height, Bitmap.Config config)
DisplayMetrics
.display
- Display metrics for the display this bitmap will be
drawn on.width
- The width of the bitmapheight
- The height of the bitmapconfig
- The bitmap config to create.IllegalArgumentException
- if the width or height are <= 0public static Bitmap createBitmap(int[] colors, int offset, int stride, int width, int height, Bitmap.Config config)
getDensity()
.colors
- Array of Color
used to initialize the pixels.offset
- Number of values to skip before the first color in the
array of colors.stride
- Number of colors in the array between rows (must be >=
width or <= -width).width
- The width of the bitmapheight
- The height of the bitmapconfig
- The bitmap config to create. If the config does not
support per-pixel alpha (e.g. RGB_565), then the alpha
bytes in the colors[] will be ignored (assumed to be FF)IllegalArgumentException
- if the width or height are <= 0, or if
the color array's length is less than the number of pixels.public static Bitmap createBitmap(DisplayMetrics display, int[] colors, int offset, int stride, int width, int height, Bitmap.Config config)
DisplayMetrics
.display
- Display metrics for the display this bitmap will be
drawn on.colors
- Array of Color
used to initialize the pixels.offset
- Number of values to skip before the first color in the
array of colors.stride
- Number of colors in the array between rows (must be >=
width or <= -width).width
- The width of the bitmapheight
- The height of the bitmapconfig
- The bitmap config to create. If the config does not
support per-pixel alpha (e.g. RGB_565), then the alpha
bytes in the colors[] will be ignored (assumed to be FF)IllegalArgumentException
- if the width or height are <= 0, or if
the color array's length is less than the number of pixels.public static Bitmap createBitmap(int[] colors, int width, int height, Bitmap.Config config)
getDensity()
.colors
- Array of Color
used to initialize the pixels.
This array must be at least as large as width * height.width
- The width of the bitmapheight
- The height of the bitmapconfig
- The bitmap config to create. If the config does not
support per-pixel alpha (e.g. RGB_565), then the alpha
bytes in the colors[] will be ignored (assumed to be FF)IllegalArgumentException
- if the width or height are <= 0, or if
the color array's length is less than the number of pixels.public static Bitmap createBitmap(DisplayMetrics display, int[] colors, int width, int height, Bitmap.Config config)
DisplayMetrics
.display
- Display metrics for the display this bitmap will be
drawn on.colors
- Array of Color
used to initialize the pixels.
This array must be at least as large as width * height.width
- The width of the bitmapheight
- The height of the bitmapconfig
- The bitmap config to create. If the config does not
support per-pixel alpha (e.g. RGB_565), then the alpha
bytes in the colors[] will be ignored (assumed to be FF)IllegalArgumentException
- if the width or height are <= 0, or if
the color array's length is less than the number of pixels.public byte[] getNinePatchChunk()
public void getOpticalInsets(Rect outInsets)
outInsets
- Rect to populate with optical insetspublic NinePatch.InsetStruct getNinePatchInsets()
public boolean compress(Bitmap.CompressFormat format, int quality, OutputStream stream)
format
- The format of the compressed imagequality
- Hint to the compressor, 0-100. 0 meaning compress for
small size, 100 meaning compress for max quality. Some
formats, like PNG which is lossless, will ignore the
quality settingstream
- The outputstream to write the compressed data.public final boolean isMutable()
public final boolean isPremultiplied()
Indicates whether pixels stored in this bitmaps are stored pre-multiplied.
When a pixel is pre-multiplied, the RGB components have been multiplied by
the alpha component. For instance, if the original color is a 50%
translucent red (128, 255, 0, 0)
, the pre-multiplied form is
(128, 128, 0, 0)
.
This method always returns false if getConfig()
is
Bitmap.Config.RGB_565
.
The return value is undefined if getConfig()
is
Bitmap.Config.ALPHA_8
.
This method only returns true if hasAlpha()
returns true.
A bitmap with no alpha channel can be used both as a pre-multiplied and
as a non pre-multiplied bitmap.
Only pre-multiplied bitmaps may be drawn by the view system or
Canvas
. If a non-pre-multiplied bitmap with an alpha channel is
drawn to a Canvas, a RuntimeException will be thrown.
setPremultiplied(boolean)
,
BitmapFactory.Options.inPremultiplied
public final void setPremultiplied(boolean premultiplied)
Bitmaps are always treated as pre-multiplied by the view system and
Canvas
for performance reasons. Storing un-pre-multiplied data in
a Bitmap (through setPixel(int, int, int)
, setPixels(int[], int, int, int, int, int, int)
, or BitmapFactory.Options.inPremultiplied
)
can lead to incorrect blending if drawn by the framework.
This method will not affect the behavior of a bitmap without an alpha
channel, or if hasAlpha()
returns false.
Calling createBitmap(android.graphics.Bitmap)
or createScaledBitmap(android.graphics.Bitmap, int, int, boolean)
with a source
Bitmap whose colors are not pre-multiplied may result in a RuntimeException,
since those functions require drawing the source, which is not supported for
un-pre-multiplied Bitmaps.
public final int getWidth()
public final int getHeight()
public int getScaledWidth(Canvas canvas)
getScaledWidth(int)
with the target
density of the given Canvas
.public int getScaledHeight(Canvas canvas)
getScaledHeight(int)
with the target
density of the given Canvas
.public int getScaledWidth(DisplayMetrics metrics)
getScaledWidth(int)
with the target
density of the given DisplayMetrics
.public int getScaledHeight(DisplayMetrics metrics)
getScaledHeight(int)
with the target
density of the given DisplayMetrics
.public int getScaledWidth(int targetDensity)
targetDensity
- The density of the target canvas of the bitmap.public int getScaledHeight(int targetDensity)
targetDensity
- The density of the target canvas of the bitmap.public static int scaleFromDensity(int size, int sdensity, int tdensity)
public final int getRowBytes()
As of Build.VERSION_CODES.KITKAT
, this method
should not be used to calculate the memory usage of the bitmap. Instead,
see getAllocationByteCount()
.
public final int getByteCount()
As of Build.VERSION_CODES.KITKAT
, the result of this method can
no longer be used to determine memory usage of a bitmap. See getAllocationByteCount()
.
public final int getAllocationByteCount()
This can be larger than the result of getByteCount()
if a bitmap is reused to
decode other bitmaps of smaller size, or by manual reconfiguration. See reconfigure(int, int, Config)
, setWidth(int)
, setHeight(int)
, setConfig(Bitmap.Config)
, and BitmapFactory.Options.inBitmap
. If a bitmap is not modified in this way, this value will be
the same as that returned by getByteCount()
.
This value will not change over the lifetime of a Bitmap.
reconfigure(int, int, Config)
public final Bitmap.Config getConfig()
public final boolean hasAlpha()
public void setHasAlpha(boolean hasAlpha)
public final boolean hasMipMap()
setHasMipMap(boolean)
public final void setHasMipMap(boolean hasMipMap)
hasMipMap
- indicates whether the renderer should attempt
to use mipmapshasMipMap()
public void eraseColor(int c)
Color
.IllegalStateException
- if the bitmap is not mutable.public int getPixel(int x, int y)
Color
at the specified location. Throws an exception
if x or y are out of bounds (negative or >= to the width or height
respectively). The returned color is a non-premultiplied ARGB value.x
- The x coordinate (0...width-1) of the pixel to returny
- The y coordinate (0...height-1) of the pixel to returnColor
at the specified coordinateIllegalArgumentException
- if x, y exceed the bitmap's boundspublic void getPixels(int[] pixels, int offset, int stride, int x, int y, int width, int height)
Color
. The stride parameter allows
the caller to allow for gaps in the returned pixels array between
rows. For normal packed results, just pass width for the stride value.
The returned colors are non-premultiplied ARGB values.pixels
- The array to receive the bitmap's colorsoffset
- The first index to write into pixels[]stride
- The number of entries in pixels[] to skip between
rows (must be >= bitmap's width). Can be negative.x
- The x coordinate of the first pixel to read from
the bitmapy
- The y coordinate of the first pixel to read from
the bitmapwidth
- The number of pixels to read from each rowheight
- The number of rows to readIllegalArgumentException
- if x, y, width, height exceed the
bounds of the bitmap, or if abs(stride) < width.ArrayIndexOutOfBoundsException
- if the pixels array is too small
to receive the specified number of pixels.public void setPixel(int x, int y, int color)
Write the specified Color
into the bitmap (assuming it is
mutable) at the x,y coordinate. The color must be a
non-premultiplied ARGB value.
x
- The x coordinate of the pixel to replace (0...width-1)y
- The y coordinate of the pixel to replace (0...height-1)color
- The ARGB color to write into the bitmapIllegalStateException
- if the bitmap is not mutableIllegalArgumentException
- if x, y are outside of the bitmap's
bounds.public void setPixels(int[] pixels, int offset, int stride, int x, int y, int width, int height)
Replace pixels in the bitmap with the colors in the array. Each element
in the array is a packed int prepresenting a non-premultiplied ARGB
Color
.
pixels
- The colors to write to the bitmapoffset
- The index of the first color to read from pixels[]stride
- The number of colors in pixels[] to skip between rows.
Normally this value will be the same as the width of
the bitmap, but it can be larger (or negative).x
- The x coordinate of the first pixel to write to in
the bitmap.y
- The y coordinate of the first pixel to write to in
the bitmap.width
- The number of colors to copy from pixels[] per rowheight
- The number of rows to write to the bitmapIllegalStateException
- if the bitmap is not mutableIllegalArgumentException
- if x, y, width, height are outside of
the bitmap's bounds.ArrayIndexOutOfBoundsException
- if the pixels array is too small
to receive the specified number of pixels.public int describeContents()
describeContents
in interface Parcelable
Parcelable.CONTENTS_FILE_DESCRIPTOR
public void writeToParcel(Parcel p, int flags)
writeToParcel
in interface Parcelable
p
- Parcel object to write the bitmap data intoflags
- Additional flags about how the object should be written.
May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE
.public Bitmap extractAlpha()
public Bitmap extractAlpha(Paint paint, int[] offsetXY)
The initial density of the returned bitmap is the same as the original's.
paint
- Optional paint used to modify the alpha values in the
resulting bitmap. Pass null for default behavior.offsetXY
- Optional array that returns the X (index 0) and Y
(index 1) offset needed to position the returned bitmap
so that it visually lines up with the original.public boolean sameAs(Bitmap other)
public void prepareToDraw()
public final long refSkPixelRef()