Class ImageBuffer
Represents an unmanaged image buffer for pixel data, providing high-performance methods to load, save, convert, and manipulate images. This type owns a native handle and must be disposed to release unmanaged resources.
public sealed class ImageBuffer : IDisposable- Inheritance
- 
      
      ImageBuffer
- Implements
- Inherited Members
Properties
- Buffer
- Gets a pointer to the raw pixel buffer. 
- BufferLength
- Gets the total length, in bytes, of the pixel buffer. 
- Format
- Gets the pixel format of the image. 
- Height
- Gets the height of the image in pixels. 
- HorizontalResolution
- Gets the horizontal resolution (DPI) stored in the image metadata. 
- PixCount
- Gets the total number of pixels in the image. 
- Scan0
- Gets a pointer to the first logical scan line (top row) of the image, taking into account the stride direction. 
- Stride
- Gets the number of bytes in a single row (scan line) of the image. 
- VerticalResolution
- Gets the vertical resolution (DPI) stored in the image metadata. 
- Width
- Gets the width of the image in pixels. 
Methods
- Clone()
- Creates a deep copy of this image buffer. 
- ConvertGRAY8()
- Creates a new ImageBuffer with pixel data converted to 8-bit grayscale (GRAY8). 
- ConvertRGB24()
- Creates a new ImageBuffer with pixel data converted to 24-bit RGB (RGB24). 
- ConvertRGBA32()
- Creates a new ImageBuffer with pixel data converted to 32-bit ARGB (RGBA32). 
- CropAuto(int, byte)
- Automatically crops uniform borders from the image by scanning from each edge until a pixel differs from the border color, then returns the cropped buffer. The border color is sampled from the corners with a simple majority/consensus, improving robustness over single-pixel sampling. 
- Deskew(DeskewParameters)
- Estimates page skew and, if significant, returns a new image with rotation correction applied. 
- Dispose()
- Releases all resources used by this ImageBuffer. 
- GetScanLine(int)
- Returns a pointer to the beginning of the specified scan line. 
- Invert()
- Inverts each pixel component in the image buffer. 
- IsBlank(byte)
- Determines whether the image is blank (all pixels have the same or similar values within a tolerance). 
- LoadAsRGB(byte[])
- Loads image data from the provided byte array and returns a new ImageBuffer in RGB24 format. 
- LoadAsRGB(ReadOnlyMemory<byte>)
- Loads image data from the provided memory block and returns a new ImageBuffer in RGB24 format. 
- LoadAsRGB(ReadOnlySpan<byte>)
- Loads image data from the provided span and returns a new ImageBuffer in RGB24 format. 
- LoadAsRGB(string)
- Loads an image from the given file path, applies any necessary path fixes, and returns a new ImageBuffer in RGB24 format. 
- Resize(int, int)
- Resizes the image to the specified dimensions, without preserving the aspect ratio. 
- ResizeBox(int, int, Color32)
- Resizes the image to fit within the specified box, adding padding with the given background color to preserve aspect ratio. 
- Rotate(int)
- Rotates the image by the specified angle. Only 90, 180 or 270 degrees clockwise are supported. 
- SaveAsBmp(string)
- Saves the image to a BMP file at the specified path. 
- SaveAsPng(string, int)
- Saves the image to a PNG file at the specified path, using the given compression level. 
- SetResolution(float)
- Sets both horizontal and vertical resolution to the same DPI value. 
- SetResolution(float, float)
- Sets the horizontal and vertical resolution (DPI) metadata for the image. 
- TryDetectBorderBackgroundColor(out Color32, float)
- Attempts to estimate a uniform background color by analyzing only the image border (top and bottom rows, and left/right columns).