* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include "main.h"
#include "color-man.h"
-#include "image.h"
-#include "ui-fileops.h"
+#include <config.h>
+#if HAVE_LCMS
+/*** color support enabled ***/
+
+#include <cstdint>
+#include <cstring>
#include <vector>
-#ifdef HAVE_LCMS
-/*** color support enabled ***/
+#include <glib-object.h>
-#ifdef HAVE_LCMS2
-#include <lcms2.h>
+#if HAVE_LCMS2
+# include <lcms2.h>
#else
-#include <lcms.h>
+# include <lcms.h>
#endif
+#include "debug.h"
+#include "filedata.h"
+#include "image.h"
+#include "intl.h"
+#include "options.h"
+#include "ui-fileops.h"
struct ColorManCache {
cmsHPROFILE profile_in;
if (init_done) return;
init_done = TRUE;
-#ifndef HAVE_LCMS2
+#if !HAVE_LCMS2
cmsErrorAction(LCMS_ERROR_IGNORE);
#endif
}
static cmsHPROFILE color_man_create_adobe_comp()
{
/* ClayRGB1998 is AdobeRGB compatible */
-#include "ClayRGB1998_icc.h"
+#include "ClayRGB1998_icc.h" // IWYU pragma: keep
return cmsOpenProfileFromMem(ClayRGB1998_icc, ClayRGB1998_icc_len);
}
guchar *pix;
gint rs;
gint i;
- gint pixbuf_width, pixbuf_height;
+ gint pixbuf_width;
+ gint pixbuf_height;
pixbuf_width = gdk_pixbuf_get_width(pixbuf);
#pragma GCC diagnostic ignored "-Wunused-function"
static gboolean color_man_idle_cb_unused(gpointer data)
{
- ColorMan *cm = static_cast<ColorMan *>(data);
- gint width, height;
+ auto *cm = static_cast<ColorMan *>(data);
+ gint width;
+ gint height;
gint rh;
if (!cm->pixbuf) return FALSE;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
-void color_man_start_bg_unused(ColorMan *cm, ColorManDoneFunc done_func, gpointer done_data)
+void color_man_start_bg_unused(ColorMan *cm, ColorMan::DoneFunc done_func, gpointer done_data)
{
cm->func_done = done_func;
cm->func_done_data = done_data;
case COLOR_PROFILE_FILE:
if (profile)
{
-#ifdef HAVE_LCMS2
+#if HAVE_LCMS2
char buffer[20];
buffer[0] = '\0';
cmsGetProfileInfoASCII(profile, cmsInfoDescription, "en", "US", buffer, 20);
color_man_cache_reset();
}
-#ifdef HAVE_HEIF
+#if HAVE_HEIF
#include <cmath>
#include <libheif/heif.h>
for(int32_t i = 0; i < size; ++i)
{
const double x = static_cast<float>(i) / (size - 1);
- const double y = MIN(fct(x), 1.0f);
+ const double y = MIN(fct(x), 1.0F);
values.push_back(static_cast<float>(y));
}
whitepoint.x = nclx->color_primary_white_x;
whitepoint.y = nclx->color_primary_white_y;
- whitepoint.Y = 1.0f;
+ whitepoint.Y = 1.0F;
primaries.Red.x = nclx->color_primary_red_x;
primaries.Red.y = nclx->color_primary_red_y;
- primaries.Red.Y = 1.0f;
+ primaries.Red.Y = 1.0F;
primaries.Green.x = nclx->color_primary_green_x;
primaries.Green.y = nclx->color_primary_green_y;
- primaries.Green.Y = 1.0f;
+ primaries.Green.Y = 1.0F;
primaries.Blue.x = nclx->color_primary_blue_x;
primaries.Blue.y = nclx->color_primary_blue_y;
- primaries.Blue.Y = 1.0f;
+ primaries.Blue.Y = 1.0F;
switch (nclx->color_primaries)
{
trc_name = "Rec709 RGB";
break;
case heif_transfer_characteristic_ITU_R_BT_470_6_System_M:
- curve[0] = curve[1] = curve[2] = cmsBuildGamma (nullptr, 2.2f);
+ curve[0] = curve[1] = curve[2] = cmsBuildGamma (nullptr, 2.2F);
profile = static_cast<cmsHPROFILE *>(cmsCreateRGBProfile(&whitepoint, &primaries, curve));
cmsFreeToneCurve(curve[0]);
trc_name = "Gamma2.2 RGB";
break;
case heif_transfer_characteristic_ITU_R_BT_470_6_System_B_G:
- curve[0] = curve[1] = curve[2] = cmsBuildGamma (nullptr, 2.8f);
+ curve[0] = curve[1] = curve[2] = cmsBuildGamma (nullptr, 2.8F);
profile = static_cast<cmsHPROFILE *>(cmsCreateRGBProfile(&whitepoint, &primaries, curve));
cmsFreeToneCurve(curve[0]);
trc_name = "Gamma2.8 RGB";
break;
case heif_transfer_characteristic_linear:
- curve[0] = curve[1] = curve[2] = cmsBuildGamma (nullptr, 1.0f);
+ curve[0] = curve[1] = curve[2] = cmsBuildGamma (nullptr, 1.0F);
profile = static_cast<cmsHPROFILE *>(cmsCreateRGBProfile(&whitepoint, &primaries, curve));
cmsFreeToneCurve(curve[0]);
trc_name = "linear RGB";
cmsCloseProfile(profile);
return static_cast<guchar *>(data);
}
- else
- {
- cmsCloseProfile(profile);
- return nullptr;
- }
- }
- else
- {
+
+ cmsCloseProfile(profile);
return nullptr;
}
+
+ return nullptr;
}
guchar *heif_color_profile(FileData *fd, guint *profile_len)
return static_cast<guchar *>(data);
}
- else
- {
- error_code = heif_image_handle_get_nclx_color_profile(handle, &nclxcp);
- if (error_code.code)
- {
- log_printf("warning: heif reader error: %s\n", error_code.message);
- heif_context_free(ctx);
- heif_nclx_color_profile_free(nclxcp);
- return nullptr;
- }
- profile = nclx_to_lcms_profile(nclxcp, profile_len);
+ error_code = heif_image_handle_get_nclx_color_profile(handle, &nclxcp);
+ if (error_code.code)
+ {
+ log_printf("warning: heif reader error: %s\n", error_code.message);
+ heif_context_free(ctx);
+ heif_nclx_color_profile_free(nclxcp);
+ return nullptr;
}
+ profile = nclx_to_lcms_profile(nclxcp, profile_len);
+
heif_context_free(ctx);
heif_nclx_color_profile_free(nclxcp);