CrImage::BMP::Writer
Inherits Reference / Object
BMP Writer encodes images to Windows Bitmap format.
Automatically selects optimal bit depth:
- 8-bit for Gray and Paletted images (with 256-color palette)
- 24-bit for opaque RGB images (no alpha channel)
- 32-bit for images with transparency (RGBA)
Features:
- RGB to BGR byte order conversion
- Bottom-up row storage (standard BMP orientation)
- 4-byte row alignment padding
- Premultiplied to non-premultiplied alpha conversion for RGBA
- Palette generation for grayscale images
Constructors
new(io : IO)
SourceClass methods
Writes an image to a file in BMP format.
Parameters:
path: Output file pathimage: Image to encode
Example:
img = CrImage.rgba(400, 300)
CrImage::BMP::Writer.write("output.bmp", img)
Writes an image to an IO stream in BMP format.
Parameters:
io: Output IO streamimage: Image to encode
Example:
File.open("output.bmp", "wb") do |file|
CrImage::BMP::Writer.write(file, img)
end