Class ImageBuffer
Represents an unmanaged image buffer for pixel data, providing methods to load, save, and manipulate images.
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.
- PixCount
Gets the total number of pixels in the image.
- Scan0
Gets a pointer to the first scan line of the image, taking into account the stride direction.
- Stride
Gets the number of bytes in a single row (scan line) of the image.
- Width
Gets the width of the image in pixels.
Methods
- Clone()
Creates a deep copy of this image buffer.
- ConvertARGB32()
Creates a new ImageBuffer with pixel data converted to 32-bit ARGB (ARGB32).
- 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).
- 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 byte in the image buffer.
- LoadAsRGB(byte[])
Loads image data from the provided byte array 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.
- 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).