Retrieves the buffer array for any WIA property of type VT_UI1 | VT_VECTOR.
#include "ltwia.h"
L_LTWIA_API L_INT EXT_FUNCTION L_WiaGetPropertyBuffer(hSession, pItem, pszID, uID, pValue, puSize)
Handle to an existing WIA session. This handle is obtained by calling the L_WiaInitSession function.
Valid pointer to a type IWiaItem or IWiaItem2 object(IWiaItem if using WIA Version 1.0; IWiaItem2 if using WIA Version 2.0), which represents the item having the property.
You can retrieve this parameter by either calling the L_WiaGetRootItem function to get a pointer to the device's root item or by enumerating the child items of the device through a call to L_WiaEnumChildItems.
This string pointer should contain the equivalent property ID string for the WIA property ID (see example below):
Property ID | Property ID Equivalent String |
---|---|
WIA_IPA_TYMED | WIA_IPA_TYMED_STR or "Media Type" |
WIA_IPA_DEPTH | WIA_IPA_DEPTH_STR or "Bits Per Pixel" |
If this parameter is NULL then the WIA toolkit will use the ID passed through the uID parameter; otherwise the pszID parameter will be used whether or not you passed valid property ID through the uID parameter.
The property ID for the value being sought.
This parameter is required only if the pszID parameter is NULL; otherwise you can pass 0 for this parameter.
Pointer to an allocated buffer to be updated with the value of the provided property ID.
Pointer to a variable that contains the allocated buffer size.
This parameter will always be updated with the exact required buffer size.
Value | Meaning |
---|---|
SUCCESS | The function was successful. |
< 1 | An error occurred. Refer to Return Codes. |
This feature is available in version 16 or higher.
Any WIA property of type VT_UI1 | VT_VECTOR (for example,WIA_IPC_THUMBNAIL, WIA_DPS_PAD_COLOR, .etc) returns a buffer array. In order to retrieve this type of buffer you need to call the function L_WiaGetPropertyBuffer after allocating a buffer of type L_UCHAR and passing a pointer to that allocated buffer.
To retrieve the required buffer size, declare a variable of type L_SIZE_T and pass the address of that variable to this function and also pass NULL for the pValue parameter. Then you can use the returned buffer size to allocate your buffer with the exact required buffer size.
LEADTOOLS WIA supports both 32-bit and 64-bit image acquisition for both WIA 1.0 (XP and earlier) and WIA 2.0 (VISTA and later).
static L_INT CALLBACK WiaEnumItemsCB(HWIASESSION hSession,
L_INT nItemsCount,
L_VOID * pItem,
L_VOID * pUserData)
{
UNREFERENCED_PARAMETER(nItemsCount);
UNREFERENCED_PARAMETER(pUserData);
L_INT nRet;
if(pItem != NULL)
{
L_SIZE_T uSize = 0;
L_UCHAR * pValue = NULL;
// Call the function the first time passing NULL for the pValue parameter so you can get
// the exact required buffer size to allocate.
nRet = L_WiaGetPropertyBuffer(hSession, pItem, NULL, WIA_IPC_THUMBNAIL, NULL, &uSize);
if(nRet != WIA_SUCCESS || uSize == 0)
return nRet;
pValue = (L_UCHAR*)GlobalAllocPtr(GHND, uSize * sizeof(L_UCHAR));
if(!pValue)
return ERROR_NO_MEMORY;
nRet = L_WiaGetPropertyBuffer(hSession, pItem, NULL, WIA_IPC_THUMBNAIL, pValue, &uSize);
if(nRet != WIA_SUCCESS)
return nRet;
// By now the pValue buffer should be filled with the thumbnail data that you can do
// whatever you like to with.
GlobalFreePtr(pValue);
nRet = L_WiaFreeItem(hSession, pItem);
if(nRet != WIA_SUCCESS)
return nRet;
}
return WIA_SUCCESS;
}
L_INT WiaGetPropertyBufferExample(HWIASESSION hSession, HWND hWnd)
{
L_INT nRet;
IWiaItem * pRootItem = NULL;
nRet = L_WiaSelectDeviceDlg(hSession, hWnd, WiaDeviceTypeDefault, 0);
if(nRet != WIA_SUCCESS)
return nRet;
nRet = L_WiaGetRootItem(hSession, NULL, (L_VOID**)&pRootItem);
if(nRet != WIA_SUCCESS)
return nRet;
nRet = L_WiaEnumChildItems(hSession, pRootItem, WiaEnumItemsCB, NULL);
if(nRet != WIA_SUCCESS)
return nRet;
return SUCCESS;
}