语言

Canvas.DrawBitmap 方法

定义

重载

名称 说明
DrawBitmap(Int32[], Int32, Int32, Single, Single, Int32, Int32, Boolean, Paint)
已过时.

将指定的颜色数组视为位图,并绘制它。

DrawBitmap(Int32[], Int32, Int32, Int32, Int32, Int32, Int32, Boolean, Paint)
已过时.

drawBitmap 的旧版(int[] 颜色, .

DrawBitmap(Bitmap, Single, Single, Paint)

使用指定的绘图(由当前矩阵转换)绘制指定位图,其左上角为 x,y。

DrawBitmap(Bitmap, Matrix, Paint)

使用指定的矩阵绘制位图。

DrawBitmap(Bitmap, Rect, Rect, Paint)

绘制指定的位图,自动缩放/转换以填充目标矩形。

DrawBitmap(Bitmap, Rect, RectF, Paint)

绘制指定的位图,自动缩放/转换以填充目标矩形。

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

注意

deprecated

将指定的颜色数组视为位图,并绘制它。

[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

参数

colors
Int32[]

表示位图像素的颜色数组

offset
Int32

第一个像素的颜色数组的偏移量

stride
Int32

行之间的数组颜色数(必须为 >宽度或 <= -width)。

x
Single

绘制位图的位置的 X 坐标

y
Single

绘制位图位置的 Y 坐标

width
Int32

位图的宽度

height
Int32

位图的高度

hasAlpha
Boolean

如此 如果颜色的 alpha 通道包含有效值。 如果为 false,则忽略 alpha 字节(假定为每个像素0xFF)。

paint
Paint

可以为 null。 用于绘制位图的油漆

特性

注解

将指定的颜色数组视为位图,并绘制它。 这提供了与首先从数组创建位图,然后绘制位图的结果相同,但此方法避免显式创建位图对象,如果颜色经常发生更改,则可以更高效。

此成员已弃用。 #isHardwareAccelerated() hardware accelerated每次调用此方法时,画布的使用都需要颜色缓冲区内容的内部副本。 使用 Bitmap 可避免此副本,并允许应用程序更显式地控制像素数据的生存期和副本。

Java文档android.graphics.Canvas.drawBitmap(int[], int, int, float, float, int, int, boolean, android.graphics.Paint)。

本页的某些部分是根据 创建和共享的工作进行的修改,并根据 许可证中所述的条款使用。

适用于

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

注意

deprecated

drawBitmap 的旧版(int[] 颜色, .

[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

参数

colors
Int32[]

打包的 ARGB 像素颜色的数组。

offset
Int32

数组中第一个像素颜色的索引。

stride
Int32

相邻行的开头之间的数组条目数。

x
Int32

位图左上角的水平位置。

y
Int32

位图左上角的垂直位置。

width
Int32

从每行读取的像素颜色数。

height
Int32

从颜色数组读取的行数。

hasAlpha
Boolean

如此 如果颜色的 alpha 通道包含有效值。 如果为 false,则忽略 alpha 字节(假定为每个像素0xFF)。

paint
Paint

用于绘制位图的油漆(可能为 null)

特性

注解

用于 x,y 的 drawBitmap(int[] 颜色...)的旧版本

此成员已弃用。 #isHardwareAccelerated() hardware accelerated每次调用此方法时,画布的使用都需要颜色缓冲区内容的内部副本。 使用 Bitmap 可避免此副本,并允许应用程序更显式地控制像素数据的生存期和副本。

Java文档android.graphics.Canvas.drawBitmap(int[], int, int, int, int, int, int, boolean, android.graphics.Paint)。

本页的某些部分是根据 创建和共享的工作进行的修改,并根据 许可证中所述的条款使用。

适用于

DrawBitmap(Bitmap, Single, Single, Paint)

使用指定的绘图(由当前矩阵转换)绘制指定位图,其左上角为 x,y。

[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

参数

bitmap
Bitmap

要绘制的位图

left
Single

要绘制的位图左侧的位置

top
Single

正在绘制的位图的上侧的位置

paint
Paint

用于绘制位图的油漆(可能为 null)

特性

注解

使用指定的绘图(由当前矩阵转换)绘制指定位图,其左上角为 x,y。

注意:如果油漆包含一个掩码,它生成一个掩码,该掩码超出了位图的原始宽度/高度(例如 BlurMaskFilter),则位图将像处于具有 CLAMP 模式的着色器中一样绘制。 因此,原始宽度/高度之外的颜色将是复制边缘颜色。

如果位图和画布具有不同的密度,此函数将负责自动缩放位图以与画布相同的密度绘制。

Java文档android.graphics.Canvas.drawBitmap(android.graphics.Bitmap, float, float, android.graphics.Paint)。

本页的某些部分是根据 创建和共享的工作进行的修改,并根据 许可证中所述的条款使用。

适用于

DrawBitmap(Bitmap, Matrix, 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")]
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

参数

bitmap
Bitmap

要绘制的位图

matrix
Matrix

绘制位图时用于转换位图的矩阵

paint
Paint

可以为 null。 用于绘制位图的油漆

特性

注解

使用指定的矩阵绘制位图。

Java文档android.graphics.Canvas.drawBitmap(android.graphics.Bitmap, android.graphics.Matrix, android.graphics.Paint)。

本页的某些部分是根据 创建和共享的工作进行的修改,并根据 许可证中所述的条款使用。

适用于

DrawBitmap(Bitmap, Rect, Rect, 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")]
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

参数

bitmap
Bitmap

要绘制的位图

src
Rect

可以为 null。 要绘制的位图的子集

dst
Rect

位图将缩放/转换为适合的矩形

paint
Paint

可以为 null。 用于绘制位图的油漆

特性

注解

绘制指定的位图,自动缩放/转换以填充目标矩形。 如果源矩形不为 null,则指定要绘制的位图子集。

注意:如果油漆包含一个掩码,它生成一个掩码,该掩码超出了位图的原始宽度/高度(例如 BlurMaskFilter),则位图将像处于具有 CLAMP 模式的着色器中一样绘制。 因此,原始宽度/高度之外的颜色将是复制边缘颜色。

此函数 忽略与位图关联的密度。 这是因为源矩形坐标空间和目标矩形坐标空间各自密度,因此必须已应用适当的缩放因子。

Java文档android.graphics.Canvas.drawBitmap(android.graphics.Bitmap, android.graphics.Rect, android.graphics.Rect, android.graphics.Paint)。

本页的某些部分是根据 创建和共享的工作进行的修改,并根据 许可证中所述的条款使用。

适用于

DrawBitmap(Bitmap, Rect, RectF, 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")]
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

参数

bitmap
Bitmap

要绘制的位图

src
Rect

可以为 null。 要绘制的位图的子集

dst
RectF

位图将缩放/转换为适合的矩形

paint
Paint

可以为 null。 用于绘制位图的油漆

特性

注解

绘制指定的位图,自动缩放/转换以填充目标矩形。 如果源矩形不为 null,则指定要绘制的位图子集。

注意:如果油漆包含一个掩码,它生成一个掩码,该掩码超出了位图的原始宽度/高度(例如 BlurMaskFilter),则位图将像处于具有 CLAMP 模式的着色器中一样绘制。 因此,原始宽度/高度之外的颜色将是复制边缘颜色。

此函数 忽略与位图关联的密度。 这是因为源矩形坐标空间和目标矩形坐标空间各自密度,因此必须已应用适当的缩放因子。

Java文档android.graphics.Canvas.drawBitmap(android.graphics.Bitmap, android.graphics.Rect, android.graphics.RectF, android.graphics.Paint)。

本页的某些部分是根据 创建和共享的工作进行的修改,并根据 许可证中所述的条款使用。

适用于