Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Add support for missing SkColorFilters: HSLAMatrix, LinearToSRGBGamma, SRGBToLinearGamma, Lerp, WithWorkingFormat #1775

Open
wieslawsoltes opened this issue Aug 18, 2021 · 1 comment · May be fixed by #2882
Labels
area/SkiaSharp Issues that relate to the C# binding of SkiaSharp.

Comments

@wieslawsoltes
Copy link

Is your feature request related to a problem? Please describe.
When doing svg filters and processing I need additional color filters that are currently missing from SKColorFilter (especially for color space conversion LinearToSRGBGamma() and SRGBToLinearGamma())

Describe the solution you'd like

API proposal (new members in SKColorFilter class):

public static SkiaSharp.SKColorFilter SKColorFilter.CreateHSLAMatrix(float[] rowMajor);
public static SkiaSharp.SKColorFilter SKColorFilter.CreateLinearToSRGBGamma();
public static SkiaSharp.SKColorFilter SKColorFilter.CreateSRGBToLinearGamma();
public static SkiaSharp.SKColorFilter SKColorFilter.CreateLerp(float t, SKColorFilter dst, SKColorFilter src);

nor sure how WithWorkingFormat would look like

Add below API from skia to SKColorFilter

    // A version of Matrix which operates in HSLA space instead of RGBA.
    // I.e. HSLA-to-RGBA(Matrix(RGBA-to-HSLA(input))).
    static sk_sp<SkColorFilter> HSLAMatrix(const SkColorMatrix&);
    static sk_sp<SkColorFilter> HSLAMatrix(const float rowMajor[20]);

    static sk_sp<SkColorFilter> LinearToSRGBGamma();
    static sk_sp<SkColorFilter> SRGBToLinearGamma();
    static sk_sp<SkColorFilter> Lerp(float t, sk_sp<SkColorFilter> dst, sk_sp<SkColorFilter> src);

    // Runs the child filter in a different working color format than usual (premul in
    // destination surface's color space), with all inputs and outputs expressed in this format.
    // Each non-null {tf,gamut,at} parameter overrides that particular aspect of the color format.
    static sk_sp<SkColorFilter> WithWorkingFormat(sk_sp<SkColorFilter>          child,
                                                  const skcms_TransferFunction* tf,
                                                  const skcms_Matrix3x3*        gamut,
                                                  const SkAlphaType*            at);

https://github.com/google/skia/blob/1f193df9b393d50da39570dab77a0bb5d28ec8ef/include/core/SkColorFilter.h#L78-L93

Describe alternatives you've considered

Additional context

@mattleibow mattleibow added this to the v2.88.1 milestone May 22, 2022
@mattleibow mattleibow modified the milestones: v2.88.1, v2.88.x Planning Sep 11, 2022
@wieslawsoltes
Copy link
Author

@mattleibow Any chance on getting that included in near future ?

@wieslawsoltes wieslawsoltes closed this as not planned Won't fix, can't repro, duplicate, stale Oct 27, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Nov 26, 2022
@mattleibow mattleibow removed this from the v2.88.x Planning milestone Apr 30, 2024
@mattleibow mattleibow reopened this Apr 30, 2024
mattleibow added a commit that referenced this issue Jun 1, 2024
@mattleibow mattleibow added the area/SkiaSharp Issues that relate to the C# binding of SkiaSharp. label Jun 1, 2024
mattleibow added a commit that referenced this issue Jun 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/SkiaSharp Issues that relate to the C# binding of SkiaSharp.
Projects
Status: New
Development

Successfully merging a pull request may close this issue.

2 participants