-
-
Notifications
You must be signed in to change notification settings - Fork 10
Picturegraphic run length encoding #28
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
5018bbc to
ad02a37
Compare
|
ad02a37 to
d453986
Compare
9b93735 to
d4b03c4
Compare
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.
Pull request overview
This PR implements automatic optimization for picture graphic encoding by intelligently selecting between raw and run-length encoding based on the resulting data size. The implementation builds both encodings during image loading and automatically chooses the smaller one.
- Implements run-length encoding (RLE) algorithm that stores pixel runs as (count, value) pairs
- Adds automatic selection between raw and RLE encoding based on output size comparison
- Displays data size information in the UI to help users understand encoding efficiency
- Improves memory efficiency by using
Cowto avoid unnecessary RGBA8 conversions
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/main.rs | Implements RLE algorithm, automatic encoding selection logic, and refactors image loading to use Cow for better memory efficiency |
| src/object_configuring.rs | Adds data size display label to show the encoded data size in bytes |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "Selected run-length encoding ({} bytes) over raw ({} bytes)", | ||
| o.data.len(), | ||
| raw.len() | ||
| ); | ||
| } else { | ||
| o.data = raw; | ||
| o.options.data_code_type = DataCodeType::Raw; | ||
| log::info!( | ||
| "Selected raw encoding ({} bytes) over run-length ({} bytes)", | ||
| o.data.len(), | ||
| rle.len() | ||
| ); |
Copilot
AI
Dec 30, 2025
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.
The indentation of this log::info! statement is inconsistent. The opening log::info! macro call should align with the surrounding code, and the parameters should be properly indented relative to the macro call.
| "Selected run-length encoding ({} bytes) over raw ({} bytes)", | |
| o.data.len(), | |
| raw.len() | |
| ); | |
| } else { | |
| o.data = raw; | |
| o.options.data_code_type = DataCodeType::Raw; | |
| log::info!( | |
| "Selected raw encoding ({} bytes) over run-length ({} bytes)", | |
| o.data.len(), | |
| rle.len() | |
| ); | |
| "Selected run-length encoding ({} bytes) over raw ({} bytes)", | |
| o.data.len(), | |
| raw.len() | |
| ); | |
| } else { | |
| o.data = raw; | |
| o.options.data_code_type = DataCodeType::Raw; | |
| log::info!( | |
| "Selected raw encoding ({} bytes) over run-length ({} bytes)", | |
| o.data.len(), | |
| rle.len() | |
| ); |
| "Selected run-length encoding ({} bytes) over raw ({} bytes)", | ||
| o.data.len(), | ||
| raw.len() | ||
| ); | ||
| } else { | ||
| o.data = raw; | ||
| o.options.data_code_type = DataCodeType::Raw; | ||
| log::info!( | ||
| "Selected raw encoding ({} bytes) over run-length ({} bytes)", | ||
| o.data.len(), | ||
| rle.len() | ||
| ); |
Copilot
AI
Dec 30, 2025
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.
The indentation of this log::info! statement is inconsistent. The opening log::info! macro call should align with the surrounding code, and the parameters should be properly indented relative to the macro call.
| "Selected run-length encoding ({} bytes) over raw ({} bytes)", | |
| o.data.len(), | |
| raw.len() | |
| ); | |
| } else { | |
| o.data = raw; | |
| o.options.data_code_type = DataCodeType::Raw; | |
| log::info!( | |
| "Selected raw encoding ({} bytes) over run-length ({} bytes)", | |
| o.data.len(), | |
| rle.len() | |
| ); | |
| "Selected run-length encoding ({} bytes) over raw ({} bytes)", | |
| o.data.len(), | |
| raw.len() | |
| ); | |
| } else { | |
| o.data = raw; | |
| o.options.data_code_type = DataCodeType::Raw; | |
| log::info!( | |
| "Selected raw encoding ({} bytes) over run-length ({} bytes)", | |
| o.data.len(), | |
| rle.len() | |
| ); |
Add automatic optimalization if run length encoding option produces smaller data size