Repository navigation
Add Dapplo.Windows.Imaging: WIC codec discovery, encode/decode and metadata - #81
Merged
Merged
Conversation
WicCodecs.GetDecoders/GetEncoders ask WIC (IWICImagingFactory::CreateComponentEnumerator) for the codecs, which also reports the built-in and packaged (Store) codecs the registry category key doesn't list. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017qu4NGxUZizEKzrG8d2DGY
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017qu4NGxUZizEKzrG8d2DGY
…es for indexed formats, orientation 5 and 7 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017qu4NGxUZizEKzrG8d2DGY
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017qu4NGxUZizEKzrG8d2DGY
…coder wrote it Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017qu4NGxUZizEKzrG8d2DGY
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017qu4NGxUZizEKzrG8d2DGY
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017qu4NGxUZizEKzrG8d2DGY
|
|
Coverage Report for CI Build 41442041037Coverage increased (+2.4%) to 54.23%Details
Uncovered Changes
Coverage RegressionsNo coverage regressions found. Coverage Stats💛 - Coveralls |
Member
Author
|
The Generated by Claude Code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Robin · project thread
Why
Greenshot needs to know which formats WIC can read and write. The registry key of the WIC decoder category (
HKCR\CLSID\{7ED96837-...}\Instance) lists only 2 of 14 decoders on Windows 11 26300, because the built-in and the packaged (Store) codecs aren't in it. Going through WPF for loading and saving also can't reach every codec (JPEG XL "no imaging component", a NullReferenceException in the HEIF encoder). This adds a new package that uses WIC directly, with no WPF, no System.Drawing and no other pixel library.What
New package Dapplo.Windows.Imaging (net480 and net10.0-windows, references Com and Common):
WicCodecs.GetDecoders(refresh)/GetEncoders(refresh)useIWICImagingFactory::CreateComponentEnumerator.WicCodecInforeports kind, CLSID, container format, vendor, friendly name, author, version, extensions (lower case, with the dot), MIME types and signing status. A codec that can't be read is skipped and logged.WicImage.Encodetakes either a pointer and stride (read through a DapploIWICBitmapSource, so the image isn't copied) or aWicRowProvidercallback (the encoder pulls the rows it needs). Options areImageQuality,Losslessand any encoder option by name; options an encoder doesn't have are skipped.GetEncoderOptionslists what an encoder supports. WIC converts the pixel format when needed, and indexed formats (GIF) get a palette.GetFrameInfo, andDecodeinto caller memory, into memory supplied once the size is known (one pass, e.g. a lockedBitmap), or to aWicRowConsumer.applyOrientationapplies the EXIF orientation viaIWICBitmapFlipRotator.WicCodecNotFoundException(aCOMException) forWINCODEC_ERR_COMPONENTNOTFOUNDandWINCODEC_ERR_COMPONENTINITIALIZEFAILURE. If a stream or callback throws, that exception reaches the caller unchanged.WicMetadataholds all items with friendly paths (/app1/ifd/exif/...; the tag paths work as aliases too), plusTryGet,TryGetRational,Orientation, the ICCColorProfile, and EXIF/XMP/IPTCRawBlocks.WicMetadataWriterhasSet,Remove,SetColorProfileandAddRawBlock. When the encoder doesn't accept something, it is reported inWicEncodeResult.MetadataIssuesand doesn't fail the encode.WicMetadataPathsgives the paths for each container.Streams through a smallIStreamadapter. It works on part of a larger stream, and non-seekable streams go through aMemoryStream. COM objects are created per call and released deterministically, and calls work from STA and MTA threads.Interop: every vtable was checked against
wincodec.idl/wincodec.h/wincodecsdk.h/ocidl.hfrom the Windows SDK. Docs:doc/articles/imaging.mdwith compiled samples (ImagingSamples), plus the codec/path matrix, README, CHANGELOG[3.18.0]andversion.json3.18.Tests
On the CI runner (Windows Server 2025), 0 tests fail on net10 and net48.
WicCodecNotFoundException.The runner has the HEIF and JPEG XL codecs registered, but their encoders fail with
0x88982F8Bthere. SoJpegXl_LosslessRoundTripandHeif_EncodeDecodeare skipped on CI. Please run those two on a machine where the encoders work.Follow-up (not in this PR)
Greenshot: reference the package, replace
WpfFileFormatHandler.RetrieveDecoders()withWicCodecs.GetDecoders(), load and save throughWicImage, and add the DLL tocore-files.iss.Generated by Claude Code