Share via


Bitmap.CreateBitmap Method

Definition

Overloads

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(Bitmap, Int32, Int32, Int32, Int32, Matrix, Boolean)

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

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(DisplayMetrics, Int32, Int32, Bitmap+Config, Boolean, ColorSpace)
CreateBitmap(Int32, Int32, Bitmap+Config, Boolean, ColorSpace)
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, Bitmap+Config, Boolean)
CreateBitmap(Bitmap, Int32, Int32, Int32, Int32)

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

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, Bitmap+Config, Boolean)
CreateBitmap(DisplayMetrics, Int32, Int32, Bitmap+Config)

Returns a mutable bitmap with the specified width and height.

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

Returns a mutable bitmap with the specified width and height.

CreateBitmap(Picture)

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

CreateBitmap(Bitmap)

Returns a bitmap from the source bitmap.

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.

[Android.Runtime.Register("createBitmap", "(Landroid/util/DisplayMetrics;[IIIIILandroid/graphics/Bitmap$Config;)Landroid/graphics/Bitmap;", "")]
public static Android.Graphics.Bitmap CreateBitmap (Android.Util.DisplayMetrics display, int[] colors, int offset, int stride, int width, int height, Android.Graphics.Bitmap.Config config);
[<Android.Runtime.Register("createBitmap", "(Landroid/util/DisplayMetrics;[IIIIILandroid/graphics/Bitmap$Config;)Landroid/graphics/Bitmap;", "")>]
static member CreateBitmap : Android.Util.DisplayMetrics * int[] * int * int * int * int * Android.Graphics.Bitmap.Config -> Android.Graphics.Bitmap

Parameters

display
DisplayMetrics

Display metrics for the display this bitmap will be drawn on.

colors
Int32[]

Array of T:Android.Graphics._Color used to initialize the pixels.

offset
Int32

Number of values to skip before the first color in the array of colors.

stride
Int32

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

width
Int32

The width of the bitmap

height
Int32

The height of the bitmap

config
Bitmap.Config

The bitmap config to create. If the config does not support per-pixel alpha (e.g. RGB_565), then the alpha bytes in the colors[] will be ignored (assumed to be FF)

Returns

Attributes

Exceptions

if the width or height are <= 0, or if the color array's length is less than the number of pixels.

Remarks

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

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

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

[Android.Runtime.Register("createBitmap", "(Landroid/graphics/Bitmap;IIIILandroid/graphics/Matrix;Z)Landroid/graphics/Bitmap;", "")]
public static Android.Graphics.Bitmap CreateBitmap (Android.Graphics.Bitmap source, int x, int y, int width, int height, Android.Graphics.Matrix? m, bool filter);
[<Android.Runtime.Register("createBitmap", "(Landroid/graphics/Bitmap;IIIILandroid/graphics/Matrix;Z)Landroid/graphics/Bitmap;", "")>]
static member CreateBitmap : Android.Graphics.Bitmap * int * int * int * int * Android.Graphics.Matrix * bool -> Android.Graphics.Bitmap

Parameters

source
Bitmap

The bitmap we are subsetting

x
Int32

The x coordinate of the first pixel in source

y
Int32

The y coordinate of the first pixel in source

width
Int32

The number of pixels in each row

height
Int32

The number of rows

m
Matrix

Optional matrix to be applied to the pixels

filter
Boolean

true if the source should be filtered. Only applies if the matrix contains more than just translation.

Returns

A bitmap that represents the specified subset of source

Attributes

Exceptions

if the x, y, width, height values are outside of the dimensions of the source bitmap, or width is <= 0, or height is <= 0

Remarks

Returns a bitmap from subset of the source bitmap, transformed by the optional matrix. The new bitmap may be the same object as source, or a copy may have been made. It is initialized with the same density and color space as the original bitmap.

If the source bitmap is immutable and the requested subset is the same as the source bitmap itself, then the source bitmap is returned and no new bitmap is created.

The returned bitmap will always be mutable except in the following scenarios: (1) In situations where the source bitmap is returned and the source bitmap is immutable

(2) The source bitmap is a hardware bitmap. That is #getConfig() is equivalent to Config#HARDWARE

Java documentation for android.graphics.Bitmap.createBitmap(android.graphics.Bitmap, int, int, int, int, android.graphics.Matrix, boolean).

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

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.

