# OcrBitmap class

> An 8 bit gray image: rows top to bottom, Width bytes each, 0 black.

Namespace: [PdfNetStack.Ocr](https://www.jadev-corp.com/api/pdfnetstack-ocr/)  
Assembly: PdfNetStack.Ocr.dll  
Package: `PdfNetStack.Ocr`

An 8 bit gray image: rows top to bottom, [Width](https://www.jadev-corp.com/api/pdfnetstack-ocr/ocrbitmap/#PdfNetStack_Ocr_OcrBitmap_Width) bytes each, 0 black.

```csharp
public sealed class OcrBitmap
```

**Inheritance**

[object](https://learn.microsoft.com/dotnet/api/system.object) ← 
[OcrBitmap](https://www.jadev-corp.com/api/pdfnetstack-ocr/ocrbitmap/)

## Constructors

### <a id="PdfNetStack_Ocr_OcrBitmap__ctor_System_Int32_System_Int32_System_Byte___"></a> OcrBitmap\(int, int, byte\[\]\)

Wraps gray pixels.

```csharp
public OcrBitmap(int width, int height, byte[] pixels)
```

#### Parameters

`width` [int](https://learn.microsoft.com/dotnet/api/system.int32)

Width in pixels.

`height` [int](https://learn.microsoft.com/dotnet/api/system.int32)

Height in pixels.

`pixels` [byte](https://learn.microsoft.com/dotnet/api/system.byte)\[\]

Width times height bytes.

#### Exceptions

 [ArgumentException](https://learn.microsoft.com/dotnet/api/system.argumentexception)

The pixel count does not match the size.

## Properties

### <a id="PdfNetStack_Ocr_OcrBitmap_Height"></a> Height

Height in pixels.

```csharp
public int Height { get; }
```

#### Property Value

 [int](https://learn.microsoft.com/dotnet/api/system.int32)

### <a id="PdfNetStack_Ocr_OcrBitmap_Pixels"></a> Pixels

The pixels, one byte each.

```csharp
public byte[] Pixels { get; }
```

#### Property Value

 [byte](https://learn.microsoft.com/dotnet/api/system.byte)\[\]

### <a id="PdfNetStack_Ocr_OcrBitmap_Width"></a> Width

Width in pixels.

```csharp
public int Width { get; }
```

#### Property Value

 [int](https://learn.microsoft.com/dotnet/api/system.int32)

## Methods

### <a id="PdfNetStack_Ocr_OcrBitmap_FromPdfBitmap_PdfNetStack_PdfBitmap_"></a> FromPdfBitmap\(PdfBitmap\)

Gray from a decoded PDF image: RGB is weighed by luma (ITU-R BT.601).

```csharp
public static OcrBitmap FromPdfBitmap(PdfBitmap bitmap)
```

#### Parameters

`bitmap` [PdfBitmap](https://www.jadev-corp.com/api/pdfnetstack/pdfbitmap/)

The decoded image.

#### Returns

 [OcrBitmap](https://www.jadev-corp.com/api/pdfnetstack-ocr/ocrbitmap/)

## Used in

- [Make scanned PDFs searchable with OCR in C#](https://www.jadev-corp.com/guides/ocr/)

Source: https://www.jadev-corp.com/pdfnetstack/api/pdfnetstack-ocr/ocrbitmap/
