Expand description
§Example
extern crate imagefmt;
use imagefmt::{ColFmt, ColType};
fn main() {
// load and convert to bgra
let _pic = imagefmt::read("stars.jpg", ColFmt::BGRA).unwrap();
// convert to one of y, ya, rgb, rgba
let pic = imagefmt::read("marbles.tga", ColFmt::Auto).unwrap();
// write image out as grayscale
imagefmt::write("out.tga", pic.w, pic.h, pic.fmt, &pic.buf,
ColType::Gray)
.unwrap();
// get width, height and color type
let _info = imagefmt::read_info("hiisi.png").unwrap();
}There are also format specific read and write functions which are more flexible. With
the write functions, set the last argument to None to write the whole image or see
source code for write_region for an example to write only a region. Use
std::io::Cursor to read and
write in-memory images.
Modules§
Structs§
Enums§
- ColFmt
- Color format – determines color type and channel order.
- ColType
- Color type – these are categories of color formats.
- Error
- Error.
Functions§
- read
- Reads an image and converts it to requested format.
- read_
from - Like
readbut reads from a reader. - read_
info - Returns width, height and color type of the image.
- read_
info_ from - Like
read_infobut reads from a reader. If it fails, it seeks back to where started. - write
- Writes an image and converts it to requested color type.
- write_
region - Writes a region of an image and converts it to requested color type.
Type Aliases§
- Result
- The type returned from all the functions.