LDicomDS::GetImage
#include "Ltdic.h"
L_UINT16 LDicomDS::GetImage(pElement, pBitmap, uStructSize, nIndex, nBitsPerPixel, nOrder, uFlags, pfnCallback, pUserData)
pDICOMELEMENT pElement; |
/* pointer to a DICOMELEMENT structure */ |
pBITMAPHANDLE pBitmap; |
/* pointer to the bitmap handle */ |
L_UINT uStructSize; |
/* size in bytes, of the structure pointed to by pBitmap */ |
L_UINT32 nIndex; |
/* index value */ |
L_INT32 nBitsPerPixel; |
/* resulting bitmap pixel depth */ |
L_INT32 nOrder; |
/* desired color order */ |
L_UINT uFlags; |
/* flags */ |
FILEREADCALLBACK pfnCallback; |
/* optional callback function */ |
/* pointer to more parameters for the callback */ |
Loads the bitmap of a Pixel Data element into a BITMAPHANDLE.
Parameter |
Description |
|
pElement |
Pointer to a DICOMELEMENT structure within the Data Set. |
|
pBitmap |
Pointer to the bitmap handle that references the loaded bitmap. |
|
uStructSize |
Size in bytes, of the structure pointed to by pBitmap, for versioning. Use sizeof(BITMAPHANDLE). |
|
nIndex |
Index value that indicates which frame in a Pixel Data element to load. |
|
nBitsPerPixel |
Resulting bitmap pixel depth. The following are valid values: |
|
|
Value |
Meaning |
|
0 |
Keep the original file's pixel depth (Do not convert). |
|
1 to 8 |
The specified bits per pixel in the resultant bitmap |
|
12 |
12 bits per pixel in the resultant bitmap. |
|
16 |
16 bits per pixel in the resultant bitmap |
|
24 |
24 bits per pixel in the resultant bitmap |
|
32 |
32 bits per pixel in the resultant bitmap |
nOrder |
The desired color order. Possible values are: |
|
|
Value |
Meaning |
|
ORDER_RGB |
[0] Red-green-blue order. |
|
ORDER_BGR |
[1] Blue-green-red order. |
|
ORDER_GRAY |
[2] 12 or 16-bit grayscale image. 12 and 16-bit grayscale images are only supported in the Document/Medical toolkits. |
|
ORDER_RGBORGRAY |
[3] Load the image as red, green, blue OR as a 12 or 16-bit grayscale image. 12 and 16-bit grayscale images are supported in the Document/Medical toolkits only. |
|
ORDER_BGRORGRAY |
[4] Load the image as blue, green, red OR as a 12 or 16-bit grayscale image. 12 and 16-bit grayscale images are supported in the Document/Medical toolkits only. |
|
0 |
The data is 8 bits per pixel or less. |
uFlags |
Flags which control the behaviour of this function: |
|
|
Value |
Meaning |
|
DICOM_GETIMAGE_AUTO_LOAD_OVERLAYS |
[0x0001] If set, the function will automatically extract the overlays included in the dataset and add them to the loaded bitmap. |
|
DICOM_GETIMAGE_AUTO_APPLY_MODALITY_LUT |
[0x0002] If set, the function will automatically apply the "Modality LUT" when loading the bitmap. |
|
DICOM_GETIMAGE_AUTO_APPLY_VOI_LUT |
[0x0004] If set, the function will automatically apply the "VOI LUT" when loading the bitmap. |
|
DICOM_GETIMAGE_ALLOW_RANGE_EXPANSION |
[0x0008] If set, the function will adjust the high bit and/or low bit (if possible) inside the bitmap handle in order to hold the range of pixel values after applying the modality LUT. |
pfnCallback |
Optional callback function for additional processing. |
|
|
If you do not provide a callback function, use NULL as the value of this parameter. |
|
|
If you do provide a callback function, use the function pointer as the value of this parameter. |
|
|
The callback function must adhere to the function prototype described in FILEREADCALLBACK Function. |
|
pUserData |
Void pointer that you can use to pass one or more additional parameters that the callback function needs. |
|
|
To use this feature, assign a value to a variable or create a structure that contains as many fields as you need. Then, in this parameter, pass the address of the variable or structure, casting it to L_VOID L_FAR *. The callback function, which receives the address in its own pUserData parameter, can cast it to a pointer of the appropriate data type to access your variable or structure. |
|
|
If the additional parameters are not needed, you can pass NULL in this parameter. |
Returns
0 |
SUCCESS |
>0 |
An error occurred. Refer to Return Codes. |
Comments
If pElement is NULL, this function will load any image within the file, based on the nIndex parameter.
If DICOM_GETIMAGE_ALLOW_RANGE_EXPANSION is set in uFlags, consider the following example:
If the dataset has the following attributes:
Bits allocated |
16 |
Bits stored |
12 |
Pixel Range |
0 - +4095 |
Pixel Representation is unsigned (0)
Photometric Interpretation is MONOCHROME2
Rescale Slope |
1 |
Rescale Intercept |
-1024 |
After applying the rescale slope and the intercept:
Output minimum pixel value = (0 * 1 +(-1024)) = -1024
Output maximum pixel value = (4095 * 1 + (-1024)) = 3071
The new pixel value range (–1024 to 3071) can’t be represented with the current bits stored (12 bits), which can represent values in the range (–2048 to 2048). In this case the function will change the high bit inside the bitmap handle to be 12 instead of 11 (bits stored becomes 13), which can represent values in the range (–8192 to 8191).
Please note that the function won’t be able to update the high bit and/or low bit if the number of bits stored was already equal to the number of bits allocated.
Required DLLs and Libraries
LTDIC For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application |
See Also
Functions: |
|
Topics: |
Example
/* This example fills a bitmap with an image from the Data Set */
L_VOID Test()
{
LDicomDS *pDS;
pDICOMELEMENT pElement;
BITMAPHANDLE Bitmap;
pDS = new LDicomDS(NULL);
pDS->LoadDS("c:\\ltwin13\\images\\image1.dic", 0);
pElement = pDS->FindFirstElement(NULL, TAG_PIXEL_DATA, FALSE);
if (pElement != NULL)
{
pDS->GetImage(pElement, &Bitmap, sizeof(BITMAPHANDLE), 0, 0, ORDER_BGR, DICOM_GETIMAGE_AUTO_APPLY_MODALITY_LUT|
DICOM_GETIMAGE_AUTO_APPLY_VOI_LUT, NULL, NULL);
L_FreeBitmap(&Bitmap);
}
delete pDS;
}