Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

rfuest
Copy link
Member

@rfuest rfuest commented Aug 15, 2020

Hi! Thank you for helping out with Embedded Graphics development! Please:

  • Check that you've added passing tests and documentation
  • Add a simulator example(s) where applicable
  • Add a CHANGELOG.md entry in the Unreleased section under the appropriate heading (Added, Fixed, etc) and appropriate crate (embedded-graphics, simulator, tinytga, tinybmp) if your changes affect the public API
  • Run rustfmt on the project
  • Run just build (Linux/macOS only) and make sure it passes. If you use Windows, check that CI passes once you've opened the PR.

PR description

The reason to create this PR was to overhaul the error handing in tinytga. But it grew in scope and now also contains other changes. Sorry for the large monolithic PR.

Overview of the changes:

  • embedded-graphics is now required and the graphics feature is removed.
  • TgaRaw is merged into Tga and can be used by calling Tga::from_slice_raw which creates a Tga<()>.
  • Unknown BPP values don't cause panics anymore and instead from_slice now returns an error.
  • Tga::from_slice now also checks that the bit depth matches the specified e-g color type and returns an error if not.
  • The iterators now handle errors by returning black pixels until the image is complete.
  • A ColorMap struct was added to allow easier access to the color map.
    This currently only supports raw color values and not e-g types, but this will be added later in the dynamic color type PR.
  • raw_developer_dictionary and raw_extension_area replace the TgaFooter type.
    The footer only contained the offset and didn't allow access to the actual data. This could later be extended to parse the areas instead of only returning the raw data.
  • The image ID can now be accessed by the image_id method.
  • To save space in the Tga struct some infrequently used methods parse the header or footer each time they are called.
  • width() and height() were replaced by size from the OriginDimensions trait.
  • IntoIterator was replaced by pixels and raw_pixels.
  • RawPacket and RlePacket are now merged into a single Packet struct that also implements Iterator.
    I hope this makes the code easier to understand.

The docs could use some more polish, but I would like to work on them in the following PR that will implement #424. And the changelog is also missing, which I will add after the first review pass.

Copy link
Member

@jamwaffles jamwaffles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of small doc nits, otherwise this looks great. More elegant code and even more tests is awesome

@rfuest rfuest requested a review from jamwaffles August 16, 2020 13:06
Copy link
Member

@jamwaffles jamwaffles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tiny nit in the changelog, otherwise good to go.

Co-authored-by: James Waples <[email protected]>
@rfuest rfuest merged commit e6afba0 into embedded-graphics:master Aug 16, 2020
@rfuest rfuest deleted the tinytga-panics branch November 9, 2020 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants