Skip to content

[feature request] reader_type + type_size #44

@lublak

Description

@lublak

currently there is only "reader_size" which calls "formats::image_type()" which also supports a reader.
So an "reader_type" would be useful.
Another function would also be useful: "type_size(image_type, reader)" if we need both data, so we don't look up the size two times.

/// [`ImageError`]: enum.ImageError.html
pub fn reader_size<R: BufRead + Seek>(mut reader: R) -> ImageResult<ImageSize> {
    dispatch_header(&mut reader)
}

/// Calls the correct image size method based on the image type
///
/// # Arguments
/// * `reader` - A reader for the data
/// * `header` - The header of the file
fn dispatch_header<R: BufRead + Seek>(reader: &mut R) -> ImageResult<ImageSize> {
    match formats::image_type(reader)? {
        ImageType::Aseprite => aesprite::size(reader),
        ImageType::Bmp => bmp::size(reader),
        ImageType::Dds => dds::size(reader),

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions