-
-
Notifications
You must be signed in to change notification settings - Fork 2
Remove DynamicTga #16
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
@jamwaffles It would be too early to review this code in detail, but I would appreciate some initial feedback if you think this is going in the right direction. |
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.
I like where this is going so far. The removeal of DynamicTga
is a welcome change to make the API simpler.
src/lib.rs
Outdated
(Bpp::Bits16, false) => ColorType::Rgb555, | ||
(Bpp::Bits24, false) => ColorType::Rgb888, | ||
_ => { | ||
return Err(ParseError::UnsupportedDynamicTgaType( |
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.
More a note to self when I review this proper: This error variant would need renaming too.
33b2932
to
f4dadd2
Compare
The docs could still use some work and they will also need to be updated to intra-doc links, but that could be handled in another PR. I didn't do any thorough benchmarks or binary size comparisons with the old version, but at least compared to |
@jamwaffles Could you also fix the required CI checks when you review this PR? |
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.
Looks good, just one small nit in the changelog.
CHANGELOG.md
Outdated
@@ -6,6 +6,23 @@ | |||
|
|||
## [Unreleased] - ReleaseDate | |||
|
|||
### Added | |||
|
|||
- [#16](https://github.com/embedded-graphics/tinybmp/pull/16) Added `display` example to display TGA images using the embedded-graphics simulator. |
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.
Did we discuss long ago in the e-g repo that changes like this don't make much sense in the changelog?
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.
Yes, we did and I removed the entry from the changelog.
This draft PR is a possible solution to the color type problems we encountered in
tinybmp
. I didn't want to experiment with that project until the open PRs are merged.The fundamental change in this PR is that
Tga
no longer accepts anyC
which has the same BPP as the image. Allowing any color type didn't make sense, because the color format is defined in the header. AC
with the same BPP could represent completely different colors, e.g.Rgb888
andBgr888
.Tga
now behaves very similar to the removedDynamicTga
. TheC
type parameter no longer specifies the format the image is stored in and is instead equal to theDrawTarget
color type. The required bounds are changed toC: PixelColor + From<Gray8> + From<Rgb555> + From<Rgb888>
, which is valid for all e-g color types and isn't hard to implement for custom color types.Tga
will now be easier to use, because it's no longer necessary to specify the color type explicitly, when aTga
object is created.The
ImageDrawable
impl is centered around a modifiedPixels
iterator. The iterator does now have two type parameters, one for the image color type and one for the target color type. This makes it possible to move thematch
statement over the image color type outside the iterator. By converting the colors in the iterator it isn't necessary to usecolor_converted
draw targets, which should help with binary size.To keep the
Tga::pixels
method working a pseudo color typeDynamic
is used. It uses a different implementation of the iterator, which includes thematch
over the color type in thenext
method.TODO:
RawPixels