Java android.graphics Bitmap fields, constructors, methods, implement or subclass

Example usage for Java android.graphics Bitmap fields, constructors, methods, implement or subclass

Introduction

In this page you can find the methods, fields and constructors for android.graphics Bitmap.

The text is from its open source code.

Field

intDENSITY_NONE
Indicates that the bitmap was created for an unknown pixel density.
Parcelable.CreatorCREATOR

Method

booleancompress(CompressFormat format, int quality, OutputStream stream)
Write a compressed version of the bitmap to the specified outputstream.
Bitmapcopy(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.
voidcopyPixelsFromBuffer(Buffer src)

Copy the pixels from the buffer, beginning at the current position, overwriting the bitmap's pixels.

voidcopyPixelsToBuffer(Buffer dst)

Copy the bitmap's pixels into the specified buffer (allocated by the caller).

BitmapcreateBitmap(@NonNull Bitmap source, int x, int y, int width, int height)
Returns an immutable bitmap from the specified subset of the source bitmap.
BitmapcreateBitmap(int width, int height, @NonNull Config config, boolean hasAlpha, @NonNull ColorSpace colorSpace)
Returns a mutable bitmap with the specified width and height.
BitmapcreateBitmap(@Nullable DisplayMetrics display, int width, int height, @NonNull Config config, boolean hasAlpha)
Returns a mutable bitmap with the specified width and height.
BitmapcreateBitmap(@Nullable DisplayMetrics display, @NonNull @ColorInt int colors[], int width, int height, @NonNull 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.
BitmapcreateBitmap(int width, int height, @NonNull Config config)
Returns a mutable bitmap with the specified width and height.
BitmapcreateBitmap(@NonNull Bitmap source, int x, int y, int width, int height, @Nullable Matrix m, boolean filter)
Returns an immutable bitmap from subset of the source bitmap, transformed by the optional matrix.
BitmapcreateBitmap(@NonNull DisplayMetrics display, @NonNull @ColorInt int[] colors, int offset, int stride, int width, int height, @NonNull 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.
BitmapcreateBitmap(@NonNull Bitmap src)
Returns an immutable bitmap from the source bitmap.
BitmapcreateBitmap(@NonNull Picture source)
Creates a Bitmap from the given Picture source of recorded drawing commands.
BitmapcreateBitmap(@Nullable DisplayMetrics display, int width, int height, @NonNull Config config)
Returns a mutable bitmap with the specified width and height.
BitmapcreateBitmap(int width, int height, @NonNull Config config, boolean hasAlpha)
Returns a mutable bitmap with the specified width and height.
BitmapcreateBitmap(@NonNull @ColorInt int[] colors, int width, int height, 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.
BitmapcreateBitmap(@NonNull Picture source, int width, int height, @NonNull Config config)
Creates a Bitmap from the given Picture source of recorded drawing commands.
BitmapcreateScaledBitmap(@NonNull Bitmap src, int dstWidth, int dstHeight, boolean filter)
Creates a new bitmap, scaled from an existing bitmap, when possible.
booleanequals(Object obj)
Indicates whether some other object is "equal to" this one.
voideraseColor(@ColorInt int c)
Fills the bitmap's pixels with the specified Color .
BitmapextractAlpha()
Returns a new bitmap that captures the alpha values of the original.
BitmapextractAlpha(Paint paint, int[] offsetXY)
Returns a new bitmap that captures the alpha values of the original.
intgetAllocationByteCount()
Returns the size of the allocated memory used to store this bitmap's pixels.
intgetByteCount()
Returns the minimum number of bytes that can be used to store this bitmap's pixels.
ConfiggetConfig()
If the bitmap's internal config is in one of the public formats, return that config, otherwise return null.
intgetDensity()

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 android.util.DisplayMetrics#DENSITY_DEFAULT .

intgetGenerationId()
Returns the generation ID of this bitmap.
intgetHeight()
Returns the bitmap's height
byte[]getNinePatchChunk()
Returns an optional array of private data, used by the UI system for some bitmaps.
intgetPixel(int x, int y)
Returns the Color at the specified location.
voidgetPixels(@ColorInt 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.
intgetRowBytes()
Return the number of bytes between rows in the bitmap's pixels.
intgetScaledHeight(Canvas canvas)
Convenience for calling #getScaledHeight(int) with the target density of the given Canvas .
intgetScaledHeight(DisplayMetrics metrics)
Convenience for calling #getScaledHeight(int) with the target density of the given DisplayMetrics .
intgetScaledHeight(int targetDensity)
Convenience method that returns the height of this bitmap divided by the density scale factor.
intgetScaledWidth(Canvas canvas)
Convenience for calling #getScaledWidth(int) with the target density of the given Canvas .
intgetScaledWidth(DisplayMetrics metrics)
Convenience for calling #getScaledWidth(int) with the target density of the given DisplayMetrics .
intgetScaledWidth(int targetDensity)
Convenience method that returns the width of this bitmap divided by the density scale factor.
intgetWidth()
Returns the bitmap's width
booleanhasAlpha()
Returns true if the bitmap's config supports per-pixel alpha, and if the pixels may contain non-opaque alpha values.
inthashCode()
Returns a hash code value for the object.
booleanisMutable()
Returns true if the bitmap is marked as mutable (i.e. can be drawn into)
booleanisPremultiplied()

Indicates whether pixels stored in this bitmaps are stored pre-multiplied.

booleanisRecycled()
Returns true if this bitmap has been recycled.
voidprepareToDraw()
Builds caches associated with the bitmap that are used for drawing it.
voidreconfigure(int width, int height, Config config)

Modifies the bitmap to have a specified width, height, and Config , without affecting the underlying allocation backing the bitmap.

voidrecycle()
Free the native object associated with this bitmap, and clear the reference to the pixel data.
booleansameAs(Bitmap other)
Given another bitmap, return true if it has the same dimensions, config, and pixel data as this bitmap.
voidsetDensity(int density)

Specifies the density for this bitmap.

voidsetHasAlpha(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).
voidsetHasMipMap(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.
voidsetPixel(int x, int y, @ColorInt int color)

Write the specified Color into the bitmap (assuming it is mutable) at the x,y coordinate.

voidsetPixels(@ColorInt 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.

voidsetPremultiplied(boolean premultiplied)
Sets whether the bitmap should treat its data as pre-multiplied.
StringtoString()
Returns a string representation of the object.