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

# Image オブジェクトの WriteToFile メソッド

このメソッドは、現在の画像プレーンのコピーを、指定した形式の画像ファイルとして保存します。

## 構文

```vb Visual Basic .NET theme={null}
Sub WriteToFile( _
  FileName As String, _
  Format As ImageFileFormatEnum, _
  Modification As ImageModification, _
  CompressionType As ImageCompressionTypeEnum, _
  extendedParams As Object _
)
```

```cpp C++ theme={null}
HRESULT WriteToFile(
  BSTR                     FileName,
  ImageFileFormatEnum      Format,
  ImageModification*       Modification,
  ImageCompressionTypeEnum CompressionType,
  IUnknown*                extendedParams
);
```

## パラメーター

**FileName**

\[in] このパラメーターには、画像の保存先となる画像ファイルのフルパスを指定します。例: "C:\MyPic.bmp"。このパスにファイルが既に存在する場合は、確認なしで上書きされます。

**Format**

\[in] 出力ファイルの形式を指定する [**ImageFileFormatEnum**](https://docs.abbyy.com/ja/flexi-capture/sdk/api-reference/imagefileformatenum.md) 型の変数です。この列挙型で定義されている形式のすべてが書き込みに対応しているわけではありません。*Format* パラメーターと *CompressionType* パラメーターは相互に関連しています。サポートされている組み合わせの一覧については、[下記](https://docs.abbyy.com/ja/flexi-capture/sdk/api-reference/image-writetofile.md#format-compressiontype-combinations)を参照してください。

**Modification**

\[in] [**ImageModification**](https://docs.abbyy.com/ja/flexi-capture/sdk/api-reference/imagemodification.md) 型のパラメーターで、ファイルに書き込む前に画像に適用する変更を定義します。このパラメーターはオプションで、0 を指定することもできます。その場合、画像には変更が適用されません。

**CompressionType**

\[in] 出力ファイルの圧縮タイプを指定する [**ImageCompressionTypeEnum**](https://docs.abbyy.com/ja/flexi-capture/sdk/api-reference/imagecompressiontypeenum.md) 型の変数です。*Format* パラメーターと *CompressionType* パラメーターは相互に関連しています。TIFF ([IFF\_Tif](https://docs.abbyy.com/ja/flexi-capture/sdk/api-reference/imagefileformatenum.md)) 以外の画像形式では、このパラメーターを ICT\_Default に設定してください。圧縮タイプが自動的に選択されます。TIFF 画像でサポートされている圧縮タイプについては、[下記の表](https://docs.abbyy.com/ja/flexi-capture/sdk/api-reference/image-writetofile.md#format-compressiontype-combinations)を参照してください。

**extendedParams**

\[in] この変数では、画像を JPEG 形式または PNG 形式で保存するためのパラメーターを定義する [**JpegExtendedParams**](https://docs.abbyy.com/ja/flexi-capture/sdk/api-reference/jpegextendedparams.md) オブジェクトまたは [**PngExtendedParams**](https://docs.abbyy.com/ja/flexi-capture/sdk/api-reference/pngextendedparams.md) オブジェクトを参照できます。このパラメーターはオプションで、0 を指定することもできます。その場合、JPEG 画像はロスレス JPEG 2000 圧縮で保存され、PNG 画像は既定のパラメーターで保存されます。

## 戻り値

画像の形式がグレーまたはカラーであるにもかかわらず保存形式が black-and-white の場合、このメソッドは **E\_INVALIDARG** を返します。また、[ABBYY FlexiCapture SDK 関数の標準の戻り値](https://docs.abbyy.com/ja/flexi-capture/sdk/api-reference/errorcodes.md)を返すこともあります。

## 解説

次のテーブルは、TIFF 画像 ([IFF\_Tif](https://docs.abbyy.com/ja/flexi-capture/sdk/api-reference/imagefileformatenum.md)) で *CompressionType* パラメーターに指定できる値を示しています。圧縮方式は、保存する画像のカラーモード ([**IImage::ImageColorType**](https://docs.abbyy.com/ja/flexi-capture/sdk/api-reference/image.md#imagecolortype)) によって異なります。

| **画像のカラーモード** | **CompressionType** |
| - | - |
| black-and-white 画像  ([ICT\_BlackWhite](https://docs.abbyy.com/ja/flexi-capture/sdk/api-reference/imagecolortypeenum.md#ict-blackwhite)) | ICT\_Uncompressed ICT\_CcittGroup4 ICT\_PackBits ICT\_Lzw ICT\_Zip |
| カラー画像 ([ICT\_Color](https://docs.abbyy.com/ja/flexi-capture/sdk/api-reference/imagecolortypeenum.md#ict-color)) 、グレー画像 ([ICT\_Gray](https://docs.abbyy.com/ja/flexi-capture/sdk/api-reference/imagecolortypeenum.md#ict-gray)) | ICT\_Uncompressed ICT\_PackBits ICT\_Jpeg ICT\_Lzw ICT\_Zip |

## 関連項目

[**Image**](https://docs.abbyy.com/ja/flexi-capture/sdk/api-reference/image.md)
