Condividi tramite


Bitmap Class

Definition

[Android.Runtime.Register("android/graphics/Bitmap", DoNotGenerateAcw=true)]
public sealed class Bitmap : Java.Lang.Object, Android.OS.IParcelable, IDisposable, Java.Interop.IJavaPeerable
[<Android.Runtime.Register("android/graphics/Bitmap", DoNotGenerateAcw=true)>]
type Bitmap = class
    inherit Object
    interface IParcelable
    interface IJavaObject
    interface IDisposable
    interface IJavaPeerable
Inheritance
Bitmap
Attributes
Implements

Remarks

Android platform documentation

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Fields

DensityNone

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

Properties

AllocationByteCount

Returns the size of the allocated memory used to store this bitmap's pixels.

ByteCount

Returns the minimum number of bytes that can be used to store this bitmap's pixels.

Class

Returns the runtime class of this Object.

(Inherited from Object)
ColorSpace

Returns the color space associated with this bitmap. -or- Modifies the bitmap to have the specified ColorSpace, without affecting the underlying allocation backing the bitmap.

Creator
Density

Returns the density for this bitmap. -or- Specifies the density for this bitmap.

Gainmap

Returns the gainmap or null if the bitmap doesn't contain a gainmap -or- Sets a gainmap on this bitmap, or removes the gainmap if null

GenerationId

Returns the generation ID of this bitmap.

Handle

The handle to the underlying Android instance.

(Inherited from Object)
HardwareBuffer
HasAlpha

Returns true if the bitmap's config supports per-pixel alpha, and if the pixels may contain non-opaque alpha values. -or- 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).

HasGainmap

Returns whether or not this Bitmap contains a Gainmap.

HasMipMap

Indicates whether the renderer responsible for drawing this bitmap should attempt to use mipmaps when this bitmap is drawn scaled down. -or- 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.

Height

Returns the bitmap's height -or- Convenience method for calling #reconfigure(int, int, Config) with the current width and config.

IsMutable

