# ImageSourceAdapter

The abstract class `ImageSourceAdapter` is an abstract class for implementing image fetching and delivering features. 

> [!Note]
> Default implementations:
> - [CameraEnhancer](https://www.dynamsoft.com/camera-enhancer/docs/mobile/programming/flutter/api-reference/camera-enhancer.md): Use the camera as the image source for scanning from the video input.

## Definition

*Assembly:* dynamsoft_capture_vision_flutter

```dart
abstract class ImageSourceAdapter
```

## Methods

| Method | Description |
| ------ | ----------- |
| [`addImageToBuffer`](#addimagetobuffer) | Adds an image to the internal buffer. |
| [`clearBuffer`](#clearbuffer) | Clears all images from the buffer. |
| [`getBufferOverflowProtectionMode`](#getbufferoverflowprotectionmode) | Get the current mode for handling buffer overflow. |
| [`getColourChannelUsageType`](#getcolourchannelusagetype) | Get the current usage type for color channels in images. |
| [`getImage`](#getimage) | Get a buffered image. Implementing classes should return a Promise that resolves with an instance of `ImageData`. |
| [`getMaximumImageCount`](#getmaximumimagecount) | Get the maximum number of images that can be buffered. |
| [`hasImage`](#hasimage) | Checks if an image with the specified ID is present in the buffer. |
| [`setBufferOverflowProtectionMode`](#setbufferoverflowprotectionmode) | Sets the behavior for handling new incoming images when the buffer is full. |
| [`setColourChannelUsageType`](#setcolourchannelusagetype) | Sets the usage type for color channels in images. |
| [`setMaximumImageCount`](#setmaximumimagecount) | Sets the maximum number of images that can be buffered at any time. |
| [`setNextImageToReturn`](#setnextimagetoreturn) | Sets the processing priority of a specific image. This can affect the order in which images are returned by getImage. |
| [`startFetching`](#startfetching) | Start fetching images from the source to the Video Buffer of `ImageSourceAdapter`. |
| [`stopFetching`](#stopfetching) | Stop fetching images from the source to the Video Buffer of `ImageSourceAdapter`. |

### addImageToBuffer

Adds an image to the internal buffer.

```dart
Future<void> addImageToBuffer(ImageData image);
```

### clearBuffer

Clears all images from the buffer.

```dart
Future<void> clearBuffer();
```

### getBufferOverflowProtectionMode


Get the current mode for handling buffer overflow.

```dart
Future<EnumBufferOverflowProtectionMode> getBufferOverflowProtectionMode() async;
```

### getColourChannelUsageType

Get the current usage type for color channels in images.

```dart
Future<EnumColourChannelUsageType> getColourChannelUsageType();
```

### getImage

Get a buffered image. Implementing classes should return a Promise that resolves with an instance of `ImageData`.

```dart
Future<ImageData?> getImage() async;
```

### getMaximumImageCount

Get the maximum number of images that can be buffered.

```dart
Future<int> getMaximumImageCount();
```

### hasImage

Checks if an image with the specified ID is present in the buffer.

```dart
Future<bool> hasImage(int imageId);
```

### setBufferOverflowProtectionMode

Sets the behavior for handling new incoming images when the buffer is full.

```dart
Future<void> setBufferOverflowProtectionMode(EnumBufferOverflowProtectionMode mode);
```

### setColourChannelUsageType

Sets the usage type for color channels in images.

```dart
Future<void> setColourChannelUsageType(EnumColourChannelUsageType type);
```

### setMaximumImageCount

Sets the maximum number of images that can be buffered at any time.

```dart
Future<void> setMaximumImageCount(int count);
```

### setNextImageToReturn

Sets the processing priority of a specific image. This can affect the order in which images are returned by getImage.

```dart
Future<bool> setNextImageToReturn(int imageId, bool keepInBuffer);
```

### startFetching

Start fetching images from the source to the Video Buffer of `ImageSourceAdapter`.

```dart
Future<void> startFetching();
```

### stopFetching

Stop fetching images from the source to the Video Buffer of `ImageSourceAdapter`.

```dart
Future<void> stopFetching();
```

