Skip to content

Commit a97aa47

Browse files
committed
Restructure the Readme
Closes: #1182
1 parent a24556b commit a97aa47

File tree

1 file changed

+26
-32
lines changed

1 file changed

+26
-32
lines changed

README.md

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ interface lets third-party crates act as format implementations for `image`. If
4646
you need to handle some other image format, check crates.io for crates that
4747
implement it.
4848

49+
4950
## Feature Flags
5051

5152
| Feature | Description
@@ -57,54 +58,43 @@ implement it.
5758
| `avif-native` | Enables non-Rust dependencies of `avif` (`mp4parse` and `dav1d`)
5859
| `serde` | Enables `serde` integration for various structs and options
5960

60-
## Image Types
61+
## Image buffer types
62+
63+
`image` provides the following pixel types to describe the layout of pixels:
64+
+ **Rgb**: RGB pixel
65+
+ **Rgba**: RGB with alpha (RGBA pixel)
66+
+ **Luma**: Grayscale pixel
67+
+ **LumaA**: Grayscale with alpha
6168

62-
This crate provides a number of different types for representing images.
63-
Individual pixels within images are indexed with (0,0) at the top left corner.
69+
All pixels are parameterised by their component type. Conversion between
70+
pixel types uses a non-constant luminance `sRGB` model however fully
71+
featured buffers have an associated CICP color space for more diverse
72+
conversions.
6473

6574
### [`ImageBuffer`](https://docs.rs/image/*/image/struct.ImageBuffer.html)
75+
6676
An image parameterised by its Pixel type, represented by a width and height and
6777
a vector of pixels. It provides direct access to its pixels and implements the
68-
`GenericImageView` and `GenericImage` traits.
78+
`GenericImageView` and `GenericImage` traits. The main use cases are defining
79+
input images and working on a common layout of contents.
6980

7081
### [`DynamicImage`](https://docs.rs/image/*/image/enum.DynamicImage.html)
71-
A `DynamicImage` is an enumeration over all supported `ImageBuffer<P>` types.
72-
Its exact image type is determined at runtime. It is the type returned when
73-
opening an image. For convenience `DynamicImage` reimplements all image
74-
processing functions.
82+
83+
A `DynamicImage` is an enumeration over all supported `ImageBuffer<P>` types. Its
84+
type of pixels is determined at runtime within a set of basic types of layouts
85+
and channels. This type is returned when opening an image. For convenience
86+
`DynamicImage` reimplements all image processing functions.
7587

7688
### The [`GenericImageView`](https://docs.rs/image/*/image/trait.GenericImageView.html) and [`GenericImage`](https://docs.rs/image/*/image/trait.GenericImage.html) Traits
7789

7890
Traits that provide methods for inspecting (`GenericImageView`) and manipulating (`GenericImage`) images, parameterised over the image's pixel type.
7991

8092
### [`SubImage`](https://docs.rs/image/*/image/struct.SubImage.html)
93+
8194
A view into another image, delimited by the coordinates of a rectangle.
8295
The coordinates given set the position of the top left corner of the rectangle.
8396
This is used to perform image processing functions on a subregion of an image.
8497

85-
86-
## The [`ImageDecoder`](https://docs.rs/image/*/image/trait.ImageDecoder.html) and [`ImageDecoderRect`](https://docs.rs/image/*/image/trait.ImageDecoderRect.html) Traits
87-
88-
All image format decoders implement the `ImageDecoder` trait which provide
89-
basic methods for getting image metadata and decoding images. Some formats
90-
additionally provide `ImageDecoderRect` implementations which allow for
91-
decoding only part of an image at once.
92-
93-
The most important methods for decoders are...
94-
+ **dimensions**: Return a tuple containing the width and height of the image.
95-
+ **color_type**: Return the color type of the image data produced by this decoder.
96-
+ **read_image**: Decode the entire image into a slice of bytes.
97-
98-
## Pixels
99-
100-
`image` provides the following pixel types:
101-
+ **Rgb**: RGB pixel
102-
+ **Rgba**: RGB with alpha (RGBA pixel)
103-
+ **Luma**: Grayscale pixel
104-
+ **LumaA**: Grayscale with alpha
105-
106-
All pixels are parameterised by their component type.
107-
10898
## Image Processing Functions
10999

110100
These are the functions defined in the [`imageops`](https://docs.rs/image/latest/image/imageops/index.html) module. All functions operate on types that implement the [`GenericImage`](https://docs.rs/image/latest/image/trait.GenericImage.html) trait.
@@ -129,6 +119,7 @@ Note that some of the functions are very slow in debug mode. Make sure to use re
129119
For more options, see the [`imageproc`](https://crates.io/crates/imageproc) crate.
130120

131121
## Examples
122+
132123
### Opening and Saving Images
133124

134125
`image` provides the [`open`](https://docs.rs/image/latest/image/fn.open.html) function for opening images from a path. The image
@@ -152,6 +143,9 @@ println!("{:?}", img.color());
152143
img.save("test.png").unwrap();
153144
```
154145

146+
The decoder module provides global hooks to register format detection patterns
147+
and as well as other decoder implementations.
148+
155149
### Generating Fractals
156150

157151
```rust,no_run
@@ -205,7 +199,7 @@ Example output:
205199
If the high level interface is not needed because the image was obtained by other means, `image` provides the function [`save_buffer`](https://docs.rs/image/latest/image/fn.save_buffer.html) to save a buffer to a file.
206200

207201
```rust,no_run
208-
let buffer: &[u8] = unimplemented!(); // Generate the image data
202+
let buffer: &[u8] = todo!("your turn, generate data");
209203
210204
// Save the buffer as "image.png"
211205
image::save_buffer("image.png", buffer, 800, 600, image::ExtendedColorType::Rgb8).unwrap()

0 commit comments

Comments
 (0)