Crate imagefmt [−] [src]
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 pic.write("out.png", ColType::Gray).unwrap(); // there's also a free function that doesn't require an Image 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 format specific functions that might offer more flexibility. When directly
using the format specific write functions, set the last argument to None
to write
the whole image. To write only a region of the image, see source code for
write_region
for an example. Reading and writing in-memory images can be done using
std::io::Cursor
.
Modules
bmp | |
jpeg | |
png | |
tga |
Structs
Image |
Image struct returned from the read functions. |
Info |
Holds basic info about an image. |
Enums
ColFmt |
Color format – determines color type and channel order. |
ColType |
Color type – these are categories of color formats. |
Error |
Error. |
Functions
convert |
Converts the image into a new allocation. |
read |
Reads an image and converts it to requested format. |
read_from |
Like |
read_info |
Returns width, height and color type of the image. |
read_info_from |
Like |
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 Definitions
Result |
The type returned from all the functions. |