Expand description
A small library for reading and writing BMP images.
The library supports uncompressed BMP Version 3 images. The different decoding and encoding schemes is shown in the table below.
| Scheme | Decoding | Encoding | Compression |
|---|---|---|---|
| 24 bpp | ✓ | ✓ | No |
| 8 bpp | ✓ | ✗ | No |
| 4 bpp | ✓ | ✗ | No |
| 1 bpp | ✓ | ✗ | No |
§Example
#[macro_use]
extern crate bmp;
use bmp::{Image, Pixel};
fn main() {
let mut img = Image::new(256, 256);
for (x, y) in img.coordinates() {
img.set_pixel(x, y, px!(x, y, 200));
}
let _ = img.save("img.bmp");
}Modules§
- consts
- Common color constants accessible by names.
Macros§
- px
- Macro to generate a
Pixelfromr,gandbvalues.
Structs§
- BmpError
- The error type returned if the decoding of an image from disk fails.
- Image
- The image type provided by the library.
- Image
Index - An
Iteratorreturning thexandycoordinates of an image. - Pixel
- The pixel data used in the
Image.
Enums§
- BmpError
Kind - The different kinds of possible BMP errors.
Functions§
- from_
reader - Attempts to construct a new
Imagefrom the given reader. Returns aBmpResult, either containing anImageor aBmpError. - open
- Utility function to load an
Imagefrom the file specified bypath. It uses thefrom_readerfunction internally to decode theImage. Returns aBmpResult, either containing anImageor aBmpError.
Type Aliases§
- BmpResult
- A result type, either containing an
Imageor aBmpError.