On this page:
Bitmap
Bitmap.width
Bitmap.height
Bitmap.size
Bitmap.backing_  scale
Bitmap.depth
Bitmap.has_  color
Bitmap.has_  alpha
Bitmap.is_  ok
Bitmap.make_  dc
Bitmap.argb_  pixels
Bitmap.set_  argb_  pixels
Bitmap.write
Bitmap.from_  file
8.12

8 Bitmap🔗ℹ

class

class Bitmap():

  constructor (

    width :: PosInt,

    height :: PosInt,

    ~backing_scale: backing_space :: Real.above(0.0) = 1,

    ~has_color: has_color :: Any = #true,

    ~has_alpha: has_alpha :: Any = #true,

  )

property

property (bm :: Bitmap).width :: PosInt

 

property

property (bm :: Bitmap).height :: PosInt

 

property

property (bm :: Bitmap).size :: Size

 

property

property (bm :: Bitmap).backing_scale :: Real.above(0.0)

 

property

property (bm :: Bitmap).depth :: NonnegInt

 

property

property (bm :: Bitmap).has_color :: Boolean

 

property

property (bm :: Bitmap).has_alpha :: Boolean

 

property

property (bm :: Bitmap).is_ok :: Boolean

Properties to access bitmap components. The Bitmap.size property combines the Bitmap.width and Bitmap.height properties.

method

method (bm :: Bitmap).make_dc() :: DC

Creates a drawing context that writes to the bitmap.

method

method (bm :: Bitmap).argb_pixels(

  ~x: x :: NonnegInt = 0,

  ~y: y :: NonnegInt = 0,

  ~width: width :: NonnegInt = width,

  ~height: height :: NonnegInt = height,

  ~dest: dest :: Bytes = Bytes.make(width * height * 4),

) :: Bytes

Copies the bitmap content into dest and returns it.

method

method (bm :: Bitmap).set_argb_pixels(

  src :: Bytes,

  ~x: x :: NonnegInt = 0,

  ~y: y :: NonnegInt = 0,

  ~width: width :: NonnegInt = width,

  ~height: height :: NonnegInt = height,

) :: Void

Sets a region of the bitmap to src.

method

method (bm :: Bitmap).write(

  dest :: Path,

  ~kind: kind :: Any.of(#'png, #'jpeg, #'xbm, #'xpm, #'bmp),

  ~quality: quality :: Int.in(0, 100) = 75,

  ~as_unscaled: as_unscaled :: Any = #false,

) :: Void

Writes the bitmap to a file.

function

fun Bitmap.from_file(path :: String || Path) :: Bitmap

Reads a bitmap from path.