Skip to content

Support 16bit output from Local contrast&brightness - #84

Merged
meesoft merged 3 commits into
mainfrom
features/Export16bit
Jul 14, 2026
Merged

Support 16bit output from Local contrast&brightness#84
meesoft merged 3 commits into
mainfrom
features/Export16bit

Conversation

@meesoft

@meesoft meesoft commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features

    • Added conversion to 16-bit output for processed float bitmap data (16-bit grayscale and 16-bit RGB).
    • Output now automatically selects 16-bit for compatible formats (PNG, TIFF, JXR, and qualifying JPEG XL); applies to video averaging results as well.
    • Local contrast can now be saved at the appropriate bit depth.
  • Bug Fixes

    • Saving processed images now uses the newly generated result image instead of the preview.
    • Improved local contrast preview robustness by handling update errors and reporting them.
  • Tests

    • Added coverage for 16-bit bitmap source generation.

@meesoft
meesoft marked this pull request as ready for review July 13, 2026 18:35
@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 15aacfd2-aaa1-4205-9570-2601357ee9f7

📥 Commits

Reviewing files that changed from the base of the PR and between 8fe65e8 and 3159ab7.

📒 Files selected for processing (2)
  • PhotoLocator/ImageTransformCommands.cs
  • PhotoLocator/LocalContrastViewModel.cs
🚧 Files skipped from review as they are similar to previous changes (1)
  • PhotoLocator/ImageTransformCommands.cs

Walkthrough

FloatBitmap now creates 16-bit bitmap sources, and format-aware output selection is shared by local-contrast and averaged-video saving. Local-contrast saving generates the appropriate result bitmap instead of directly saving the preview, with preview-update errors handled explicitly.

Changes

16-bit output pipeline

Layer / File(s) Summary
16-bit bitmap conversion and validation
PhotoLocator/BitmapOperations/FloatBitmap.cs, PhotoLocatorTest/BitmapOperations/FloatBitmapTest.cs
Adds gamma-corrected, clamped 16-bit conversion for grayscale and RGB float buffers, with dimension and pixel-format tests.
Format-aware local-contrast result selection
PhotoLocator/PictureFileFormats/GeneralFileFormatHandler.cs, PhotoLocator/LocalContrastViewModel.cs, PhotoLocator/ImageTransformCommands.cs
Centralizes extension-based 16-bit decisions, generates the local-contrast result during saving, and handles preview update exceptions.
Averaged-video output selection
PhotoLocator/VideoTransformCommands.cs
Uses the shared format helper when selecting 16-bit averaged-processing output.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant SaveProcessedImageAsync
  participant GeneralFileFormatHandler
  participant LocalContrastViewModel
  participant BitmapSource
  SaveProcessedImageAsync->>GeneralFileFormatHandler: Check output format
  GeneralFileFormatHandler-->>SaveProcessedImageAsync: Return 16-bit decision
  SaveProcessedImageAsync->>LocalContrastViewModel: Get result image
  LocalContrastViewModel->>BitmapSource: Convert destination bitmap when 16-bit
  BitmapSource-->>SaveProcessedImageAsync: Return bitmap source
Loading

Possibly related PRs

  • meesoft/PhotoLocator#23: Refactors the local-contrast image-loading and batch-saving flow related to SaveProcessedImageAsync.
  • meesoft/PhotoLocator#56: Extends the LocalContrastViewModel preview pipeline with histogram computation using FloatBitmap helpers.
  • meesoft/PhotoLocator#80: Adds an astro-stretch stage that changes the local-contrast destination bitmap used for generated output.
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding 16-bit output support for local contrast and brightness processing.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch features/Export16bit

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
PhotoLocatorTest/BitmapOperations/FloatBitmapTest.cs (1)

120-143: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Assert the converted 16-bit pixel values.

This test verifies only dimensions and format, so it would pass if conversion wrote incorrect values. Add assertions for gamma mapping plus clamping to 0 and ushort.MaxValue; also cover the unsupported-plane exception.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@PhotoLocatorTest/BitmapOperations/FloatBitmapTest.cs` around lines 120 - 143,
Extend ToBitmapSource16_ShouldCreateBitmapSource to inspect converted 16-bit
pixel values, asserting the expected gamma-mapped result and clamping behavior
at 0 and ushort.MaxValue. Add test coverage for an unsupported plane count and
verify the expected exception is thrown, while preserving the existing dimension
and format assertions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@PhotoLocator/LocalContrastViewModel.cs`:
- Around line 579-584: Update the produce16bitOutput branch in the local
contrast result flow to check the destination bitmap’s plane count before
calling ToBitmapSource16. For unsupported counts such as CMYK’s four planes,
return PreviewPictureSource instead, while preserving 16-bit export for
supported one- and three-plane results.

---

Nitpick comments:
In `@PhotoLocatorTest/BitmapOperations/FloatBitmapTest.cs`:
- Around line 120-143: Extend ToBitmapSource16_ShouldCreateBitmapSource to
inspect converted 16-bit pixel values, asserting the expected gamma-mapped
result and clamping behavior at 0 and ushort.MaxValue. Add test coverage for an
unsupported plane count and verify the expected exception is thrown, while
preserving the existing dimension and format assertions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: e0c9961a-15ff-4ebb-9088-6b32df611a41

📥 Commits

Reviewing files that changed from the base of the PR and between 550e2e9 and 8fe65e8.

📒 Files selected for processing (6)
  • PhotoLocator/BitmapOperations/FloatBitmap.cs
  • PhotoLocator/ImageTransformCommands.cs
  • PhotoLocator/LocalContrastViewModel.cs
  • PhotoLocator/PictureFileFormats/GeneralFileFormatHandler.cs
  • PhotoLocator/VideoTransformCommands.cs
  • PhotoLocatorTest/BitmapOperations/FloatBitmapTest.cs

Comment thread PhotoLocator/LocalContrastViewModel.cs
@meesoft
meesoft merged commit e54c0ab into main Jul 14, 2026
5 checks passed
@meesoft
meesoft deleted the features/Export16bit branch July 14, 2026 20:48
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.

1 participant