// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
using System.Diagnostics.CodeAnalysis;
using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp.Drawing.Processing.Backends {
///
/// Canvas frame backed by a .
///
/// The pixel format.
public sealed class MemoryCanvasFrame : ICanvasFrame
where TPixel : unmanaged, IPixel
{
private readonly Buffer2DRegion region;
///
/// Initializes a new instance of the class.
///
/// The pixel buffer region backing this frame.
public MemoryCanvasFrame(Buffer2DRegion region)
{
Guard.NotNull(region.Buffer, nameof(region));
this.region = region;
}
///
public Rectangle Bounds => this.region.Bounds;
///
public bool TryGetCpuRegion(out Buffer2DRegion region)
{
region = this.region;
return true;
}
///
public bool TryGetNativeSurface([NotNullWhen(true)] out NativeSurface? surface)
{
surface = null;
return false;
}
}
}