|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectdanger.ui.Bitmap
public class Bitmap
Rectangular grid of pixels, in one of several different colorspaces.
Direct instances of this class may be modified, but instances of the
subclass ImmutableBitmap may not.
| Nested Class Summary | |
|---|---|
static class |
Bitmap.FromResource
Bitmaps that come from resources are instances of this subclass of Bitmap. |
| Field Summary | |
|---|---|
static int |
COPYBITS_ALPHA
Perform an alpha-blended copy, with the alpha channel specified in the high byte of the flags word. |
static int |
COPYBITS_ALPHA_MASK
Mask for extracting the alpha channel from the flags word. |
static int |
COPYBITS_CLAMP_TRANSPARENCY
Make partially transparent source pixels fully transparent in the desitnation. |
static int |
COPYBITS_FLAGS_MASK
Mask for extracting the flags bits from the flags word. |
static int |
COPYBITS_INTERPOLATED
Use bilinear interpolation for smooth scaling of copy. |
static int |
COPYBITS_INVERTED
Invert each pixel (XOR with -1) as it is copied. |
static int |
COPYBITS_SRCOVER
Copy will behave as a strided memcpy. |
static int |
COPYBITS_SRCOVER_TRANS
Like SRCOVER, but the source transparent color (if any) will be converted to the destination transparent color. |
static boolean |
DONT_PRESERVE_TRANSPARENCY
Used as a parameter to convertToScreenColorSpace. |
protected int |
mPaletteFlags
Deprecated. Use getPaletteFlags() instead. |
static int |
PALETTE_BGR16
Image contains an RGB16_BGR palette at the end of the pixel data. |
static int |
PALETTE_BGR16_ALPHA
Image contains an RGB16_BGR palette at the end of the pixel data, and an alpha palette at the end of the palette data. |
static int |
PALETTE_BGR16_OFFSET
Image contains an RGB16_BGR palette at the offset specified in the low three bytes of the palette word. |
static int |
PALETTE_FLAGS_MASK
Mask for extracting the flags bits from the palette word. |
static int |
PALETTE_NONE
Image contains no palette. |
static int |
PALETTE_RGB16_LE
Image contains an RGB16_RGB_LE palette at the end of the pixel data. |
static int |
PALETTE_RGB16_LE_ALPHA
Image contains an RGB16_RGB_LE palette at the end of the pixel data, and an alpha palette at the end of the palette data. |
static int |
PALETTE_RGB16_LE_OFFSET
Image contains an RGB16_RGB_LE palette at the offset specified in the low three bytes of the palette word. |
static int |
PALETTE_SIZE_MASK
Mask for extracting the palette size or offset from the palette word. |
static boolean |
PRESERVE_TRANSPARENCY
Used as a parameter to convertToScreenColorSpace. |
| Constructor Summary | |
|---|---|
Bitmap()
Construct an empty zero-sized instance. |
|
Bitmap(Bitmap src)
Construct an instance copied from another instance. |
|
Bitmap(Bitmap src,
int width,
int height)
Construct an instance copied from another instance. |
|
Bitmap(Bitmap src,
Rect r)
Construct an instance copied from a portion of another instance. |
|
Bitmap(byte[] pixels,
int width,
int height,
int transparentColor)
Construct a palette-less instance in the default colorspace. |
|
Bitmap(byte[] pixels,
int width,
int height,
int colorspace,
int transparentColor)
Construct a palette-less instance. |
|
Bitmap(byte[] pixels,
int width,
int height,
int colorspace,
int transparentColor,
int paletteSize)
Construct an instance. |
|
Bitmap(int width,
int height)
Construct an empty instance. |
|
| Method Summary | |
|---|---|
boolean |
canDrawInverted()
|
static Bitmap |
convertToScreenColorSpace(Bitmap bitmap)
Convert a bitmap to the native screen format. |
static Bitmap |
convertToScreenColorSpace(Bitmap bitmap,
boolean preserveTransparency)
Convert to screen color space and optionally preserve the transparent color in a colorspace independent way. |
static Bitmap |
convertToScreenColorSpace(Bitmap bitmap,
int backgroundColor)
Convert a bitmap to the native screen format. |
static Bitmap |
copy(Bitmap src)
|
static Bitmap |
copy(Bitmap src,
int width,
int height)
|
static Bitmap |
copy(Bitmap src,
Rect r)
|
static void |
copyBits(Bitmap to,
Rect toRect,
Bitmap from,
Rect fromRect)
Copy a region from one bitmap to another |
static void |
copyBits(Bitmap to,
Rect toRect,
Bitmap from,
Rect fromRect,
int flags)
|
static void |
copyBitsInterpolated(Bitmap to,
Rect toRect,
Bitmap from,
Rect fromRect)
Copy a region from one bitmap to another |
void |
copyBitsTo(Bitmap to,
Rect toRect,
Rect fromRect)
Copy the contents of fromRect in this bitmap, to toRect in the provided destination Bitmap |
void |
copyInterpolated(Bitmap src)
Copy the contents of the provided source bitmap to this bitmap, scaling them to fit using bilinear interpolation |
boolean |
copyRotated(Bitmap from,
int degrees)
|
void |
copyScaled(Bitmap src)
Copy the contents of the provided source bitmap to this bitmap, scaling them to fit |
static Bitmap |
createOptimalBitmap(Object pixels,
int width,
int height,
int colorspace,
int transparentColor,
int paletteSize)
|
Pen |
createPen()
Create a pen that draws on this instance, with location (0, 0)
corresponding to the upper-left corner of the bitmap area. |
Pen |
createPen(int dx,
int dy)
Create a pen that draws on this instance, offset by the given amount from the upper-left corner of the bitmap area. |
static void |
flatten(Bitmap src,
byte[] dst,
int dstOffset)
|
int |
getColorSpace()
|
static int |
getFlattenedSize(Bitmap src)
|
int |
getHeight()
|
protected int |
getPaletteFlags()
Return the palette flags. |
protected int |
getPaletteOffset()
|
int |
getPaletteSize()
|
byte[] |
getPixels()
return the raw pixel data array |
int |
getPoint(int x,
int y)
|
int |
getPoint(Point point)
|
int |
getStride()
|
int |
getTransparentColor()
|
int |
getTransparentColorRGB()
Get the transparent color for this bitmap in RGB components. |
int |
getWidth()
|
boolean |
isGrayscale()
Determine if this bitmap is color or black/white. |
void |
mirror()
|
static Bitmap |
newFromEncodedData(byte[] data)
|
static Bitmap |
newFromFlattenedData(byte[] data,
int offset)
|
static Bitmap |
newFromJPEGData(byte[] jpegData)
|
static Bitmap |
newFromPNGData(byte[] pngData)
|
void |
replaceColor(int color,
int newColor)
|
void |
replacePaletteColor(int color,
int newColor)
|
void |
replacePaletteColors(int[] colorPairs)
Replace the palette colors for the given color pairs. |
Bitmap |
rotateBy(int degrees)
return a bitmap rotated by 0, 90, 180, or 270 degrees. |
Bitmap |
scaleTo(int width,
int height)
Return a new bitmap, containing the contents of this bitmap, scaled to the provided size |
void |
setTo(Bitmap src)
Sets the values of this bitmap to those of a passed in bitmap |
void |
setTransparentColor(int color)
Directly set the transparent color for this bitmap. |
void |
setTransparentColorRGB(int rgb)
Set the transparent color for this bitmap from rgb components. |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int COPYBITS_INVERTED
public static final int COPYBITS_SRCOVER
public static final int COPYBITS_CLAMP_TRANSPARENCY
public static final int COPYBITS_SRCOVER_TRANS
public static final int COPYBITS_ALPHA
public static final int COPYBITS_INTERPOLATED
public static final int COPYBITS_FLAGS_MASK
public static final int COPYBITS_ALPHA_MASK
public static final int PALETTE_NONE
public static final int PALETTE_BGR16
public static final int PALETTE_BGR16_ALPHA
public static final int PALETTE_BGR16_OFFSET
public static final int PALETTE_RGB16_LE
public static final int PALETTE_RGB16_LE_ALPHA
public static final int PALETTE_RGB16_LE_OFFSET
public static final int PALETTE_FLAGS_MASK
public static final int PALETTE_SIZE_MASK
public static final boolean PRESERVE_TRANSPARENCY
public static final boolean DONT_PRESERVE_TRANSPARENCY
protected int mPaletteFlags
getPaletteFlags() instead.| Constructor Detail |
|---|
public Bitmap(byte[] pixels,
int width,
int height,
int colorspace,
int transparentColor,
int paletteSize)
pixels - null-ok; the pixels of the bitmap, or null
if the bitmap is to be initially blank; if non-null then
the pixels become shared (modifying the original array affects the
constructed instance)width - >= 0; the width of the bitmapheight - >= 0; the height of the bitmapcolorspace - the colorspace; see ColorSpacetransparentColor - what color ought to be considered "transparent"
when drawing the bitmap; use -1 if there is to be no
transparencypaletteSize - the number of colors in the palette; if >=
0, then the palette is located just past the end of the pixel
data per se in pixelspublic Bitmap()
Bitmap(null, 0, 0, Screen.getColorSpace(), -1, 0)
public Bitmap(int width,
int height)
Bitmap(null,
width, height, Screen.getColorSpace(), -1, 0)
width - >= 0; the width of the bitmapheight - >= 0; the height of the bitmap
public Bitmap(byte[] pixels,
int width,
int height,
int colorspace,
int transparentColor)
Bitmap(pixels,
width, height, colorspace, transparentColor, 0)
pixels - null-ok; the pixels of the bitmap, or null
if the bitmap is to be initially blank; if non-null then
the pixels become shared (modifying the original array affects the
constructed instance)width - >= 0; the width of the bitmapheight - >= 0; the height of the bitmapcolorspace - the colorspace; see ColorSpacetransparentColor - what color ought to be considered "transparent"
when drawing the bitmap; use -1 if there is to be no
transparencypublic Bitmap(Bitmap src)
src - non-null; the original instance
public Bitmap(Bitmap src,
int width,
int height)
src - non-null; the original instancewidth - >= 0; the width of the bitmapheight - >= 0; the height of the bitmap
public Bitmap(Bitmap src,
Rect r)
src - non-null; the original instancer - non-null; a rectangle specifying the portion of the original pixel data
public Bitmap(byte[] pixels,
int width,
int height,
int transparentColor)
Bitmap(pixels, width, height,
Screen.getColorSpace(), transparentColor, 0)
pixels - null-ok; the pixels of the bitmap, or null
if the bitmap is to be initially blank; if non-null then
the pixels become shared (modifying the original array affects the
constructed instance)width - >= 0; the width of the bitmapheight - >= 0; the height of the bitmaptransparentColor - what color ought to be considered "transparent"
when drawing the bitmap; use -1 if there is to be no
transparency| Method Detail |
|---|
public static Bitmap copy(Bitmap src)
public static Bitmap copy(Bitmap src,
int width,
int height)
public static Bitmap copy(Bitmap src,
Rect r)
public static Bitmap createOptimalBitmap(Object pixels,
int width,
int height,
int colorspace,
int transparentColor,
int paletteSize)
public static Bitmap newFromPNGData(byte[] pngData)
throws IOException
IOException
public static Bitmap newFromJPEGData(byte[] jpegData)
throws IOException
IOException
public static Bitmap newFromEncodedData(byte[] data)
throws IOException
IOException
public static Bitmap newFromFlattenedData(byte[] data,
int offset)
public static void flatten(Bitmap src,
byte[] dst,
int dstOffset)
public static int getFlattenedSize(Bitmap src)
public Pen createPen(int dx,
int dy)
dx - the x offsetdy - the y offset
public Pen createPen()
(0, 0)
corresponding to the upper-left corner of the bitmap area.
- Returns:
- non-null; the pen
public int getPoint(int x,
int y)
public int getPoint(Point point)
public int getPaletteSize()
public void setTo(Bitmap src)
public Bitmap scaleTo(int width,
int height)
public void copyScaled(Bitmap src)
public void copyInterpolated(Bitmap src)
public final void copyBitsTo(Bitmap to,
Rect toRect,
Rect fromRect)
public static void copyBits(Bitmap to,
Rect toRect,
Bitmap from,
Rect fromRect)
public static void copyBits(Bitmap to,
Rect toRect,
Bitmap from,
Rect fromRect,
int flags)
public static void copyBitsInterpolated(Bitmap to,
Rect toRect,
Bitmap from,
Rect fromRect)
public Bitmap rotateBy(int degrees)
public boolean copyRotated(Bitmap from,
int degrees)
public void mirror()
public final int getWidth()
public final int getHeight()
public final int getStride()
public final int getColorSpace()
public final int getTransparentColor()
public int getTransparentColorRGB()
public byte[] getPixels()
public void setTransparentColor(int color)
color - A colorspace dependent integer to use as the
transparent color.public void setTransparentColorRGB(int rgb)
rgb - An RGB color packed into an integer. The alpha
component is masked out and ignored.
public void replacePaletteColor(int color,
int newColor)
public void replacePaletteColors(int[] colorPairs)
public void replaceColor(int color,
int newColor)
public static Bitmap convertToScreenColorSpace(Bitmap bitmap,
int backgroundColor)
bitmap - Bitmap to be converted.backgroundColor - Color to fill destination with before copying source.
public static Bitmap convertToScreenColorSpace(Bitmap bitmap)
bitmap - Bitmap to be converted.
public static Bitmap convertToScreenColorSpace(Bitmap bitmap,
boolean preserveTransparency)
bitmap - Bitmap to be converted.preserveTransparency - True if you want the transparency to be maintained.
public boolean isGrayscale()
public boolean canDrawInverted()
public String toString()
toString in class Objectprotected int getPaletteOffset()
protected final int getPaletteFlags()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||