Browse Source

Add rectangle support to images

This massively reduces number of syntax errors
pull/3153/head
winscripter 4 weeks ago
parent
commit
4d0a468639
  1. 7
      src/ImageSharp/Formats/Jxl/Memory/JxlImage3{T}.cs
  2. 11
      src/ImageSharp/Formats/Jxl/Memory/JxlPlane{T}.cs

7
src/ImageSharp/Formats/Jxl/Memory/JxlImage3{T}.cs

@ -46,6 +46,13 @@ internal class JxlImage3<T> : IDisposable
return rowSpan;
}
public Span<T> PlaneRow(Rectangle rectangle, int c, int y)
{
DebugGuard.MustBeGreaterThanOrEqualTo(y + rectangle.Top, 0, nameof(y));
return this.PlaneRow(c, y + rectangle.Top)[rectangle.Left..];
}
public JxlPlane<T> Plane(int index) => this.planes[index];
public void Swap(JxlImage3<T> other)

11
src/ImageSharp/Formats/Jxl/Memory/JxlPlane{T}.cs

@ -36,6 +36,17 @@ internal class JxlPlane<T> : JxlPlaneBase
public Span<T> GetRow(int y) => this.GetRowBase<T>(y);
public Span<T> GetRow(Rectangle rectangle, int y)
{
DebugGuard.MustBeGreaterThanOrEqualTo(y + rectangle.Top, 0, nameof(y));
return this.GetRow(y + rectangle.Top)[rectangle.Left..];
}
public bool IsRectangleInside(Rectangle rectangle) => rectangle.Contains(this.GetRectangle());
public Rectangle GetRectangle() => new(0, 0, this.XSize, this.YSize);
/// <summary>
/// Fills everything in this image with 0.
/// </summary>

Loading…
Cancel
Save