[Android.Runtime.Register("createBitmap", "([IIIIILandroid/graphics/Bitmap$Config;)Landroid/graphics/Bitmap;", "")]
public static Android.Graphics.Bitmap CreateBitmap (int[] colors, int offset, int stride, int width, int height, Android.Graphics.Bitmap.Config config);
[<Android.Runtime.Register("createBitmap", "([IIIIILandroid/graphics/Bitmap$Config;)Landroid/graphics/Bitmap;", "")>]
static member CreateBitmap : int[] * int * int * int * int * Android.Graphics.Bitmap.Config -> Android.Graphics.Bitmap

Parameters

colors
Int32[]

Array of T:Android.Graphics._Color used to initialize the pixels.

offset
Int32

Number of values to skip before the first color in the array of colors.

stride
Int32

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

width
Int32

The width of the bitmap

height
Int32

The height of the bitmap

config
Bitmap.Config

The bitmap config to create. If the config does not support per-pixel alpha (e.g. RGB_565), then the alpha bytes in the colors[] will be ignored (assumed to be FF)

Returns

Attributes

Exceptions

if the width or height are <= 0, or if the color array's length is less than the number of pixels.

Remarks

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

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

[Android.Runtime.Register("createBitmap", "(Landroid/util/DisplayMetrics;IILandroid/graphics/Bitmap$Config;ZLandroid/graphics/ColorSpace;)Landroid/graphics/Bitmap;", "", ApiSince=26)]
public static Android.Graphics.Bitmap CreateBitmap (Android.Util.DisplayMetrics? display, int width, int height, Android.Graphics.Bitmap.Config config, bool hasAlpha, Android.Graphics.ColorSpace colorSpace);
[<Android.Runtime.Register("createBitmap", "(Landroid/util/DisplayMetrics;IILandroid/graphics/Bitmap$Config;ZLandroid/graphics/ColorSpace;)Landroid/graphics/Bitmap;", "", ApiSince=26)>]
static member CreateBitmap : Android.Util.DisplayMetrics * int * int * Android.Graphics.Bitmap.Config * bool * Android.Graphics.ColorSpace -> Android.Graphics.Bitmap

Parameters

display
DisplayMetrics
width
Int32
height
Int32
config
Bitmap.Config
hasAlpha
Boolean
colorSpace
ColorSpace

Returns

Attributes

Remarks

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

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

[Android.Runtime.Register("createBitmap", "(IILandroid/graphics/Bitmap$Config;ZLandroid/graphics/ColorSpace;)Landroid/graphics/Bitmap;", "", ApiSince=26)]
public static Android.Graphics.Bitmap CreateBitmap (int width, int height, Android.Graphics.Bitmap.Config config, bool hasAlpha, Android.Graphics.ColorSpace colorSpace);
[<Android.Runtime.Register("createBitmap", "(IILandroid/graphics/Bitmap$Config;ZLandroid/graphics/ColorSpace;)Landroid/graphics/Bitmap;", "", ApiSince=26)>]
static member CreateBitmap : int * int * Android.Graphics.Bitmap.Config * bool * Android.Graphics.ColorSpace -> Android.Graphics.Bitmap

Parameters

width
Int32
height
Int32
config
Bitmap.Config
hasAlpha
Boolean
colorSpace
ColorSpace

Returns

Attributes

Remarks

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

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.

[Android.Runtime.Register("createBitmap", "(Landroid/util/DisplayMetrics;[IIILandroid/graphics/Bitmap$Config;)Landroid/graphics/Bitmap;", "")]
public static Android.Graphics.Bitmap CreateBitmap (Android.Util.DisplayMetrics? display, int[] colors, int width, int height, Android.Graphics.Bitmap.Config config);
[<Android.Runtime.Register("createBitmap", "(Landroid/util/DisplayMetrics;[IIILandroid/graphics/Bitmap$Config;)Landroid/graphics/Bitmap;", "")>]
static member CreateBitmap : Android.Util.DisplayMetrics * int[] * int * int * Android.Graphics.Bitmap.Config -> Android.Graphics.Bitmap

Parameters

display
DisplayMetrics

Display metrics for the display this bitmap will be drawn on.

colors
Int32[]

Array of T:Android.Graphics._Color used to initialize the pixels. This array must be at least as large as width * height.

width
Int32

The width of the bitmap

height
Int32

The height of the bitmap

config
Bitmap.Config

The bitmap config to create. If the config does not support per-pixel alpha (e.g. RGB_565), then the alpha bytes in the colors[] will be ignored (assumed to be FF)

Returns

Attributes

Exceptions

