#include "ltdic.h"
L_LTDIC_API L_INT L_DicomPrintSCUUpdateImageBox(hPrintSCU, pszImageBoxInstanceUID, pImage, uIndex, pParameters, pszRefImageOverlayBoxInstanceUID, pszRefPresLUTInstanceUID)
A handle to Dicom Print SCU.
SOP Instance UID of the Image Box.
Image to be printed in the Image Box.
Image Box index to be updated.
Image Box parameters to be updated.
Referenced Image Overlay Box.
Referenced Presentation LUT.
| Value | Meaning |
|---|---|
| SUCCESS | The function was successful. |
| < 1 | An error occurred. Refer to Return Codes. |
When the Print SCP is requested to create a Film Box, it will also create one or more Image Boxes, based on the Image Display Format. This function updates a particular Image Box. The Image Box specified (by the SOP Instance UID) must belong to the current (last created) Film Box.
The type of the Image Boxes created by the Print SCP (Grayscale or Color) depends on the Meta SOP Class of the Film Session created at first. Refer to the function L_DicomPrintSCUCreateFilmSession for more information.
The function will not return until it receives the response of the Print SCP, or an error occurs. The function L_DicomPrintSCUGetLastOperationStatus can be used to obtain the status code specified in the response of the Print SCP. When the return value of the function UpdateImageBox is 0, then the Image Box was updated successfully, with either a Success or Warning status code in the response of the Print SCP.
The parameter pParameters points to an IMAGEBOXPARAMETERS structure that specifies the Image Box parameters to be updated. In this structure, if a string member is NULL, then the corresponding Attribute will not be included in the request to the Print SCP and hence will not be updated. Similarly, if a numeric member (that specifies an Attribute) is negative, the corresponding Attribute will not be included in the request and hence will not be updated. Notice that since the Attributes Min Density, Max Density, and Configuration Information are defined only for Grayscale Image Boxes, the function will ignore the following structure members for Color Image Boxes:
Win32, x64, Linux.
L_INT DicomPrintSCUUpdateImageBoxExample(){L_INT nRet;HDICOMPRINTSCU hPrintSCU;hPrintSCU = L_DicomPrintSCUCreate(NULL);L_DicomPrintSCUSetTimeout (hPrintSCU, 60); // 60 secondsL_TCHAR szMsg[32];// Establish the AssociationnRet = L_DicomPrintSCUAssociate (hPrintSCU,TEXT("10.0.2.20"), 7104, TEXT("PrintSCP"), 2704,TEXT("PrintSCP"), TEXT("PrintSCU"),PRINTSCU_BASIC_GRAYSCALE_PM_META_SOP_CLASS |PRINTSCU_BASIC_COLOR_PM_META_SOP_CLASS |PRINTSCU_BASIC_ANNOTATION_BOX_SOP_CLASS |PRINTSCU_BASIC_PRINT_IMAGE_OVERLAY_BOX_SOP_CLASS |PRINTSCU_PRESENTATION_LUT_SOP_CLASS |PRINTSCU_PRINT_JOB_SOP_CLASS |PRINTSCU_PRINTER_CONFIGURATION_RETRIEVAL_SOP_CLASS);if(nRet != DICOM_SUCCESS)return nRet;if (nRet == DICOM_ERROR_PRINTSCU_ASSOCIATE_RQ_REJECTED){L_UCHAR nSource, nReason;L_DicomPrintSCUGetAssociateRejectInfo (hPrintSCU, NULL, &nSource, &nReason);wsprintf(szMsg, TEXT("Source = %i, Reason = %i"), nSource, nReason);MessageBox(NULL, szMsg, TEXT("Association Request was Rejected"), MB_OK);return nRet;}else if (nRet != DICOM_SUCCESS){wsprintf(szMsg, TEXT("Error code: %i"), nRet);MessageBox(NULL, szMsg, TEXT("Failed to Establish the Association"), MB_OK);return nRet;}// Display some printer info//GetPrinterInfo(PrintSCU);// Display some printer configuration info//GetPrinterConfigInfo(PrintSCU);FILMSESSIONPARAMETERS FilmSessionParams;// Create a Film SessionL_DicomPrintSCUGetDefaultFilmSessionParameters (hPrintSCU, &FilmSessionParams,sizeof(FILMSESSIONPARAMETERS));FilmSessionParams.nNumberOfCopies = 1;nRet = L_DicomPrintSCUCreateFilmSession (hPrintSCU, &FilmSessionParams, FALSE);if(nRet != DICOM_SUCCESS)return nRet;MessageBox(NULL, L_DicomPrintSCUGetFilmSessionInstanceUID (hPrintSCU),TEXT("Film Session SOP Instance UID"), MB_OK);// Update the Film Session to specify a "MED" Print PrioritynRet = L_DicomPrintSCUGetDefaultFilmSessionParameters (hPrintSCU, &FilmSessionParams,sizeof(FILMSESSIONPARAMETERS));if(nRet != DICOM_SUCCESS)return nRet;FilmSessionParams.pszPrintPriority = TEXT("MED");nRet = L_DicomPrintSCUUpdateFilmSession (hPrintSCU, &FilmSessionParams);if(nRet != DICOM_SUCCESS)return nRet;FILMBOXPARAMETERS FilmBoxParams;nRet = L_DicomPrintSCUGetDefaultFilmBoxParameters (hPrintSCU, &FilmBoxParams,sizeof(FILMBOXPARAMETERS));if(nRet != DICOM_SUCCESS)return nRet;if (L_DicomPrintSCUIsClassSupported (hPrintSCU, PRINTSCU_BASIC_ANNOTATION_BOX_SOP_CLASS)){FilmBoxParams.pszAnnotationDisplayFormatID = TEXT("SomeID");}// Create a Film BoxnRet = L_DicomPrintSCUCreateFilmBox (hPrintSCU, &FilmBoxParams, NULL);if(nRet != DICOM_SUCCESS)return nRet;MessageBox(NULL, L_DicomPrintSCUGetFilmBoxInstanceUID (hPrintSCU),TEXT("Film Box SOP Instance UID"), MB_OK);L_PCTSTR pszPresLUTInstanceUID = NULL;// Create a Presentation LUTif (L_DicomPrintSCUIsClassSupported (hPrintSCU, PRINTSCU_PRESENTATION_LUT_SOP_CLASS)){LDicomDS PresLUT;nRet = PresLUT.LoadDS(MAKE_IMAGE_PATH(TEXT("IMAGE1.dcm")), DS_LOAD_CLOSE);if (nRet == DICOM_SUCCESS){nRet = L_DicomPrintSCUCreatePresentationLUT (hPrintSCU, &PresLUT, NULL);if(nRet != DICOM_SUCCESS)return nRet;pszPresLUTInstanceUID = L_DicomPrintSCUGetPresentationLUTInstanceUID (hPrintSCU);MessageBox(NULL, pszPresLUTInstanceUID,TEXT("PresLUT SOP Instance UID"), MB_OK);}elsereturn nRet;}if (pszPresLUTInstanceUID){// Update the Film Box to reference the Presentation LUT we just creatednRet = L_DicomPrintSCUUpdateFilmBox (hPrintSCU, NULL, pszPresLUTInstanceUID);if(nRet != DICOM_SUCCESS)return nRet;}L_PCTSTR pszOverlayBoxInstanceUID = NULL;L_PCTSTR pszRefPresLUTInstanceUID = NULL;// The image to be printed in the Image BoxLDicomDS Image;nRet = Image.LoadDS (MAKE_IMAGE_PATH(TEXT("Image1.dcm")), DS_LOAD_CLOSE);if(nRet != DICOM_SUCCESS)return nRet;// Update the Image Box. Since the Image Display Format of the Film Box was// set to "STANDARD\1,1", then we are supposed to have one Image Box created// by the Print SCP.if (L_DicomPrintSCUGetImageBoxesCount (hPrintSCU)){L_PCTSTR pszImageBoxInstanceUID = L_DicomPrintSCUGetImageBoxInstanceUID (hPrintSCU, 0);MessageBox(NULL, pszImageBoxInstanceUID,TEXT("Image Box SOP Instance UID"), MB_OK);IMAGEBOXPARAMETERS ImageBoxParams;nRet = L_DicomPrintSCUGetDefaultImageBoxParameters(hPrintSCU, &ImageBoxParams,sizeof(IMAGEBOXPARAMETERS));if(nRet != DICOM_SUCCESS)return nRet;ImageBoxParams.nImagePosition = 1;#if defined(LEADTOOLS_V19_OR_LATER)nRet = L_DicomPrintSCUUpdateImageBox (hPrintSCU, pszImageBoxInstanceUID,&Image,0,&ImageBoxParams,pszOverlayBoxInstanceUID,pszRefPresLUTInstanceUID);#elsenRet = L_DicomPrintSCUUpdateImageBox (hPrintSCU, pszImageBoxInstanceUID,&Image,&ImageBoxParams,pszOverlayBoxInstanceUID);#endifif(nRet != DICOM_SUCCESS)return nRet;// We don't need them any moreL_DicomPrintSCUFreeImageBoxesInstanceUIDs(hPrintSCU);}// Update the Annotation Boxes (if there are any)L_UINT32 uAnnBoxesCount = L_DicomPrintSCUGetAnnotationBoxesCount (hPrintSCU);for (L_UINT32 i = 0; i < uAnnBoxesCount; i++){nRet = L_DicomPrintSCUUpdateAnnotationBox (hPrintSCU, L_DicomPrintSCUGetAnnotationBoxInstanceUID (hPrintSCU, i),L_UINT16(i + 1), TEXT("Some Text"));if(nRet != DICOM_SUCCESS)return nRet;}L_DicomPrintSCUFreeAnnotationBoxesInstanceUIDs (hPrintSCU); // We don't need them any more// Print the Film Session (or the Film Box; there is no difference since we// have a single Film Box in the Film Session)nRet = L_DicomPrintSCUPrintFilmSession (hPrintSCU);if(nRet != DICOM_SUCCESS)return nRet;// Display some info about the Print Jobif (L_DicomPrintSCUIsClassSupported (hPrintSCU, PRINTSCU_PRINT_JOB_SOP_CLASS)){//GetPrintJobInfo(PrintSCU, L_DicomPrintSCUGetPrintJobInstanceUID (hPrintSCU));}// Delete the Film Box (anyway, it would be deleted when the Film Session// is deleted)nRet = L_DicomPrintSCUDeleteFilmBox (hPrintSCU);if(nRet != DICOM_SUCCESS)return nRet;// Delete the Film SessionnRet = L_DicomPrintSCUDeleteFilmSession (hPrintSCU);if(nRet != DICOM_SUCCESS)return nRet;// Delete the Presentation LUTif (pszPresLUTInstanceUID){nRet = L_DicomPrintSCUDeletePresentationLUT (hPrintSCU, pszPresLUTInstanceUID);if(nRet != DICOM_SUCCESS)return nRet;}// Delete the Image Overlay Boxif (pszOverlayBoxInstanceUID){nRet = L_DicomPrintSCUDeleteOverlayBox (hPrintSCU, pszOverlayBoxInstanceUID);if(nRet != DICOM_SUCCESS)return nRet;}// Release the Association and close the connectionnRet = L_DicomPrintSCURelease(hPrintSCU);if(nRet != DICOM_SUCCESS)return nRet;L_DicomPrintSCUFree(hPrintSCU);return DICOM_SUCCESS;}