> ## Documentation Index
> Fetch the complete documentation index at: https://docs.abbyy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# SetBitmapBits Method of the TrainingImage Object

<Warning>
  This method is not implemented for Linux and macOS
</Warning>

This method sets the training image data from the buffer in memory.

The image should be isotropic (that is its horizontal resolution should be equal to the vertical one), black-and-white with 1 bit per pixel encoding.

Image is stored in buffer continuously, line-by-line, from top to bottom. One line of black-and-white image is stored as a sequence of at least N = ceil ( width / 8 ) bytes. Each byte encodes colors of 8 adjacent pixels, most significant bit of the first byte corresponds to leftmost pixel of the line. Bit value of 0 denotes white pixel, value of 1 denotes black pixel. If width is not a multiple of 8, least significant bits of N-th byte are ignored.

## Syntax

### C++

```cpp theme={null}
HRESULT SetBitmapBits(
  int     Height,
  int     Width,
  __int64 RawDataPointer
);
```

### C\#

```csharp theme={null}
void SetBitmapBits(
  int   Height,
  int   Width,
  Int64 RawDataPointer
);
```

### Visual Basic .NET

```vb theme={null}
Sub SetBitmapBits( _
  Height As Integer, _
  Width As Integer, _
  RawDataPointer As Int64 _
)
```

## Parameters

Height

\[in] Specifies the height of the training image in pixels.

Width

\[in] Specifies the width of the training image in pixels.

RawDataPointer

\[in] This parameter is treated as a handle to memory buffer containing image data. The handle is passed as [\_\_int64](/fine-reader/engine/guided-tour/advanced-techniques/programming-aspects/working-with-properties).

## Return values

For Windows: This method has no specific return values. It returns the [standard return values of ABBYY FineReader Engine functions](/fine-reader/engine/api-reference/return-codes).

For Linux and macOS: This method returns E\_NOTIMPL.

## Remarks

The image data should exist while the corresponding [TrainingImage](/fine-reader/engine/api-reference/image-related-objects/trainingimage) object exists.

## Samples

<Accordion title="C# code">
  ```csharp theme={null}
  // The format of the bitmap should be the same as in FineReader Engine.
  // If an image is in another format, you can use Image.GetBitmap method.
  // IntPtr hBitmap = document.Pages[0].ImageDocument.BlackWhiteImage.GetBitmap(null).Handle;
  // Bitmap bitmap = new Bitmap( Image.FromHbitmap( hBitmap ) );
  Bitmap bitmap = new Bitmap(imagePath);
  Rectangle imageRect = new Rectangle(0, 0, bitmap.Size.Width, bitmap.Size.Height);
  System.Drawing.Imaging.BitmapData data = bitmap.LockBits(imageRect, System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format1bppIndexed);
  FREngine.ITrainingImage trainingImage = engineLoader.Engine.CreateTrainingImage();
  trainingImage.SetBitmapBits(bitmap.Size.Height, bitmap.Size.Width, data.Scan0.ToInt64());
  ```
</Accordion>

## See also

[TrainingImage](/fine-reader/engine/api-reference/image-related-objects/trainingimage)
