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

2-bit icons #41

Open
wants to merge 22 commits into
base: dev
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
65ae2a3
Add simple support for 2 bit icons
MarkusEngsner Mar 17, 2021
b5e8baf
Add support for custom 2 bit coloring
MarkusEngsner Mar 17, 2021
ae64978
Add transparency support to 2 bit drawing
MarkusEngsner Mar 17, 2021
0e88b64
Add tests for Draw2BitIcon()
MarkusEngsner Mar 17, 2021
4be8a03
Update variable naming to adhere to conventions
MarkusEngsner Mar 17, 2021
5cbd1c2
Implement Linear Interpolation for Draw2BitIcon()
MarkusEngsner Mar 19, 2021
9135a15
Add documentation regarding Draw2BitIcon
MarkusEngsner Mar 19, 2021
f0a6c49
Add more efficient color blending implementation
MarkusEngsner Mar 19, 2021
91d6437
Merge pull request #1 from MarkusEngsner/better_alpha_blending
MarkusEngsner Mar 19, 2021
630e857
Remove unused functions, add comments
MarkusEngsner Apr 6, 2021
7cf90a6
Remove unused imports
MarkusEngsner Apr 6, 2021
504dd17
Add debug painter support
MarkusEngsner Apr 6, 2021
c0c67e6
Fix Draw2BitIcon signature
MarkusEngsner Apr 6, 2021
433365f
Fix Draw2BitIcon tests
MarkusEngsner Apr 6, 2021
7eda424
Add Alpha blending tests
MarkusEngsner Apr 6, 2021
9cd654a
Add GetColor() test, fix Draw2BitIcon tests
MarkusEngsner Apr 6, 2021
7cc30ff
Remove unnecessary import
MarkusEngsner Apr 6, 2021
b7ab8d1
Update info file
MarkusEngsner Apr 6, 2021
f48db96
Move AlphaBlend into utils
MarkusEngsner Apr 6, 2021
e4e1329
Move GetColor() into painter, update tests
MarkusEngsner Apr 6, 2021
a4e80a5
Update info file about function placements
MarkusEngsner Apr 6, 2021
29ee014
Remove array import from IPainter.h
MarkusEngsner Apr 6, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update info file
MarkusEngsner committed Apr 6, 2021
commit b7ab8d1df6e8dc1ddf602390b890cef2d045600d
26 changes: 12 additions & 14 deletions GSOC_Draw2BitIcon.md
Original file line number Diff line number Diff line change
@@ -12,38 +12,36 @@ It works for PNGs and SVGs, using CairoSVG and Pillow.
as well as a background color.
It then uses these colors to interpolate color values for pixels
with the values `0x1` and `0x2`.
The interpolation is currently done linearly,
with the fixed values of 0.3 and 0.7 representing `0x1` and `0x2`, respectively.
The interpolation is currently done linearly,
with fixed values representing `0x1` and `0x2`, respectively.


### Implementation

#### Helpers

* `Lerp (Utils.h)`: Linear interpolation between two uint8_t values.
* `LerpColor (Painter.cpp)`: Linear interpolation between two RGB565 colors.
* `Painter::GetPixel (Painter.cpp)`: Helper to get the current color at a point
in the framebuffer. This currenly doesn't do any bounds checking.
* `AlphaBlend (Painter.cpp)`: Linear interpolation between two colors.
* `Painter::GetPixel (Painter.cpp)`: Helper to get the
current color at a point in the framebuffer.
This currenly doesn't do any bounds checking.
* `GetColor (Painter.cpp)`: Maps a 2Bit representation of a Pixel to a color.

I wasn't sure if LerpColor should go in `Utils.h` too,
seeing as it is pretty generic. For now I put it in the `Painter.cpp` file.

#### The function itself

`Draw2BitIcon` iterates over the entire framebuffer, one row at a time.
I choose to diverge slightly from the original implementation of `DrawIcon()`,
which uses two loops for each row.
This does result in defining `currentByte` with the same value 4 times for each byte,
but in return it reduces the complexity by only needing 1 loop per row.
My solution does result in defining `currentByte`
with the same value 4 times for each byte,
but in return it reduces the complexity by only needing 1 loop per row.




### Testing
Tests have been implemented for the `Draw2BitIcon()` function.
Seeing as these tests use the same Interpolation functions,
additional tests should be added for the helpers as well.
Tests have been implemented for the `Draw2BitIcon()` function,
as well as for the helpers.


## Screenshot
![Demo of Draw2BitIcon()](gsoc.png)