Skip to content

Conversation

@GwnDaan
Copy link
Member

@GwnDaan GwnDaan commented Dec 21, 2025

Add automatic optimalization if run length encoding option produces smaller data size

@GwnDaan GwnDaan force-pushed the daan/run-length-encoding branch from 5018bbc to ad02a37 Compare December 21, 2025 18:56
@github-actions
Copy link

github-actions bot commented Dec 21, 2025

PR Preview Action v1.8.0
Preview removed because the pull request was closed.
2026-01-01 13:26 UTC

@GwnDaan GwnDaan force-pushed the daan/run-length-encoding branch from ad02a37 to d453986 Compare December 21, 2025 19:04
Copilot AI review requested due to automatic review settings December 30, 2025 11:28
@GwnDaan GwnDaan force-pushed the daan/run-length-encoding branch from 9b93735 to d4b03c4 Compare December 30, 2025 11:28
Copy link

Copilot AI left a 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 Cow to 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.

Comment on lines +263 to +274
"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()
);
Copy link

Copilot AI Dec 30, 2025

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.

Suggested change
"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 uses AI. Check for mistakes.
Comment on lines +263 to +274
"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()
);
Copy link

Copilot AI Dec 30, 2025

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.

Suggested change
"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 uses AI. Check for mistakes.
@GwnDaan GwnDaan merged commit 830a746 into main Jan 1, 2026
27 checks passed
@GwnDaan GwnDaan deleted the daan/run-length-encoding branch January 3, 2026 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants