> ## 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.

# TrainingImage オブジェクトの SetBitmapBits メソッド

> ABBYY FineReader Engine API の TrainingImage オブジェクトの SetBitmapBits メソッド。メモリ内のバッファから学習用画像データを設定します。画像は等方性で、白黒、1 ピクセルあたり 1 ビットである必要があります（Windows のみ）。

<Warning>
  このメソッドは Linux および macOS では実装されていません
</Warning>

このメソッドは、メモリ内のバッファから学習用画像データを設定します。

画像は等方性である必要があります。つまり、水平方向と垂直方向の解像度が同じでなければなりません。また、1 ピクセルあたり 1 ビットで符号化された白黒画像である必要があります。

画像は、上から下へ行単位で連続してバッファに格納されます。白黒画像の 1 行は、少なくとも N = ceil ( width / 8 ) バイトの並びとして格納されます。各バイトは隣接する 8 ピクセルの色を表し、最初のバイトの最上位ビットがその行の最も左のピクセルに対応します。ビット値 0 は白ピクセル、1 は黒ピクセルを表します。width が 8 の倍数でない場合、N-番目のバイトの下位ビットは無視されます。

<div id="syntax">
  ## 構文
</div>

<div id="c">
  ### C++
</div>

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

### C\#

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

<div id="visual-basic-net">
  ### Visual Basic .NET
</div>

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

<div id="parameters">
  ## パラメーター
</div>

Height

\[in] 学習用画像の高さをピクセル単位で指定します。

Width

\[in] 学習用画像の幅をピクセル単位で指定します。

RawDataPointer

\[in] このパラメーターは、画像データを含むメモリバッファへのハンドルとして扱われます。ハンドルは [\_\_int64](/ja/fine-reader/engine/guided-tour/advanced-techniques/programming-aspects/working-with-properties) 型で渡されます。

<div id="return-values">
  ## 戻り値
</div>

Windows の場合: このメソッドに固有の戻り値はありません。[ABBYY FineReader Engine 関数の標準的な戻り値](/ja/fine-reader/engine/api-reference/return-codes)が返されます。

Linux および macOS の場合: このメソッドは E\_NOTIMPL を返します。

<div id="remarks">
  ## 備考
</div>

対応する [TrainingImage](/ja/fine-reader/engine/api-reference/image-related-objects/trainingimage) オブジェクトが存在している間は、画像データも保持されている必要があります。

<div id="samples">
  ## サンプル
</div>

<Accordion title="C# コード">
  ```csharp theme={null}
  // ビットマップの形式は、FineReader Engine の形式と同じである必要があります。
  // 画像が別の形式の場合は、Image.GetBitmap メソッドを使用できます。
  // 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>

<div id="see-also">
  ## 関連項目
</div>

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