#include "jpeglib.h" #include "iccjpeg.h" #include "lcms.h" // // This snippet shows how to deal with Embedded profiles in JPEG // files using IJG (aka, Tom Lane's) library. You will also need // the icc decoder, present on IJG site. // // This is given as an example, and does *NOT* compile unless // you replace "Decompress" and "Compress" variables with those // ow your own. cmsHPROFILE JPEGGetColorProfile(void) { LPBYTE Buffer; unsigned int Len; cmsHPROFILE hProfile; if (!read_icc_profile(&Decompressor, &Buffer, &Len)) { return NULL; } hProfile = cmsOpenProfileFromMem(Buffer, Len); free(Buffer); return hProfile; } /* * This routine writes the given ICC profile data into a JPEG file. * It *must* be called AFTER calling jpeg_start_compress() and BEFORE * the first call to jpeg_write_scanlines(). * (This ordering ensures that the APP2 marker(s) will appear after the * SOI and JFIF or Adobe markers, but before all else.) */ int JPEGEmbbedColorProfile(LPVOID Buffer, LONG Len) { write_icc_profile(&Compressor, (LPBYTE) Buffer, Len); return TRUE; }