|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectandroid.graphics.Bitmap
public final class Bitmap
| Nested Class Summary | |
|---|---|
static class |
Bitmap.CompressFormat
Specifies the known formats a bitmap can be compressed into |
static class |
Bitmap.Config
|
| Nested classes/interfaces inherited from interface android.os.Parcelable |
|---|
Parcelable.Creator<T> |
| Field Summary | |
|---|---|
static Parcelable.Creator<Bitmap> |
CREATOR
|
| Fields inherited from interface android.os.Parcelable |
|---|
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE |
| Method Summary | |
|---|---|
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 |
copyPixelsToBuffer(Buffer dst)
Copy the bitmap's pixels into the specified buffer (allocated by the caller). |
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(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)
|
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. |
protected void |
finalize()
Called by the virtual machine when there are no longer any (non-weak) references to the receiver. |
Bitmap.Config |
getConfig()
If the bitmap's internal config is in one of the public formats, return that config, otherwise return null. |
int |
getHeight()
Returns the bitmap's height |
byte[] |
getNinePatchChunk()
Returns an optional array of private data, used by the UI system for some bitmaps. |
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 |
getWidth()
Returns the bitmap's width |
boolean |
hasAlpha()
Returns true if the bitmap's pixels support levels of alpha |
boolean |
isMutable()
Returns true if the bitmap is marked as mutable (i.e. |
boolean |
isRecycled()
Returns true if this bitmap has been recycled. |
(package private) int |
ni()
|
void |
recycle()
Free up the memory associated with this bitmap's pixels, and mark the bitmap as "dead", meaning it will throw an exception if getPixels() or setPixels() is called, and will draw nothing. |
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 |
writeToParcel(Parcel p,
int flags)
Write the bitmap and its pixels to the parcel. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final Parcelable.Creator<Bitmap> CREATOR
| Method Detail |
|---|
public void recycle()
public final boolean isRecycled()
public void copyPixelsToBuffer(Buffer dst)
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 static Bitmap createScaledBitmap(Bitmap src,
int dstWidth,
int dstHeight,
boolean filter)
public 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 rows
public 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 - Option 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.
public static Bitmap createBitmap(int width,
int height,
Bitmap.Config config)
width - The width of the bitmapheight - The height of the bitmapconfig - The bitmap config to create.
IllegalArgumentException - if the width or height are <= 0
public static Bitmap createBitmap(int[] colors,
int offset,
int stride,
int width,
int height,
Bitmap.Config config)
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)
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 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 int getWidth()
public final int getHeight()
public final int getRowBytes()
public final Bitmap.Config getConfig()
public final boolean hasAlpha()
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).
x - The x coordinate (0...width-1) of the pixel to returny - The y coordinate (0...height-1) of the pixel to return
Color at the specified coordinate
IllegalArgumentException - if x, y exceed the bitmap's bounds
public 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.
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 read
IllegalArgumentException - 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)
Color into the bitmap (assuming it is
mutable) at the x,y coordinate.
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 Color to write into the bitmap
IllegalStateException - if the bitmap is not mutable
IllegalArgumentException - 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)
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 bitmap
IllegalStateException - if the bitmap is not mutable
IllegalArgumentException - 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
public void writeToParcel(Parcel p,
int flags)
writeToParcel in interface Parcelablep - 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)
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.
protected void finalize()
throws Throwable
ObjectNote: The virtual machine assumes that the implementation in class Object is empty.
finalize in class ObjectThrowable - The virtual machine ignores any exceptions which are
thrown during finalization.final int ni()
|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||