mirror of https://github.com/SixLabors/ImageSharp
3 changed files with 83 additions and 0 deletions
@ -0,0 +1,21 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
using SixLabors.ImageSharp.Memory; |
|||
|
|||
namespace SixLabors.ImageSharp.Formats.Jxl.Processing.RenderPipeline; |
|||
|
|||
internal sealed class SplineStage(Configuration configuration, JxlSplines splines) : RenderPipelineStageBase(configuration) |
|||
{ |
|||
public override string Name => "Splines"; |
|||
|
|||
public override void ProcessRow(Buffer2D<Memory<float>> inputRows, Buffer2D<Memory<float>> outputRows, int xExtraLeft, int xExtraRight, int width, int xPos, int yPos) |
|||
{ |
|||
Span<float> rowX = this.GetInputRow(inputRows, 0, 0, xExtraLeft); |
|||
Span<float> rowY = this.GetInputRow(inputRows, 1, 0, xExtraLeft); |
|||
Span<float> rowB = this.GetInputRow(inputRows, 2, 0, xExtraLeft); |
|||
splines.AddToRow(rowX, rowY, rowB, yPos, xPos - xExtraLeft, xPos + width + xExtraRight); |
|||
} |
|||
|
|||
public override RenderPipelineChannelMode GetChannelMode(int channel) => channel < 3 ? RenderPipelineChannelMode.InPlace : RenderPipelineChannelMode.Ignored; |
|||
} |
|||
@ -0,0 +1,37 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
using SixLabors.ImageSharp.Memory; |
|||
|
|||
namespace SixLabors.ImageSharp.Formats.Jxl.Processing.RenderPipeline; |
|||
|
|||
internal sealed class SpotColorStage(Configuration configuration, int spotColorOffset, Memory<float> spotColor) |
|||
: RenderPipelineStageBase(configuration) |
|||
{ |
|||
private readonly int spotC = 3 + spotColorOffset; |
|||
|
|||
public override string Name => "Spot"; |
|||
|
|||
public override void ProcessRow(Buffer2D<Memory<float>> inputRows, Buffer2D<Memory<float>> outputRows, int xExtraLeft, int xExtraRight, int width, int xPos, int yPos) |
|||
{ |
|||
Span<float> spotColors = spotColor.Span; |
|||
|
|||
float scale = 0; |
|||
for (int c = 0; c < 3; c++) |
|||
{ |
|||
Span<float> p = this.GetInputRow(inputRows, c, 0); |
|||
Span<float> s = this.GetInputRow(inputRows, this.spotC, 0); |
|||
|
|||
for (int x = 0; x < width; x++) |
|||
{ |
|||
float mix = scale * s[x]; |
|||
p[x] = (mix * spotColors[c]) + ((1.0f - mix) * p[x]); |
|||
} |
|||
} |
|||
} |
|||
|
|||
public override RenderPipelineChannelMode GetChannelMode(int channel) |
|||
=> channel < 3 ? RenderPipelineChannelMode.InPlace |
|||
: channel == this.spotC ? RenderPipelineChannelMode.Input |
|||
: RenderPipelineChannelMode.Ignored; |
|||
} |
|||
Loading…
Reference in new issue