-
-
Notifications
You must be signed in to change notification settings - Fork 109
Improved error handling for tinytga #430
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
Conversation
There was a problem hiding this 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
Co-authored-by: James Waples <[email protected]>
Co-authored-by: James Waples <[email protected]>
Co-authored-by: James Waples <[email protected]>
There was a problem hiding this 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]>
Hi! Thank you for helping out with Embedded Graphics development! Please:
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 APIrustfmt
on the projectjust 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 thegraphics
feature is removed.TgaRaw
is merged intoTga
and can be used by callingTga::from_slice_raw
which creates aTga<()>
.panic
s anymore and insteadfrom_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.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
andraw_extension_area
replace theTgaFooter
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.
image_id
method.Tga
struct some infrequently used methods parse the header or footer each time they are called.width()
andheight()
were replaced bysize
from theOriginDimensions
trait.IntoIterator
was replaced bypixels
andraw_pixels
.RawPacket
andRlePacket
are now merged into a singlePacket
struct that also implementsIterator
.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.