Krita Source Code Documentation
Loading...
Searching...
No Matches
IccColorProfile::Private Struct Reference

Classes

struct  ProfileInfo
 
struct  Shared
 

Public Types

using LazyProfileInfo = KisLazyStorage<KisLazyValueWrapper<ProfileInfo>, std::function<ProfileInfo()>>
 

Public Member Functions

ProfileInfo calculateFloatUIMinMax () const
 
 Private ()
 

Public Attributes

QSharedPointer< Sharedshared
 

Detailed Description

Definition at line 65 of file IccColorProfile.cpp.

Member Typedef Documentation

◆ LazyProfileInfo

Constructor & Destructor Documentation

◆ Private()

IccColorProfile::Private::Private ( )
inline

Definition at line 84 of file IccColorProfile.cpp.

Member Function Documentation

◆ calculateFloatUIMinMax()

IccColorProfile::Private::ProfileInfo IccColorProfile::Private::calculateFloatUIMinMax ( ) const

Definition at line 463 of file IccColorProfile.cpp.

464{
465 Private::ProfileInfo info;
467
468 cmsHPROFILE cprofile = shared->lcmsProfile->lcmsProfile();
469 Q_ASSERT(cprofile);
470
471 cmsColorSpaceSignature color_space_sig = cmsGetColorSpace(cprofile);
472 unsigned int num_channels = cmsChannelsOf(color_space_sig);
473 unsigned int color_space_mask = _cmsLCMScolorSpace(color_space_sig);
474
475 Q_ASSERT(num_channels >= 1 && num_channels <= 4); // num_channels==1 is for grayscale, we need to handle it
476 Q_ASSERT(color_space_mask);
477
478 // to try to find the max range of float/doubles for this profile,
479 // pass in min/max int and make the profile convert that
480 // this is far from perfect, we need a better way, if possible to get the "bounds" of a profile
481
482 uint16_t in_min_pixel[4] = {0, 0, 0, 0};
483 uint16_t in_max_pixel[4] = {0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF};
484 qreal out_min_pixel[4] = {0, 0, 0, 0};
485 qreal out_max_pixel[4] = {0, 0, 0, 0};
486
487 cmsHTRANSFORM trans = cmsCreateTransform(
488 cprofile,
489 (COLORSPACE_SH(color_space_mask) | CHANNELS_SH(num_channels) | BYTES_SH(2)),
490 cprofile,
491 (COLORSPACE_SH(color_space_mask) | FLOAT_SH(1) | CHANNELS_SH(num_channels) | BYTES_SH(0)), //NOTE THAT 'BYTES' FIELD IS SET TO ZERO ON DLB because 8 bytes overflows the bitfield
492 INTENT_ABSOLUTE_COLORIMETRIC, 0); // does the intent matter in this case?
493 // absolute colorimetric gives bigger bounds with cmyk's Chemical Proof
494
495 if (trans) {
496 cmsDoTransform(trans, in_min_pixel, out_min_pixel, 1);
497 cmsDoTransform(trans, in_max_pixel, out_max_pixel, 1);
498 cmsDeleteTransform(trans);
499 }//else, we'll just default to [0..1] below
500
501 // Some (calibration) profiles may have a weird RGB->XYZ transformation matrix,
502 // which is not invertible. Therefore, such profile cannot be used as
503 // a workspace color profile and we should convert the image to sRGB
504 // right on image loading
505
506 // LCMS doesn't have a separate method for checking if conversion matrix
507 // is invertible, therefore we just try to create a simple transformation,
508 // where the profile is both, input and output. If the transformation
509 // is created successfully, then this profile is probably suitable for
510 // usage as a working color space.
511
512 info.canCreateCyclicTransform = bool(trans);
513
514 ret.resize(num_channels);
515 for (unsigned int i = 0; i < num_channels; ++i) {
516 if (color_space_sig == cmsSigYCbCrData) {
517 // Although YCbCr profiles are essentially LUT-based
518 // (due to the inability of ICC to represent multiple successive
519 // matrix transforms except with BtoD0 tags in V4),
520 // YCbCr is intended to be a roundtrip transform to the
521 // corresponding RGB transform (BT.601, BT.709).
522 // Force enable the full range of values.
523 ret[i].minVal = 0;
524 ret[i].maxVal = 1;
525 } else if (out_min_pixel[i] < out_max_pixel[i]) {
526 ret[i].minVal = out_min_pixel[i];
527 ret[i].maxVal = out_max_pixel[i];
528 } else {
529 // apparently we can't even guarantee that converted_to_double(0x0000) < converted_to_double(0xFFFF)
530 // assume [0..1] in such cases
531 // we need to find a really solid way of determining the bounds of a profile, if possible
532 ret[i].minVal = 0;
533 ret[i].maxVal = 1;
534 }
535 }
536
537 return info;
538}
#define INTENT_ABSOLUTE_COLORIMETRIC
Definition kis_global.h:106

References KoColorProfile::info, INTENT_ABSOLUTE_COLORIMETRIC, and shared.

Member Data Documentation

◆ shared

QSharedPointer<Shared> IccColorProfile::Private::shared

Definition at line 88 of file IccColorProfile.cpp.


The documentation for this struct was generated from the following file: