Table of Contents

Class PdfBitmap

Namespace
nebulae.dotPDFium
Assembly
dotPDFium.dll

The PdfBitmap class represents a bitmap image in the PDFium library. It provides methods to create and manipulate bitmap images from PDF pages.

public class PdfBitmap : PdfObject, IDisposable
Inheritance
PdfBitmap
Implements
Inherited Members

Properties

Buffer

Gets a pointer to the memory buffer containing the raw image data of the PDF bitmap.

public nint Buffer { get; }

Property Value

nint

Remarks

The buffer is managed by the underlying PDF rendering library and should not be modified or freed by the caller. The caller is responsible for ensuring the associated bitmap handle remains valid while accessing the buffer.

Format

Gets the format of the bitmap, which indicates the color depth and pixel format.

public PdfBitmapFormat Format { get; }

Property Value

PdfBitmapFormat

Height

Returns the height of the bitmap in pixels.

public int Height { get; }

Property Value

int

Stride

Gets the stride of the bitmap, which is the number of bytes in a row of pixel data.

public int Stride { get; }

Property Value

int

Width

Returns the width of the bitmap in pixels.

public int Width { get; }

Property Value

int

Methods

Create(int, int, bool)

Creates a new bitmap with the specified width, height, and alpha channel support.

public static PdfBitmap Create(int width, int height, bool alpha = true)

Parameters

width int

The width of the bitmap in pixels

height int

The height of the bitmap in pixels

alpha bool

Whether or not the bitmap should support an alpha channel (transparency)

Returns

PdfBitmap

a new PdfBitmap

Exceptions

dotPDFiumException

Throws on PDFium library error

CreateEx(int, int, PdfBitmapFormat, nint, int)

Create a bitmap with the specified width, height, format, buffer, and stride.

public static PdfBitmap CreateEx(int width, int height, PdfBitmapFormat format, nint buffer, int stride)

Parameters

width int

The width of the bitmap in pixels

height int

The height of the bitmap in pixels

format PdfBitmapFormat

The format of the bitmap

buffer nint

The buffer for the newly created bitmap

stride int

The stride of the new bitmap (width of a row)

Returns

PdfBitmap

a new PdfBitmap object whose buffer is user-controlled

Exceptions

dotPDFiumException

Dispose(bool)

Dispose method. This method is protected and should not be used directly.

protected override void Dispose(bool disposing)

Parameters

disposing bool

FillRect(int, int, int, int, uint)

Fills a rectangle in the bitmap with the specified color.

public void FillRect(int left, int top, int width, int height, uint color)

Parameters

left int

The left pixel parameter of the origin of the rectangle

top int

The top pixel parameter of the origin of the rectangle

width int

The width parameter of the rectangle in pixels

height int

The height parameter of the rectangle in pixels

color uint

The color to use to fill the rectangle