This function locks HIGEAR for a particular operation.
Declaration:
|
Copy Code
|
AT_ERRCOUNT EXPORT ACCUAPI IG_thread_image_lock(
HIGEAR hIGear,
AT_MODE nLockMode
);
|
Arguments:
Name |
Type |
Description |
hIGear |
HIGEAR |
HIGEAR image handle |
nLockMode |
AT_MODE |
The lock mode (IG_THREAD_LOCK_READ or IG_THREAD_LOCK_WRITE) indicator. Several threads can perform read lock concurrently, but only one thread is allowed to do write lock. |
Return Value:
Returns the number of ImageGear errors that occurred during this function call.
Supported Raster Image Formats:
This function does not process image pixels.
Sample:
MFC Threads
Example:
|
Copy Code
|
hIGear = pDoc->hMainGear;
nErrCnt = IG_thread_image_lock( pDoc->hMainGear, IG_THREAD_LOCK_WRITE );
if (nErrCnt == 0)
{
// locked successfully
IG_IP_rotate_multiple_90( hIGear, IG_ROTATE_90 );
IG_thread_image_unlock( pDoc->hMainGear, IG_THREAD_LOCK_WRITE );
...
}
|
Remarks:
Two APIs (IG_thread_image_lock(), IG_thread_image_unlock()) are required for those rare situations in which two or more threads-at least one of which is modifying or deleting an image-are simultaneously accessing the same HIGEAR. For example, one thread can save HIGEAR to a JPEG file (read access to a HIGEAR), while another is performing rotation in the asynchronous mode (write access to a HIGEAR). Thus, the "saving" thread would be required to call lock/unlock with the read mode as a parameter, and the "rotation" thread would be required to call lock/unlock with the write mode as a parameter.
Please note that all auxiliary HIGEARs associated with the main HIGEAR (such as Alpha channel, NRA mask, and transparency mask) need to be locked separately.