mm2 / Little-CMS

A free, open source, CMM engine. It provides fast transforms between ICC profiles.
https://www.littlecms.com
MIT License
549 stars 174 forks source link

cmsCreateTransform returns nullptr in 2.16, but works in 2.15- #445

Closed 9241304 closed 5 months ago

9241304 commented 5 months ago

Test code (x64, VS2022)

#define cimg_use_png //libpng 1643
#include "cimg/CImg.h"
#include <lcms2.h>

auto src{ cil::CImg<unsigned char>("e:\\png_with_alpha.png") };
auto dst{ cil::CImg<unsigned char>(src.width(), src.height(), src.depth(), 4)};
auto inp{ cmsCreate_sRGBProfile() };
auto outp{ cmsOpenProfileFromFile("e:\\printer_profile.icm", "r") };
auto transform{ cmsCreateTransform(inp, TYPE_RGBA_8_PLANAR, outp, TYPE_CMYK_8_PLANAR, INTENT_ABSOLUTE_COLORIMETRIC, cmsFLAGS_BLACKPOINTCOMPENSATION) };

This works correctly in 2.15-(also checked 2.13.1), but doesn`t work in 2.16. If I remove flags, then code works in 2.16 too.

mm2 commented 5 months ago

I've checked your code with USWebCoatedSWOP.icc and it works fine to me. Which is the printer_profile.icm you are using?

BTW, black point compensation does nothing in absolute colorimetric, but this should not make create transform to fail.

9241304 commented 5 months ago

I think it doesn`t matter what printer profile used. Problem appears when I set any flag. Did you check on 2.16 release version or current version? DTF P900 ROLL.dmp (rename to icm)

mm2 commented 5 months ago

Using this code with official lcms2-2.16, Visual studio 2022, works fine to me

#include "lcms2.h"

int main()
{
auto inp{ cmsCreate_sRGBProfile() };
auto outp{ cmsOpenProfileFromFile("DTF.P900.ROLL.dmp", "r") };
auto transform{ cmsCreateTransform(inp, TYPE_RGBA_8_PLANAR, outp, TYPE_CMYK_8_PLANAR, INTENT_ABSOLUTE_COLORIMETRIC, cmsFLAGS_BLACKPOINTCOMPENSATION) };
return 0;
}
9241304 commented 5 months ago

OK, I will build lcms2 debug version and check again.

9241304 commented 5 months ago

It`s a magic... I built debug version, and all works. Then rebuilt release version. And it works too. Thanks for your time )

mm2 commented 5 months ago

It happens to me all the time. Don’t worry, this is the best thing it can happen. And thanks for reporting, it could have been a serious issue.

Best

Marti