Browse Source

Add IJxlImageOutput

pull/3153/head
winscripter 1 month ago
parent
commit
9ad02108f3
  1. 3
      src/ImageSharp/Formats/Jxl/Processing/Decoder/JxlDecoderCore.cs
  2. 54
      src/ImageSharp/Formats/Jxl/Processing/Image/IJxlImageOutput.cs
  3. 25
      src/ImageSharp/Formats/Jxl/Processing/Primitives/Delegates.cs

3
src/ImageSharp/Formats/Jxl/Processing/Decoder/JxlDecoderCore.cs

@ -1928,8 +1928,7 @@ internal sealed class JxlDecoderCore : ImageDecoderCore, IDisposable
new PixelCallback(
this.imageOutputInitCallback,
this.imageOutputRunCallback,
this.imageOutputDestroyCallback,
this.imageOutputInitOpaque),
this.imageOutputDestroyCallback),
this.imageOutBuffer,
this.imageOutputSize,
dimensions.Width,

54
src/ImageSharp/Formats/Jxl/Processing/Image/IJxlImageOutput.cs

@ -0,0 +1,54 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
using SixLabors.ImageSharp.Formats.Jxl.Processing.Primitives;
namespace SixLabors.ImageSharp.Formats.Jxl.Processing.Image;
/// <summary>
/// Abstracts a way for the codec to output images during decoding.
/// </summary>
internal interface IJxlImageOutput : IDisposable
{
/// <summary>
/// Gets or sets the pixel format for the output pixels.
/// </summary>
public JxlPixelFormat PixelFormat { get; set; }
/// <summary>
/// Gets or sets the output bit depth for unsigned data types.
/// </summary>
public int BitsPerSample { get; set; }
/// <summary>
/// Gets or sets the pixel buffer for image output.
/// </summary>
public Memory<byte> Buffer { get; set; }
/// <summary>
/// Gets or sets length of a row of image buffer in bytes.
/// </summary>
public int Stride { get; set; }
/// <summary>
/// Outputs the image.
/// </summary>
/// <param name="data">Data where the image should be output.</param>
/// <param name="x">X offset</param>
/// <param name="y">Y offset</param>
/// <param name="pixels">Pixels to output.</param>
public void Output(
Span<byte> data,
int x,
int y,
Span<byte> pixels);
/// <summary>
/// Initializes image data.
/// </summary>
/// <param name="data">Output image data.</param>
/// <param name="numPixelsPerThread">Number of pixels a thread processes.</param>
public void Initialize(
Span<byte> data,
int numPixelsPerThread);
}

25
src/ImageSharp/Formats/Jxl/Processing/Primitives/Delegates.cs

@ -1,25 +0,0 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Formats.Jxl.Processing.Primitives;
internal delegate void JxlImageOutputCallback(
Span<byte> data,
int x,
int y,
int numPixels,
Span<byte> pixels);
internal delegate void JxlImageOutputInitializeCallback(
Span<byte> data,
int numThreads,
int numPixelsPerThread);
internal delegate void JxlImageOutputRunCallback(
Span<byte> data,
int x,
int y,
int numPixels,
Span<byte> pixels);
internal delegate void JxlImageOutputDestroyCallback(Span<byte> data);
Loading…
Cancel
Save