# [−][src]Trait image::ImageDecoder

    pub trait ImageDecoder: Sized {
        type Reader: Read;
        fn dimensions(&self) -> (u64, u64);
        fn colortype(&self) -> ColorType;
        fn into_reader(self) -> ImageResult<Self::Reader>;

        fn row_bytes(&self) -> u64 { ... }
        fn total_bytes(&self) -> u64 { ... }
        fn scanline_bytes(&self) -> u64 { ... }
        fn read_image(self) -> ImageResult<Vec<u8>> { ... }
        fn read_image_with_progress<F: Fn(Progress)>(
            self,
            progress_callback: F
        ) -> ImageResult<Vec<u8>> { ... }
    }

The trait that all decoders implement

## Associated Types

### `type Reader: Read`

The type of reader produced by `into_reader`.

Loading content...

## Required methods

### `fn dimensions(&self) -> (u64, u64)`

Returns a tuple containing the width and height of the image

### `fn colortype(&self) -> ColorType`

Returns the color type of the image e.g. RGB(8) (8bit RGB)

### `fn into_reader(self) -> ImageResult<Self::Reader>`

Returns a reader that can be used to obtain the bytes of the image. For the best performance, always try to read at least `scanline_bytes` from the reader at a time. Reading fewer bytes will cause the reader to perform internal buffering.

Loading content...

## Provided methods

### `fn row_bytes(&self) -> u64`

Returns the number of bytes in a single row of the image. All decoders will pad image rows to a byte boundary.

### `fn total_bytes(&self) -> u64`

Returns the total number of bytes in the image.

### `fn scanline_bytes(&self) -> u64`

Returns the minimum number of bytes that can be efficiently read from this decoder. This may be as few as 1 or as many as `total_bytes()`.

### `fn read_image(self) -> ImageResult<Vec<u8>>`

Returns all the bytes in the image.

### `fn read_image_with_progress<F: Fn(Progress)>(
self,
progress_callback: F
) -> ImageResult<Vec<u8>>`

Same as `read_image` but periodically calls the provided callback to give updates on loading progress.

Loading content...

## Implementors

### `impl<R: BufRead> ImageDecoder for HDRAdapter<R>`[src]

#### `type Reader = Cursor<Vec<u8>>`

#### `fn dimensions(&self) -> (u64, u64)`[src]

#### `fn colortype(&self) -> ColorType`[src]

#### `fn into_reader(self) -> ImageResult<Self::Reader>`[src]

#### `fn read_image(self) -> ImageResult<Vec<u8>>`[src]

### `impl<R: Read + Seek> ImageDecoder for BMPDecoder<R>`[src]

#### `type Reader = Cursor<Vec<u8>>`

#### `fn dimensions(&self) -> (u64, u64)`[src]

#### `fn colortype(&self) -> ColorType`[src]

#### `fn into_reader(self) -> ImageResult<Self::Reader>`[src]

#### `fn read_image(self) -> ImageResult<Vec<u8>>`[src]

### `impl<R: Read + Seek> ImageDecoder for ICODecoder<R>`[src]

#### `type Reader = Cursor<Vec<u8>>`

#### `fn dimensions(&self) -> (u64, u64)`[src]

#### `fn colortype(&self) -> ColorType`[src]

#### `fn into_reader(self) -> ImageResult<Self::Reader>`[src]

#### `fn read_image(self) -> ImageResult<Vec<u8>>`[src]

### `impl<R: Read + Seek> ImageDecoder for TGADecoder<R>`[src]

#### `type Reader = TGAReader<R>`

#### `fn dimensions(&self) -> (u64, u64)`[src]

#### `fn colortype(&self) -> ColorType`[src]

#### `fn scanline_bytes(&self) -> u64`[src]

#### `fn into_reader(self) -> ImageResult<Self::Reader>`[src]

#### `fn read_image(self) -> ImageResult<Vec<u8>>`[src]

### `impl<R: Read + Seek> ImageDecoder for TIFFDecoder<R>`[src]

#### `type Reader = Cursor<Vec<u8>>`

#### `fn dimensions(&self) -> (u64, u64)`[src]

#### `fn colortype(&self) -> ColorType`[src]

#### `fn into_reader(self) -> ImageResult<Self::Reader>`[src]

#### `fn read_image(self) -> ImageResult<Vec<u8>>`[src]

### `impl<R: Read> ImageDecoder for DXTDecoder<R>`[src]

#### `type Reader = DXTReader<R>`

#### `fn dimensions(&self) -> (u64, u64)`[src]

#### `fn colortype(&self) -> ColorType`[src]

#### `fn scanline_bytes(&self) -> u64`[src]

#### `fn into_reader(self) -> ImageResult<Self::Reader>`[src]

#### `fn read_image(self) -> ImageResult<Vec<u8>>`[src]

### `impl<R: Read> ImageDecoder for Decoder<R>`[src]

#### `type Reader = Cursor<Vec<u8>>`

#### `fn dimensions(&self) -> (u64, u64)`[src]

#### `fn colortype(&self) -> ColorType`[src]

#### `fn into_reader(self) -> ImageResult<Self::Reader>`[src]

#### `fn read_image(self) -> ImageResult<Vec<u8>>`[src]

### `impl<R: Read> ImageDecoder for JPEGDecoder<R>`[src]

#### `type Reader = Cursor<Vec<u8>>`

#### `fn dimensions(&self) -> (u64, u64)`[src]

#### `fn colortype(&self) -> ColorType`[src]

#### `fn into_reader(self) -> ImageResult<Self::Reader>`[src]

#### `fn read_image(self) -> ImageResult<Vec<u8>>`[src]

### `impl<R: Read> ImageDecoder for PNGDecoder<R>`[src]

#### `type Reader = Cursor<Vec<u8>>`

#### `fn dimensions(&self) -> (u64, u64)`[src]

#### `fn colortype(&self) -> ColorType`[src]

#### `fn into_reader(self) -> ImageResult<Self::Reader>`[src]

#### `fn read_image(self) -> ImageResult<Vec<u8>>`[src]

### `impl<R: Read> ImageDecoder for PNMDecoder<R>`[src]

#### `type Reader = Cursor<Vec<u8>>`

#### `fn dimensions(&self) -> (u64, u64)`[src]

#### `fn colortype(&self) -> ColorType`[src]

#### `fn into_reader(self) -> ImageResult<Self::Reader>`[src]

#### `fn read_image(self) -> ImageResult<Vec<u8>>`[src]

### `impl<R: Read> ImageDecoder for WebpDecoder<R>`[src]

#### `type Reader = Cursor<Vec<u8>>`

#### `fn dimensions(&self) -> (u64, u64)`[src]

#### `fn colortype(&self) -> ColorType`[src]

#### `fn into_reader(self) -> ImageResult<Self::Reader>`[src]

#### `fn read_image(self) -> ImageResult<Vec<u8>>`[src]

Loading content...

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g., `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g., `vec -> usize` or `* -> vec`)

Search multiple things at once by splitting your query with comma (e.g., `str,u8` or `String,struct:Vec,test`)