if the width or height are <= 0, or if the color array's length is less than the number of pixels.

Remarks

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

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

[Android.Runtime.Register("createBitmap", "(Landroid/util/DisplayMetrics;IILandroid/graphics/Bitmap$Config;Z)Landroid/graphics/Bitmap;", "", ApiSince=26)]
public static Android.Graphics.Bitmap CreateBitmap (Android.Util.DisplayMetrics? display, int width, int height, Android.Graphics.Bitmap.Config config, bool hasAlpha);
[<Android.Runtime.Register("createBitmap", "(Landroid/util/DisplayMetrics;IILandroid/graphics/Bitmap$Config;Z)Landroid/graphics/Bitmap;", "", ApiSince=26)>]
static member CreateBitmap : Android.Util.DisplayMetrics * int * int * Android.Graphics.Bitmap.Config * bool -> Android.Graphics.Bitmap

Parameters

display
DisplayMetrics
width
Int32
height
Int32
config
Bitmap.Config
hasAlpha
Boolean

Returns

Attributes

Remarks

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

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

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

[Android.Runtime.Register("createBitmap", "(Landroid/graphics/Bitmap;IIII)Landroid/graphics/Bitmap;", "")]
public static Android.Graphics.Bitmap CreateBitmap (Android.Graphics.Bitmap source, int x, int y, int width, int height);
[<Android.Runtime.Register("createBitmap", "(Landroid/graphics/Bitmap;IIII)Landroid/graphics/Bitmap;", "")>]
static member CreateBitmap : Android.Graphics.Bitmap * int * int * int * int -> Android.Graphics.Bitmap

Parameters

source
Bitmap

The bitmap we are subsetting

x
Int32

The x coordinate of the first pixel in source

y
Int32

The y coordinate of the first pixel in source

width
Int32

The number of pixels in each row

height
Int32

The number of rows

Returns

A copy of a subset of the source bitmap or the source bitmap itself.

Attributes

Exceptions

if the x, y, width, height values are outside of the dimensions of the source bitmap, or width is <= 0, or height is <= 0

Remarks

Returns a bitmap from the specified subset of the source bitmap. The new bitmap may be the same object as source, or a copy may have been made. It is initialized with the same density and color space as the original bitmap.

Java documentation for android.graphics.Bitmap.createBitmap(android.graphics.Bitmap, int, int, int, int).

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

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.

[Android.Runtime.Register("createBitmap", "([IIILandroid/graphics/Bitmap$Config;)Landroid/graphics/Bitmap;", "")]
public static Android.Graphics.Bitmap CreateBitmap (int[] colors, int width, int height, Android.Graphics.Bitmap.Config? config);
[<Android.Runtime.Register("createBitmap", "([IIILandroid/graphics/Bitmap$Config;)Landroid/graphics/Bitmap;", "")>]
static member CreateBitmap : int[] * int * int * Android.Graphics.Bitmap.Config -> Android.Graphics.Bitmap

Parameters

colors
Int32[]

Array of T:Android.Graphics._Color used to initialize the pixels. This array must be at least as large as width * height.

width
Int32

The width of the bitmap

height
Int32

The height of the bitmap

config
Bitmap.Config

The bitmap config to create. If the config does not support per-pixel alpha (e.g. RGB_565), then the alpha bytes in the colors[] will be ignored (assumed to be FF)

Returns

Attributes

Exceptions

if the width or height are <= 0, or if the color array's length is less than the number of pixels.

Remarks

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

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

[Android.Runtime.Register("createBitmap", "(IILandroid/graphics/Bitmap$Config;Z)Landroid/graphics/Bitmap;", "", ApiSince=26)]
public static Android.Graphics.Bitmap CreateBitmap (int width, int height, Android.Graphics.Bitmap.Config config, bool hasAlpha);
[<Android.Runtime.Register("createBitmap", "(IILandroid/graphics/Bitmap$Config;Z)Landroid/graphics/Bitmap;", "", ApiSince=26)>]
static member CreateBitmap : int * int * Android.Graphics.Bitmap.Config * bool -> Android.Graphics.Bitmap

Parameters

width
Int32
height
Int32
config
Bitmap.Config
hasAlpha
Boolean

Returns

Attributes

Remarks

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

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

Returns a mutable bitmap with the specified width and height.

