Share via


Canvas.DrawBitmap Method

Definition

Overloads

DrawBitmap(Int32[], Int32, Int32, Single, Single, Int32, Int32, Boolean, Paint)
Obsolete.

Treat the specified array of colors as a bitmap, and draw it.

DrawBitmap(Int32[], Int32, Int32, Int32, Int32, Int32, Int32, Boolean, Paint)
Obsolete.

Legacy version of drawBitmap(int[] colors, .

DrawBitmap(Bitmap, Single, Single, Paint)

Draw the specified bitmap, with its top/left corner at (x,y), using the specified paint, transformed by the current matrix.

DrawBitmap(Bitmap, Rect, Rect, Paint)

Draw the specified bitmap, scaling/translating automatically to fill the destination rectangle.

DrawBitmap(Bitmap, Matrix, Paint)

Draw the bitmap using the specified matrix.

DrawBitmap(Bitmap, Rect, RectF, Paint)

Draw the specified bitmap, scaling/translating automatically to fill the destination rectangle.

DrawBitmap(Int32[], Int32, Int32, Single, Single, Int32, Int32, Boolean, Paint)

Caution

deprecated

Treat the specified array of colors as a bitmap, and draw it.

[Android.Runtime.Register("drawBitmap", "([IIIFFIIZLandroid/graphics/Paint;)V", "GetDrawBitmap_arrayIIIFFIIZLandroid_graphics_Paint_Handler")]
[System.Obsolete("deprecated")]
public virtual void DrawBitmap (int[] colors, int offset, int stride, float x, float y, int width, int height, bool hasAlpha, Android.Graphics.Paint? paint);
[<Android.Runtime.Register("drawBitmap", "([IIIFFIIZLandroid/graphics/Paint;)V", "GetDrawBitmap_arrayIIIFFIIZLandroid_graphics_Paint_Handler")>]
[<System.Obsolete("deprecated")>]
abstract member DrawBitmap : int[] * int * int * single * single * int * int * bool * Android.Graphics.Paint -> unit
override this.DrawBitmap : int[] * int * int * single * single * int * int * bool * Android.Graphics.Paint -> unit

Parameters

colors
Int32[]

Array of colors representing the pixels of the bitmap

offset
Int32

Offset into the array of colors for the first pixel

stride
Int32

The number of colors in the array between rows (must be >= width or <= -width).

x
Single

The X coordinate for where to draw the bitmap

y
Single

The Y coordinate for where to draw the bitmap

width
Int32

The width of the bitmap

height
Int32

The height of the bitmap

hasAlpha
Boolean

True if the alpha channel of the colors contains valid values. If false, the alpha byte is ignored (assumed to be 0xFF for every pixel).

paint
Paint

May be null. The paint used to draw the bitmap

Attributes

Remarks

Treat the specified array of colors as a bitmap, and draw it. This gives the same result as first creating a bitmap from the array, and then drawing it, but this method avoids explicitly creating a bitmap object which can be more efficient if the colors are changing often.

This member is deprecated. Usage with a #isHardwareAccelerated() hardware accelerated canvas requires an internal copy of color buffer contents every time this method is called. Using a Bitmap avoids this copy, and allows the application to more explicitly control the lifetime and copies of pixel data.

Java documentation for android.graphics.Canvas.drawBitmap(int[], int, int, float, float, int, int, boolean, android.graphics.Paint).

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.

Applies to

DrawBitmap(Int32[], Int32, Int32, Int32, Int32, Int32, Int32, Boolean, Paint)

Caution

deprecated

Legacy version of drawBitmap(int[] colors, .

[Android.Runtime.Register("drawBitmap", "([IIIIIIIZLandroid/graphics/Paint;)V", "GetDrawBitmap_arrayIIIIIIIZLandroid_graphics_Paint_Handler")]
[System.Obsolete("deprecated")]
public virtual void DrawBitmap (int[] colors, int offset, int stride, int x, int y, int width, int height, bool hasAlpha, Android.Graphics.Paint? paint);
[<Android.Runtime.Register("drawBitmap", "([IIIIIIIZLandroid/graphics/Paint;)V", "GetDrawBitmap_arrayIIIIIIIZLandroid_graphics_Paint_Handler")>]
[<System.Obsolete("deprecated")>]
abstract member DrawBitmap : int[] * int * int * int * int * int * int * bool * Android.Graphics.Paint -> unit
override this.DrawBitmap : int[] * int * int * int * int * int * int * bool * Android.Graphics.Paint -> unit

Parameters

colors
Int32[]
offset
Int32
stride
Int32
x
Int32
y
Int32
width
Int32
height
Int32
hasAlpha
Boolean
paint
Paint

The paint used to draw the bitmap (may be null)

Attributes

Remarks

Legacy version of drawBitmap(int[] colors, ...) that took ints for x,y

This member is deprecated. Usage with a #isHardwareAccelerated() hardware accelerated canvas requires an internal copy of color buffer contents every time this method is called. Using a Bitmap avoids this copy, and allows the application to more explicitly control the lifetime and copies of pixel data.

Java documentation for android.graphics.Canvas.drawBitmap(int[], int, int, int, int, int, int, boolean, android.graphics.Paint).

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.

Applies to

DrawBitmap(Bitmap, Single, Single, Paint)

Draw the specified bitmap, with its top/left corner at (x,y), using the specified paint, transformed by the current matrix.

[Android.Runtime.Register("drawBitmap", "(Landroid/graphics/Bitmap;FFLandroid/graphics/Paint;)V", "GetDrawBitmap_Landroid_graphics_Bitmap_FFLandroid_graphics_Paint_Handler")]
public virtual void DrawBitmap (Android.Graphics.Bitmap bitmap, float left, float top, Android.Graphics.Paint? paint);
[<Android.Runtime.Register("drawBitmap", "(Landroid/graphics/Bitmap;FFLandroid/graphics/Paint;)V", "GetDrawBitmap_Landroid_graphics_Bitmap_FFLandroid_graphics_Paint_Handler")>]
abstract member DrawBitmap : Android.Graphics.Bitmap * single * single * Android.Graphics.Paint -> unit
override this.DrawBitmap : Android.Graphics.Bitmap * single * single * Android.Graphics.Paint -> unit

Parameters

bitmap
Bitmap

The bitmap to be drawn

left
Single

The position of the left side of the bitmap being drawn

top
Single

The position of the top side of the bitmap being drawn

paint
Paint

The paint used to draw the bitmap (may be null)

Attributes

Remarks

Draw the specified bitmap, with its top/left corner at (x,y), using the specified paint, transformed by the current matrix.

Note: if the paint contains a maskfilter that generates a mask which extends beyond the bitmap's original width/height (e.g. BlurMaskFilter), then the bitmap will be drawn as if it were in a Shader with CLAMP mode. Thus the color outside of the original width/height will be the edge color replicated.

If the bitmap and canvas have different densities, this function will take care of automatically scaling the bitmap to draw at the same density as the canvas.

Java documentation for android.graphics.Canvas.drawBitmap(android.graphics.Bitmap, float, float, android.graphics.Paint).

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.

Applies to

DrawBitmap(Bitmap, Rect, Rect, Paint)

Draw the specified bitmap, scaling/translating automatically to fill the destination rectangle.

[Android.Runtime.Register("drawBitmap", "(Landroid/graphics/Bitmap;Landroid/graphics/Rect;Landroid/graphics/Rect;Landroid/graphics/Paint;)V", "GetDrawBitmap_Landroid_graphics_Bitmap_Landroid_graphics_Rect_Landroid_graphics_Rect_Landroid_graphics_Paint_Handler")]
public virtual void DrawBitmap (Android.Graphics.Bitmap bitmap, Android.Graphics.Rect? src, Android.Graphics.Rect dst, Android.Graphics.Paint? paint);
[<Android.Runtime.Register("drawBitmap", "(Landroid/graphics/Bitmap;Landroid/graphics/Rect;Landroid/graphics/Rect;Landroid/graphics/Paint;)V", "GetDrawBitmap_Landroid_graphics_Bitmap_Landroid_graphics_Rect_Landroid_graphics_Rect_Landroid_graphics_Paint_Handler")>]
abstract member DrawBitmap : Android.Graphics.Bitmap * Android.Graphics.Rect * Android.Graphics.Rect * Android.Graphics.Paint -> unit
override this.DrawBitmap : Android.Graphics.Bitmap * Android.Graphics.Rect * Android.Graphics.Rect * Android.Graphics.Paint -> unit

Parameters

bitmap
Bitmap

The bitmap to be drawn

src
Rect

May be null. The subset of the bitmap to be drawn

dst
Rect

The rectangle that the bitmap will be scaled/translated to fit into

paint
Paint

May be null. The paint used to draw the bitmap

Attributes

Remarks

Draw the specified bitmap, scaling/translating automatically to fill the destination rectangle. If the source rectangle is not null, it specifies the subset of the bitmap to draw.

Note: if the paint contains a maskfilter that generates a mask which extends beyond the bitmap's original width/height (e.g. BlurMaskFilter), then the bitmap will be drawn as if it were in a Shader with CLAMP mode. Thus the color outside of the original width/height will be the edge color replicated.

This function <em>ignores the density associated with the bitmap</em>. This is because the source and destination rectangle coordinate spaces are in their respective densities, so must already have the appropriate scaling factor applied.

Java documentation for android.graphics.Canvas.drawBitmap(android.graphics.Bitmap, android.graphics.Rect, android.graphics.Rect, android.graphics.Paint).

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.

Applies to

DrawBitmap(Bitmap, Matrix, Paint)

Draw the bitmap using the specified matrix.

[Android.Runtime.Register("drawBitmap", "(Landroid/graphics/Bitmap;Landroid/graphics/Matrix;Landroid/graphics/Paint;)V", "GetDrawBitmap_Landroid_graphics_Bitmap_Landroid_graphics_Matrix_Landroid_graphics_Paint_Handler")]
public virtual void DrawBitmap (Android.Graphics.Bitmap bitmap, Android.Graphics.Matrix matrix, Android.Graphics.Paint? paint);
[<Android.Runtime.Register("drawBitmap", "(Landroid/graphics/Bitmap;Landroid/graphics/Matrix;Landroid/graphics/Paint;)V", "GetDrawBitmap_Landroid_graphics_Bitmap_Landroid_graphics_Matrix_Landroid_graphics_Paint_Handler")>]
abstract member DrawBitmap : Android.Graphics.Bitmap * Android.Graphics.Matrix * Android.Graphics.Paint -> unit
override this.DrawBitmap : Android.Graphics.Bitmap * Android.Graphics.Matrix * Android.Graphics.Paint -> unit

Parameters

bitmap
Bitmap

The bitmap to draw

matrix
Matrix

The matrix used to transform the bitmap when it is drawn

paint
Paint

May be null. The paint used to draw the bitmap

Attributes

Remarks

Draw the bitmap using the specified matrix.

Java documentation for android.graphics.Canvas.drawBitmap(android.graphics.Bitmap, android.graphics.Matrix, android.graphics.Paint).

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.

Applies to

DrawBitmap(Bitmap, Rect, RectF, Paint)

Draw the specified bitmap, scaling/translating automatically to fill the destination rectangle.

[Android.Runtime.Register("drawBitmap", "(Landroid/graphics/Bitmap;Landroid/graphics/Rect;Landroid/graphics/RectF;Landroid/graphics/Paint;)V", "GetDrawBitmap_Landroid_graphics_Bitmap_Landroid_graphics_Rect_Landroid_graphics_RectF_Landroid_graphics_Paint_Handler")]
public virtual void DrawBitmap (Android.Graphics.Bitmap bitmap, Android.Graphics.Rect? src, Android.Graphics.RectF dst, Android.Graphics.Paint? paint);
[<Android.Runtime.Register("drawBitmap", "(Landroid/graphics/Bitmap;Landroid/graphics/Rect;Landroid/graphics/RectF;Landroid/graphics/Paint;)V", "GetDrawBitmap_Landroid_graphics_Bitmap_Landroid_graphics_Rect_Landroid_graphics_RectF_Landroid_graphics_Paint_Handler")>]
abstract member DrawBitmap : Android.Graphics.Bitmap * Android.Graphics.Rect * Android.Graphics.RectF * Android.Graphics.Paint -> unit
override this.DrawBitmap : Android.Graphics.Bitmap * Android.Graphics.Rect * Android.Graphics.RectF * Android.Graphics.Paint -> unit

Parameters

bitmap
Bitmap

The bitmap to be drawn

src
Rect

May be null. The subset of the bitmap to be drawn

dst
RectF

The rectangle that the bitmap will be scaled/translated to fit into

paint
Paint

May be null. The paint used to draw the bitmap

Attributes

Remarks

Draw the specified bitmap, scaling/translating automatically to fill the destination rectangle. If the source rectangle is not null, it specifies the subset of the bitmap to draw.

Note: if the paint contains a maskfilter that generates a mask which extends beyond the bitmap's original width/height (e.g. BlurMaskFilter), then the bitmap will be drawn as if it were in a Shader with CLAMP mode. Thus the color outside of the original width/height will be the edge color replicated.

This function <em>ignores the density associated with the bitmap</em>. This is because the source and destination rectangle coordinate spaces are in their respective densities, so must already have the appropriate scaling factor applied.

Java documentation for android.graphics.Canvas.drawBitmap(android.graphics.Bitmap, android.graphics.Rect, android.graphics.RectF, android.graphics.Paint).

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.

Applies to