Tips For Success

Having the best tools for document imaging is only half of the equation. Our Tech Tips are designed to provide you with valuable information to help you succeed by achieving faster results with our RasterMaster Imaging and Conversion SDKs or VirtualViewer high-speed document and image viewers. New time-saving tips are added monthly - you can receive them through Imaging News or our Tech Tips RSS feed.

Tech Tip: Applying Embedded ICC Profiles

Some image files have embedded ICC (International Color Consortium) Profiles. These profiles allow for consistent color in images when scanning, displaying, and printing. RasterMaster for Windows imaging SDK (DLL, ActiveX, .NET) gives developers the ability to apply these embedded ICC Profiles when viewing and printing.

This tech tip shows how to apply an embedded ICC Profile when printing an image.

int ApplyDestinationProfile()

{

CString szFileName; // image file name

CString szDestinationProfileName; // destination profile name

char* pDestinationProfileBuffer; // destination profile buffer

int nImageHandle; // image handle

int nStatus; // return status

 

// setup output profile

 

// set destination profile name to valid output (printer) profile

szDestinationProfileName = "C:\\windows\\system32\\outputdevice.icc";

 

// open destination profile for reading

CFile destProfile( szDestinationProfileName, CFile::modeRead );

 

// allocate buffer for output profile

pDestinationProfileBuffer = new char[ destProfile.GetLength() + 1 ];

 

// clear output profile buffer

memset( pDestinationProfileBuffer, 0, destProfile.GetLength() + 1 );

 

// read in output profile from file into buffer

destProfile.Read( pDestinationProfileBuffer, destProfile.GetLength() );

 

// close file

destProfile.Close();

 

// get handle to image file

szFileName = "C:\\Image.tif";

nImageHandle = IMG_decompress_bitmap_page( ( char*)(LPCTSTR)szFileName, 0 );

 

// now apply output profile to image when printing

if ( NULL != pDestinationProfileBuffer )

{

int nStatus =

IMG_apply_profile(

m_nImageHandle, // handle to image

NULL, // use default input profile

pDestinationProfileBuffer, // profile buffer

2 // apply when printing

);

}

 

// free up allocated memory

if ( NULL != pDestinationProfileBuffer )

delete [] pDestinationProfileBuffer;

 

return nStatus;

}