[Android.Runtime.Register("createBitmap", "(Landroid/util/DisplayMetrics;IILandroid/graphics/Bitmap$Config;)Landroid/graphics/Bitmap;", "")]
public static Android.Graphics.Bitmap CreateBitmap (Android.Util.DisplayMetrics? display, int width, int height, Android.Graphics.Bitmap.Config config);
[<Android.Runtime.Register("createBitmap", "(Landroid/util/DisplayMetrics;IILandroid/graphics/Bitmap$Config;)Landroid/graphics/Bitmap;", "")>]
static member CreateBitmap : Android.Util.DisplayMetrics * int * int * Android.Graphics.Bitmap.Config -> Android.Graphics.Bitmap

Parameters

display
DisplayMetrics

Display metrics for the display this bitmap will be drawn on.

width
Int32

The width of the bitmap

height
Int32

The height of the bitmap

config
Bitmap.Config

The bitmap config to create.

Returns

Attributes

Exceptions

if the width or height are <= 0

Remarks

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

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

[Android.Runtime.Register("createBitmap", "(Landroid/graphics/Picture;IILandroid/graphics/Bitmap$Config;)Landroid/graphics/Bitmap;", "", ApiSince=28)]
public static Android.Graphics.Bitmap CreateBitmap (Android.Graphics.Picture source, int width, int height, Android.Graphics.Bitmap.Config config);
[<Android.Runtime.Register("createBitmap", "(Landroid/graphics/Picture;IILandroid/graphics/Bitmap$Config;)Landroid/graphics/Bitmap;", "", ApiSince=28)>]
static member CreateBitmap : Android.Graphics.Picture * int * int * Android.Graphics.Bitmap.Config -> Android.Graphics.Bitmap

Parameters

source
Picture
width
Int32
height
Int32
config
Bitmap.Config

Returns

Attributes

Applies to

CreateBitmap(Int32, Int32, Bitmap+Config)

Returns a mutable bitmap with the specified width and height.

[Android.Runtime.Register("createBitmap", "(IILandroid/graphics/Bitmap$Config;)Landroid/graphics/Bitmap;", "")]
public static Android.Graphics.Bitmap CreateBitmap (int width, int height, Android.Graphics.Bitmap.Config config);
[<Android.Runtime.Register("createBitmap", "(IILandroid/graphics/Bitmap$Config;)Landroid/graphics/Bitmap;", "")>]
static member CreateBitmap : int * int * Android.Graphics.Bitmap.Config -> Android.Graphics.Bitmap

Parameters

width
Int32

The width of the bitmap

height
Int32

The height of the bitmap

config
Bitmap.Config

The bitmap config to create.

Returns

Attributes

Exceptions

if the width or height are <= 0

Remarks

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

CreateBitmap(Picture)

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

[Android.Runtime.Register("createBitmap", "(Landroid/graphics/Picture;)Landroid/graphics/Bitmap;", "", ApiSince=28)]
public static Android.Graphics.Bitmap CreateBitmap (Android.Graphics.Picture source);
[<Android.Runtime.Register("createBitmap", "(Landroid/graphics/Picture;)Landroid/graphics/Bitmap;", "", ApiSince=28)>]
static member CreateBitmap : Android.Graphics.Picture -> Android.Graphics.Bitmap

Parameters

source
Picture

The recorded Picture of drawing commands that will be drawn into the returned Bitmap.

Returns

An immutable bitmap with a HARDWARE config whose contents are created from the recorded drawing commands in the Picture source.

Attributes

Remarks

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

Equivalent to calling #createBitmap(Picture, int, int, Config) with width and height the same as the Picture's width and height and a Config.HARDWARE config.

Java documentation for android.graphics.Bitmap.createBitmap(android.graphics.Picture).

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

CreateBitmap(Bitmap)

Returns a bitmap from the source bitmap.

[Android.Runtime.Register("createBitmap", "(Landroid/graphics/Bitmap;)Landroid/graphics/Bitmap;", "")]
public static Android.Graphics.Bitmap CreateBitmap (Android.Graphics.Bitmap src);
[<Android.Runtime.Register("createBitmap", "(Landroid/graphics/Bitmap;)Landroid/graphics/Bitmap;", "")>]
static member CreateBitmap : Android.Graphics.Bitmap -> Android.Graphics.Bitmap

Parameters

src
Bitmap

Returns

Attributes

Remarks

Returns a bitmap from the source bitmap. The new bitmap may be the same object as source, or a copy may have been made. It is initialized with the same density and color space as the original bitmap.

Java documentation for android.graphics.Bitmap.createBitmap(android.graphics.Bitmap).

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