Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API overhaul #40

Open
birktj opened this issue Apr 23, 2019 · 0 comments
Open

API overhaul #40

birktj opened this issue Apr 23, 2019 · 0 comments
Labels
enhancement New feature or request

Comments

@birktj
Copy link
Member

birktj commented Apr 23, 2019

I think that the current api of this crate is sort of messy and a overhaul would be nice. I think this crate should be structured for two use cases: a low-level usage of the tiff format with direct control over tags and data and a mid-level baseline tiff implementation with access to properties specified by baseline tiff (and possibly some more). The high-level use case should be covered by the image crate.

Two things that I think would improve the api a lot would be to reorganize all the small helper types so that they fit together well with both the decoder and encoder and clean up decoder api.

I propose something like this for the decoding api:

impl TiffDecoder<R> {
    fn new(...) {...}

    fn next_directory<'a>(&'a mut self) -> TiffResult<Option<Directory<'a>>> {...}
    fn prev_directory<'a>(&'a mut self) -> TiffResult<Option<Directory<'a>>> {...}

    fn next_image<'a>(&'a mut self) -> TiffResult<Option<Image<'a>>> {...}
    fn prev_image<'a>(&'a mut self) -> TiffResult<Option<Image<'a>>> {...}
}

impl DirectoryDecoder {
    fn read_tag(&mut self, tag: Tag) -> Entry {...}
    fn read_data<T: TiffValue>(&mut self, offset: u32, buffer: &mut T) -> TiffResult<()> {...}
}

impl ImageDecoder {
    fn width(&self) -> u32 {...}
    fn height(&self) -> u32 {...}
    fn pixel_format(&self) -> PixelFormat {...}

    fn read_strip(&mut self) -> DecodingResult {...} // ???
    fn reader<'a>(&'a mut self) -> Reader<'a> {...}

    fn resolution_unit(&mut self) -> ResolutionUnit {...}
    fn x_resolution(&self) -> Rational {...}
    fn y_resolution(&self) -> Rational {...}
    // Other baseline tiff properties  ...
}
@birktj birktj added the enhancement New feature or request label Apr 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant