BitmapKt
public final class BitmapKt
Summary
Public methods |
|
|---|---|
static final @NonNull Bitmap |
Creates a new |
static final boolean |
Returns true if the specified point is inside the bitmap. |
static final boolean |
Returns true if the specified point is inside the bitmap. |
static final @NonNull Bitmap |
createBitmap(int width, int height, @NonNull Bitmap.Config config)Returns a mutable bitmap with the specified |
static final @NonNull Bitmap |
@RequiresApi(value = 26)Returns a mutable bitmap with the specified |
static final int |
Returns the value of the pixel at the specified location. |
static final @NonNull Bitmap |
Creates a new bitmap, scaled from this bitmap, when possible. |
static final void |
Writes the specified |
Public methods
applyCanvas
public static final @NonNull Bitmap applyCanvas(
@NonNull Bitmap receiver,
@NonNull Function1<@NonNull Canvas, Unit> block
)
Creates a new Canvas to draw on this bitmap and executes the specified block on the newly created canvas. Example:
return Bitmap.createBitmap(…).applyCanvas {
drawLine(…)
translate(…)
drawRect(…)
}contains
public static final boolean contains(@NonNull Bitmap receiver, @NonNull Point p)
Returns true if the specified point is inside the bitmap. A point is contained if: 0 <= x < width and 0 <= y < height. An empty bitmap never contains any point.
contains
public static final boolean contains(@NonNull Bitmap receiver, @NonNull PointF p)
Returns true if the specified point is inside the bitmap. A point is contained if: 0 <= x < width and 0 <= y < height. An empty bitmap never contains any point.
createBitmap
public static final @NonNull Bitmap createBitmap(int width, int height, @NonNull Bitmap.Config config)
Returns a mutable bitmap with the specified width and height. A config can be optionally specified. If not, the default config is Bitmap.Config.ARGB_8888.
| Parameters | |
|---|---|
int width |
The new bitmap's desired width |
int height |
The new bitmap's desired height |
@NonNull Bitmap.Config config |
The new bitmap's desired |
createBitmap
@RequiresApi(value = 26)
public static final @NonNull Bitmap createBitmap(
int width,
int height,
@NonNull Bitmap.Config config,
boolean hasAlpha,
@NonNull ColorSpace colorSpace
)
Returns a mutable bitmap with the specified width and height. The config, transparency and color space can optionally be specified. They respectively default to Bitmap.Config.ARGB_8888, true and sRGB.
| Parameters | |
|---|---|
int width |
The new bitmap's desired width |
int height |
The new bitmap's desired height |
@NonNull Bitmap.Config config |
The new bitmap's desired |
boolean hasAlpha |
Whether the new bitmap is opaque or not |
@NonNull ColorSpace colorSpace |
The new bitmap's color space |
get
public static final int get(@NonNull Bitmap receiver, int x, int y)
Returns the value of the pixel at the specified location. The returned value is a color int in the sRGB color space.
scale
public static final @NonNull Bitmap scale(@NonNull Bitmap receiver, int width, int height, boolean filter)
Creates a new bitmap, scaled from this bitmap, when possible. If the specified width and height are the same as the current width and height of this bitmap, this bitmap is returned and no new bitmap is created.
| Parameters | |
|---|---|
int width |
The new bitmap's desired width |
int height |
The new bitmap's desired height |
boolean filter |
|