Blog: Tech Talk

agsdix-fas fa-home

Blog: Home

agsdix-fas fa-pen-fancy

Blog: CEO's Corner

agsdix-fas fa-code

Blog: Tech Talk

Blog: Product Releases

agsdix-fas fa-chalkboard-teacher

Blog: Viewing

Blog: Conversion

arrow left circle icon Blog: Tech Talk

Color Correcting Images Using ICC Profiles

by | Apr 24, 2012

ICC (International Color Consortium) Profiles allow for consistent color in images when scanning, displaying, and printing. RasterMaster for Windows imaging SDK gives developers the ability to apply ICC profiles to color images. These profiles can be applied to an image when viewing or printing. They can also be applied to an image permanently.

This tech tip shows how to apply an 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;

}