From ff98ffd0f74778f0abe7b44851e1586490449589 Mon Sep 17 00:00:00 2001 From: winscripter <142818255+winscripter@users.noreply.github.com> Date: Sat, 8 Aug 2026 18:26:07 +0400 Subject: [PATCH] Add image copy operations --- .../Jxl/Processing/JxlImageOperations.cs | 43 ++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/src/ImageSharp/Formats/Jxl/Processing/JxlImageOperations.cs b/src/ImageSharp/Formats/Jxl/Processing/JxlImageOperations.cs index f1b50596f..c62f6a403 100644 --- a/src/ImageSharp/Formats/Jxl/Processing/JxlImageOperations.cs +++ b/src/ImageSharp/Formats/Jxl/Processing/JxlImageOperations.cs @@ -46,6 +46,47 @@ internal static class JxlImageOperations return false; } - + if (!from.IsRectangleInside(rectFrom)) + { + return false; + } + + if (!to.IsRectangleInside(rectTo)) + { + return false; + } + + if (rectFrom.Width == 0) + { + return true; + } + + for (int y = 0; y < rectFrom.Height; y++) + { + Span rowFrom = from.GetRow(rectFrom, y); + Span rowTo = to.GetRow(rectTo, y); + rowFrom.CopyTo(rowTo); + } + + return true; + } + + public static bool CopyImageTo(Rectangle rectFrom, JxlImage3 from, Rectangle rectTo, JxlImage3 to) + where T : unmanaged + { + if (rectFrom != rectTo) + { + return false; + } + + for (int plane = 0; plane < 3; plane++) + { + if (!CopyImageTo(rectFrom, from.Plane(plane), rectTo, to.Plane(plane))) + { + return false; + } + } + + return true; } }