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

# OpenImageFileFromMemory Method of the Engine Object

This method opens an image file from the global memory, where it was previously loaded by the user.

## Syntax

### C++

#### Linux and macOS

```cpp theme={null}
HRESULT OpenImageFileFromMemory(
  void*                   DataPtr,
  __int64                 DataSize,
  IImagePasswordCallback* Callback,
  IPrepareImageMode*      PrepareMode,
  BSTR                    FileName
  IImageDocument**        Result
);
```

#### Windows

```cpp theme={null}
HRESULT OpenImageFileFromMemory(
  __int64                 HGlobal,
  IImagePasswordCallback* Callback,
  IPrepareImageMode*      PrepareMode,
  BSTR                    FileName
  IImageDocument**        Result
);
```

### C\#

```csharp theme={null}
IImageDocument OpenImageFileFromMemory(
  Int64                   HGlobal,
  IImagePasswordCallback  Callback,
  IPrepareImageMode       PrepareMode,
  string                  FileName
);
```

### Visual Basic .NET

```vb theme={null}
Function OpenImageFileFromMemory( _
  HGlobal As Int64, _
  Callback As IImagePasswordCallback, _
  [PrepareMode As IPrepareImageMode = Nothing], _
  [FileName As String = "0"] _
) As IImageDocument
```

## Parameters

DataPtr

\[in] Linux: Specifies the address of the memory block which contains the image file.

DataSize

\[in] Linux: Specifies the size of the image loaded into memory.

HGlobal

\[in] macOS and Windows: Specifies the HGLOBAL handle of the memory block which contains the image file. The handle is passed as [\_\_int64](/fine-reader/engine/guided-tour/advanced-techniques/programming-aspects/working-with-properties). This handle should be valid.

Callback

\[in] This variable refers to the interface of the user-implemented object of the type [ImagePasswordCallback](/fine-reader/engine/api-reference/image-related-objects/iimagepasswordcallback) which is used to handle possible password requests for accessing images in PDF format. This parameter is optional and may be 0, in which case password-protected files cannot be processed.

PrepareMode

\[in] Refers to the [PrepareImageMode](/fine-reader/engine/api-reference/image-related-objects/prepareimagemode) object which specifies how an image will be preprocessed during opening. This parameter is optional and may be 0, in which case either the default parameters are used, or, if a [profile](/fine-reader/engine/guided-tour/advanced-techniques/working-with-profiles) has been loaded, the parameters set by this profile are used.

FileName

\[in] Specifies the name of the image file. This information is used to define the format of the file, and in error messages. This parameter is optional and may be 0.

Result

\[out, retval] A pointer to IImageDocument\* pointer variable that receives the interface pointer of the resulting [ImageDocument](/fine-reader/engine/api-reference/image-related-objects/imagedocument) object.

## Return values

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

## Remarks

* Notice that for multi-page image files, the ImageDocument object will be created only from the first page. To open all pages of the file, use the [AddImageFileFromMemory](/fine-reader/engine/api-reference/document-related-objects/frdocument/addimagefilefrommemory-method) method of the [FRDocument](/fine-reader/engine/api-reference/document-related-objects/frdocument) object.
* This method does not work if the Engine is loaded as an out-of-process server in Linux or if the object is created using the [OutprocLoader](/fine-reader/engine/api-reference/engine-loaders/outprocloader) object in Windows.
* In Windows, this method does not support WIC-compatible files opening.

## See also

[Engine](/fine-reader/engine/api-reference/engine-object-iengine-interface)

[IFRDocument::AddImageFileFromMemory](/fine-reader/engine/api-reference/document-related-objects/frdocument/addimagefilefrommemory-method)