Returns true if the bitmap is marked as mutable (i.

IsPremultiplied

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

IsRecycled

Returns true if this bitmap has been recycled.

JniIdentityHashCode (Inherited from Object)
JniPeerMembers
PeerReference (Inherited from Object)
Premultiplied
Obsolete.

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

RowBytes

Return the number of bytes between rows in the bitmap's pixels.

ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

(Inherited from Object)
ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

(Inherited from Object)
Width

Returns the bitmap's width -or- Convenience method for calling #reconfigure(int, int, Config) with the current height and config.

Methods

AsShared()

Return an immutable bitmap backed by shared memory which can be efficiently passed between processes via Parcelable.

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
Compress(Bitmap+CompressFormat, Int32, Stream)

Write a compressed version of the bitmap to the specified outputstream.

CompressAsync(Bitmap+CompressFormat, Int32, Stream)
Copy(Bitmap+Config, Boolean)

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.

CopyPixelsFromBuffer(Buffer)

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

CopyPixelsFromBufferAsync(Buffer)
CopyPixelsToBuffer(Buffer)

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

CopyPixelsToBufferAsync(Buffer)
CreateBitmap(Bitmap, Int32, Int32, Int32, Int32, Matrix, Boolean)

Returns a bitmap from subset of the source bitmap, transformed by the optional matrix.

CreateBitmap(Bitmap, Int32, Int32, Int32, Int32)

Returns a bitmap from the specified subset of the source bitmap.

CreateBitmap(Bitmap)

Returns a bitmap from the source bitmap.

CreateBitmap(DisplayMetrics, Int32, Int32, Bitmap+Config, Boolean, ColorSpace)
CreateBitmap(DisplayMetrics, Int32, Int32, Bitmap+Config, Boolean)
CreateBitmap(DisplayMetrics, Int32, Int32, Bitmap+Config)

Returns a mutable bitmap with the specified width and height.

CreateBitmap(DisplayMetrics, Int32[], Int32, Int32, Bitmap+Config)

Returns a immutable bitmap with the specified width and height, with each pixel value set to the corresponding value in the colors array.

CreateBitmap(DisplayMetrics, Int32[], Int32, Int32, Int32, Int32, Bitmap+Config)

Returns a immutable bitmap with the specified width and height, with each pixel value set to the corresponding value in the colors array.

CreateBitmap(Int32, Int32, Bitmap+Config, Boolean, ColorSpace)
CreateBitmap(Int32, Int32, Bitmap+Config, Boolean)
CreateBitmap(Int32, Int32, Bitmap+Config)

Returns a mutable bitmap with the specified width and height.

CreateBitmap(Int32[], Int32, Int32, Bitmap+Config)

Returns a immutable bitmap with the specified width and height, with each pixel value set to the corresponding value in the colors array.

CreateBitmap(Int32[], Int32, Int32, Int32, Int32, Bitmap+Config)

Returns a immutable bitmap with the specified width and height, with each pixel value set to the corresponding value in the colors array.

CreateBitmap(Picture, Int32, Int32, Bitmap+Config)
CreateBitmap(Picture)

Creates a Bitmap from the given Picture source of recorded drawing commands.

CreateScaledBitmap(Bitmap, Int32, Int32, Boolean)

Creates a new bitmap, scaled from an existing bitmap, when possible.

DescribeContents()

No special parcel contents.

Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
EraseColor(Int32)

Fills the bitmap's pixels with the specified Color.

EraseColor(Int64)

Fills the bitmap's pixels with the specified ColorLong.

ExtractAlpha()

Returns a new bitmap that captures the alpha values of the original.

ExtractAlpha(Paint, Int32[])

Returns a new bitmap that captures the alpha values of the original.

GetBitmapInfo()
GetColor(Int32, Int32)

Returns the Color at the specified location.

GetConfig()

If the bitmap's internal config is in one of the public formats, return that config, otherwise return null.

GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
GetNinePatchChunk()

Returns an optional array of private data, used by the UI system for some bitmaps.

GetPixel(Int32, Int32)

Returns the Color at the specified location.

GetPixels(Int32[], Int32, Int32, Int32, Int32, Int32, Int32)

Returns in pixels[] a copy of the data in the bitmap.

GetScaledHeight(Canvas)

Convenience for calling #getScaledHeight(int) with the target density of the given Canvas.

GetScaledHeight(DisplayMetrics)

Convenience for calling #getScaledHeight(int) with the target density of the given DisplayMetrics.

GetScaledHeight(Int32)

Convenience method that returns the height of this bitmap divided by the density scale factor.

GetScaledWidth(Canvas)

Convenience for calling #getScaledWidth(int) with the target density of the given Canvas.

GetScaledWidth(DisplayMetrics)

Convenience for calling #getScaledWidth(int) with the target density of the given DisplayMetrics.

GetScaledWidth(Int32)

Convenience method that returns the width of this bitmap divided by the density scale factor.

JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
LockPixels()
Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
PrepareToDraw()

Builds caches associated with the bitmap that are used for drawing it.

Reconfigure(Int32, Int32, Bitmap+Config)
Recycle()

Free the native object associated with this bitmap, and clear the reference to the pixel data.

SameAs(Bitmap)

Given another bitmap, return true if it has the same dimensions, config, and pixel data as this bitmap.

SetConfig(Bitmap+Config)

Convenience method for calling #reconfigure(int, int, Config) with the current height and width.

SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
SetPixel(Int32, Int32, Color)

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

SetPixels(Int32[], Int32, Int32, Int32, Int32, Int32, Int32)

Replace pixels in the bitmap with the colors in the array.

SetPremultiplied(Boolean)

Sets whether the bitmap should treat its data as pre-multiplied.

ToArray<T>() (Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
UnlockPixels()
UnregisterFromRuntime() (Inherited from Object)
Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
WrapHardwareBuffer(HardwareBuffer, ColorSpace)

Create a hardware bitmap backed by a HardwareBuffer.

WriteToParcel(Parcel, ParcelableWriteFlags)

Write the bitmap and its pixels to the parcel.

Explicit Interface Implementations

IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Applies to