Add sk_imagefilter_new_crop C API#261
Merged
Merged
Conversation
Wraps SkImageFilters::Crop(const SkRect& rect, SkTileMode tileMode, sk_sp<SkImageFilter> input). This is the modern replacement for the deprecated cropRect parameter pattern on individual filters. Fixes #3938 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
8e301ae to
ce2dc98
Compare
mattleibow
added a commit
to mono/SkiaSharp
that referenced
this pull request
Jun 24, 2026
Wraps Skia's modern SkImageFilters::Crop(rect, tileMode, input), the replacement for the deprecated cropRect parameter pattern on individual filters. Crop restricts an image filter's output to a rectangle using a tile mode for the area outside the rect. Changes: - C API: sk_imagefilter_new_crop in the skia submodule (mono/skia#261), rebased onto main's skia which includes CreateEmpty (#260) + m150 fixes. - C# wrapper: three CreateCrop overloads (no default parameters) - (rect), (rect, tileMode), (rect, tileMode, input) - with GC.KeepAlive. - Regenerated SkiaApi.generated.cs P/Invoke binding. - Tests validating non-null, null input, blur composition, pixel-level Decal crop rendering, and Decal-vs-Clamp behavioral differences. - ImageFilterCropSample gallery demo with enable toggle, crop sliders, tile mode picker, blur composition, and an aligned crop-rect outline. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
mattleibow
added a commit
to mono/SkiaSharp
that referenced
this pull request
Jun 24, 2026
Wraps Skia's modern SkImageFilters::Crop(rect, tileMode, input), the replacement for the deprecated cropRect parameter pattern on individual filters. Crop restricts an image filter's output to a rectangle using a tile mode for the area outside the rect. Changes: - C API: sk_imagefilter_new_crop in the skia submodule (mono/skia#261), rebased onto main's skia which includes CreateEmpty (#260) + m150 fixes. - C# wrapper: three CreateCrop overloads (no default parameters) - (rect), (rect, tileMode), (rect, tileMode, input) - with GC.KeepAlive. - Regenerated SkiaApi.generated.cs P/Invoke binding. - Tests validating non-null, null input, blur composition, pixel-level Decal crop rendering, and Decal-vs-Clamp behavioral differences. - ImageFilterCropSample gallery demo with enable toggle, crop sliders, tile mode picker, blur composition, and an aligned crop-rect outline. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
mattleibow
added a commit
to mono/SkiaSharp
that referenced
this pull request
Jun 25, 2026
Add SKImageFilter.CreateCrop() (#4229) Closes: #3938 Requires: mono/skia#261 Exposes SkImageFilters::Crop as SKImageFilter.CreateCrop(), the modern replacement for the deprecated per-filter `cropRect` pattern. Crop restricts an image filter's output to a rectangle using a tile mode, and composes with other filters (e.g. blur then crop) instead of every filter carrying its own crop argument. Add three ABI-safe overloads (no default parameters): * CreateCrop(SKRect) - defaults to Decal * CreateCrop(SKRect, SKShaderTileMode) - null input (source) * CreateCrop(SKRect, SKShaderTileMode, SKImageFilter?) - full control The full overload calls sk_imagefilter_new_crop and uses GC.KeepAlive on the input filter to keep it alive across the native call. A null input maps to IntPtr.Zero, which Skia interprets as the source image. * binding/SkiaSharp/SKImageFilter.cs - the three CreateCrop overloads * binding/SkiaSharp/SkiaApi.generated.cs - regenerated P/Invoke binding * externals/skia - bump to pick up mono/skia#261 Tests in SKImageFilterTest.cs go beyond non-null checks and verify behavior: null input is accepted, Crop composes with CreateBlur, Decal leaves pixels outside the crop transparent while Clamp produces a different (edge-extended) result, and a rendering test confirms pixels inside the rect are drawn and those outside are cropped away. ImageFilterCropSample.cs adds an interactive gallery demo with crop bounds sliders, a tile-mode picker, an "Enable Crop" toggle, and an optional blur composition, drawing the crop rect as an overlay so the effect is visible. Co-authored-by: Matthew Leibowitz <mattleibow@live.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Wraps SkImageFilters::Crop(const SkRect& rect, SkTileMode tileMode, sk_sp input).
This is the modern replacement for the deprecated cropRect parameter pattern on individual filters.
Fixes mono/SkiaSharp#3938
Changes
Testing
Tested in mono/SkiaSharp#TBD with comprehensive C# tests.