Picturegraphic run length encoding - #28
Conversation
5018bbc to
ad02a37
Compare
|
ad02a37 to
d453986
Compare
9b93735 to
d4b03c4
Compare
There was a problem hiding this comment.
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() | ||
| ); |
There was a problem hiding this comment.
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() | ||
| ); |
There was a problem hiding this comment.
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