ImageSourceAdapter
The ImageSourceAdapter class provides an class for fetching and buffering images. It is an abstract class that needs to be implemented by a concrete class to provide actual functionality.
Note: Subclasses inheriting from this class must ensure that the parent class constructor (
super()) is properly called to guarantee correct initialization.
Definition
Package: com.dynamsoft.core.basic_structures
public abstract class ImageSourceAdapter
Methods
| Method | Description |
|---|---|
addImageToBuffer |
Adds an image to the buffer of the adapter. |
hasNextImageToFetch |
Determines whether there are more images left to fetch. |
startFetching |
Starts fetching images. |
stopFetching |
Stops fetching images. |
getImage |
Returns a buffered image. |
setMaxImageCount |
Sets how many images are allowed to be buffered. |
getMaxImageCount |
Returns how many images can be buffered. |
setBufferOverflowProtectionMode |
Sets a mode that determines the action to take when there is a new incoming image and the buffer is full. |
getBufferOverflowProtectionMode |
Returns the current buffer overflow protection mode. |
hasImage |
Determines whether the image is in the buffer or not. |
setNextImageToReturn |
Sets the next image to return. |
getImageCount |
Returns the actual count of buffered images. |
isBufferEmpty |
Determines whether the buffer is empty. |
clearBuffer |
Clears the image buffer. |
setColourChannelUsageType |
Sets the usage type of a color channel in an image. |
getColourChannelUsageType |
Gets the usage type of a color channel in an image. |
setErrorListener |
Sets the error listener for the image source. |
addImageToBuffer
Adds an image to the buffer of the adapter.
void addImageToBuffer(ImageData img)
Parameters
img The image to be added to the buffer.
See Also
hasNextImageToFetch
Determines whether there are more images left to fetch.
public abstract boolean hasNextImageToFetch()
Return Value
Returns true if there are more images left to fetch, false otherwise. This function must be implemented in the subclass.
startFetching
Starts fetching images.
void startFetching()
stopFetching
Stops fetching images.
void stopFetching()
getImage
Returns a buffered image.
ImageData getImage()
Return Value
Returns an image if it exists in the buffer, null otherwise.
See Also
setMaxImageCount
Sets how many images are allowed to be buffered.
void setMaxImageCount(int count)
Parameters
count The maximum number of images that can be buffered.
getMaxImageCount
Returns how many images can be buffered.
int getMaxImageCount()
Return Value
Returns the maximum number of images that can be buffered.
setBufferOverflowProtectionMode
Sets a mode that determines the action to take when there is a new incoming image and the buffer is full.
void setBufferOverflowProtectionMode(@EnumBufferOverflowProtectionMode int mode)
Parameters
mode The buffer overflow protection mode to set.
See Also
EnumBufferOverflowProtectionMode
getBufferOverflowProtectionMode
Returns the current buffer overflow protection mode.
@EnumBufferOverflowProtectionMode int getBufferOverflowProtectionMode()
Return Value
Returns the current buffer overflow protection mode.
See Also
EnumBufferOverflowProtectionMode
hasImage
Determines whether the image is in the buffer or not.
boolean hasImage(int imageId)
Parameters
imageId The ID of the image to check.
Return Value
Returns true if the image is in the buffer, false otherwise.
setNextImageToReturn
Sets the next image to return.
boolean setNextImageToReturn(int imageId, boolean keepInBuffer)
Parameters
imageId The ID of the next image to return.
keepInBuffer Whether the image should be retained in the buffer, even if the buffer is full and the image needs to be updated based on the BufferOverflowProtectionMode parameter.
Return Value
Returns true if the image is in the buffer and is set as the next image to return, false otherwise.
getImageCount
Returns the actual count of buffered images.
int getImageCount()
Return Value
Returns the actual count of buffered images.
isBufferEmpty
Determines whether the buffer is empty.
boolean isBufferEmpty()
Return Value
Returns true if the buffer is empty, false otherwise.
clearBuffer
Clear the image buffer.
void clearBuffer()
setColourChannelUsageType
Sets the usage type of a color channel in images.
void setColourChannelUsageType(@EnumColourChannelUsageType int type)
Parameters
type The usage type of a color channel in images to set.
See Also
getColourChannelUsageType
Gets the usage type of a color channel in images.
@EnumColourChannelUsageType int getColourChannelUsageType()
Return Value
Returns the usage type of a color channel in images.
See Also
setErrorListener
This function allows you to set an error listener object that will receive notifications when errors occur during image source operations. If an error occurs, the error infomation will be passed to the listener’s onErrorReceived method.
void setErrorListener(ImageSourceErrorListener listener)
Parameters
listener Specifies a listening object of the type ImageSourceErrorListener, which will handle error notifications.
See Also