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;

}

Category:

Online Demo