#include "main.h"
#include "color-man.h"
+#include "filedata.h"
#include "image.h"
#include "ui-fileops.h"
+#include <vector>
#ifdef HAVE_LCMS
/*** color support enabled ***/
*-------------------------------------------------------------------
*/
-//static void color_man_done(ColorMan *cm, ColorManReturnType type)
-//{
- //if (cm->func_done)
- //{
- //cm->func_done(cm, type, cm->func_done_data);
- //}
-//}
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-function"
+static void color_man_done_unused(ColorMan *cm, ColorManReturnType type)
+{
+ if (cm->func_done)
+ {
+ cm->func_done(cm, type, cm->func_done_data);
+ }
+}
+#pragma GCC diagnostic pop
void color_man_correct_region(ColorMan *cm, GdkPixbuf *pixbuf, gint x, gint y, gint w, gint h)
{
}
-//static gboolean color_man_idle_cb(gpointer data)
-//{
- //ColorMan *cm = static_cast<ColorMan *>(data);
- //gint width, height;
- //gint rh;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-function"
+static gboolean color_man_idle_cb_unused(gpointer data)
+{
+ ColorMan *cm = static_cast<ColorMan *>(data);
+ gint width, height;
+ gint rh;
- //if (!cm->pixbuf) return FALSE;
+ if (!cm->pixbuf) return FALSE;
- //if (cm->imd &&
- //cm->pixbuf != image_get_pixbuf(cm->imd))
- //{
- //cm->idle_id = 0;
- //color_man_done(cm, COLOR_RETURN_IMAGE_CHANGED);
- //return FALSE;
- //}
+ if (cm->imd &&
+ cm->pixbuf != image_get_pixbuf(cm->imd))
+ {
+ cm->idle_id = 0;
+ color_man_done_unused(cm, COLOR_RETURN_IMAGE_CHANGED);
+ return FALSE;
+ }
- //width = gdk_pixbuf_get_width(cm->pixbuf);
- //height = gdk_pixbuf_get_height(cm->pixbuf);
+ width = gdk_pixbuf_get_width(cm->pixbuf);
+ height = gdk_pixbuf_get_height(cm->pixbuf);
- //if (cm->row > height)
- //{
- //if (!cm->incremental_sync && cm->imd)
- //{
- //image_area_changed(cm->imd, 0, 0, width, height);
- //}
+ if (cm->row > height)
+ {
+ if (!cm->incremental_sync && cm->imd)
+ {
+ image_area_changed(cm->imd, 0, 0, width, height);
+ }
- //cm->idle_id = 0;
- //color_man_done(cm, COLOR_RETURN_SUCCESS);
- //return FALSE;
- //}
+ cm->idle_id = 0;
+ color_man_done_unused(cm, COLOR_RETURN_SUCCESS);
+ return FALSE;
+ }
- //rh = COLOR_MAN_CHUNK_SIZE / width + 1;
- //color_man_correct_region(cm, cm->pixbuf, 0, cm->row, width, rh);
- //if (cm->incremental_sync && cm->imd) image_area_changed(cm->imd, 0, cm->row, width, rh);
- //cm->row += rh;
+ rh = COLOR_MAN_CHUNK_SIZE / width + 1;
+ color_man_correct_region(cm, cm->pixbuf, 0, cm->row, width, rh);
+ if (cm->incremental_sync && cm->imd) image_area_changed(cm->imd, 0, cm->row, width, rh);
+ cm->row += rh;
- //return TRUE;
-//}
+ return TRUE;
+}
+#pragma GCC diagnostic pop
static ColorMan *color_man_new_real(ImageWindow *imd, GdkPixbuf *pixbuf,
ColorManProfileType input_type, const gchar *input_file,
screen_type, screen_file, screen_data, screen_data_len);
}
-//void color_man_start_bg(ColorMan *cm, ColorManDoneFunc done_func, gpointer done_data)
-//{
- //cm->func_done = done_func;
- //cm->func_done_data = done_data;
- //cm->idle_id = g_idle_add(color_man_idle_cb, cm);
-//}
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-function"
+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;
+ cm->idle_id = g_idle_add(color_man_idle_cb_unused, cm);
+}
+#pragma GCC diagnostic pop
ColorMan *color_man_new_embedded(ImageWindow *imd, GdkPixbuf *pixbuf,
guchar *input_data, guint input_data_len,
}
#ifdef HAVE_HEIF
+#include <cmath>
#include <libheif/heif.h>
-#include <math.h>
static cmsToneCurve* colorspaces_create_transfer(int32_t size, double (*fct)(double))
{
- auto values = static_cast<float *>(g_malloc(sizeof(float) * size));
-
+ std::vector<float> values;
+ values.reserve(size);
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);
- values[i] = static_cast<float>(y);
+ values.push_back(static_cast<float>(y));
}
- cmsToneCurve* result = cmsBuildTabulatedToneCurveFloat(nullptr, size, values);
- g_free(values);
- return result;
+ return cmsBuildTabulatedToneCurveFloat(nullptr, size, values.data());
}
// https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.2100-2-201807-I!!PDF-F.pdf
return profile;
}
#else
-guchar *heif_color_profile(FileData *UNUSED(fd), guint *UNUSED(profile_len))
+guchar *heif_color_profile(FileData *, guint *)
{
return NULL;
}
/*** color support not enabled ***/
-ColorMan *color_man_new(ImageWindow *UNUSED(imd), GdkPixbuf *UNUSED(pixbuf),
- ColorManProfileType UNUSED(input_type), const gchar *UNUSED(input_file),
- ColorManProfileType UNUSED(screen_type), const gchar *UNUSED(screen_file),
- guchar *UNUSED(screen_data), guint UNUSED(screen_data_len))
+ColorMan *color_man_new(ImageWindow *, GdkPixbuf *,
+ ColorManProfileType, const gchar *,
+ ColorManProfileType, const gchar *,
+ guchar *, guint)
{
/* no op */
return nullptr;
}
-ColorMan *color_man_new_embedded(ImageWindow *UNUSED(imd), GdkPixbuf *UNUSED(pixbuf),
- guchar *UNUSED(input_data), guint UNUSED(input_data_len),
- ColorManProfileType UNUSED(screen_type), const gchar *UNUSED(screen_file),
- guchar *UNUSED(screen_data), guint UNUSED(screen_data_len))
+ColorMan *color_man_new_embedded(ImageWindow *, GdkPixbuf *,
+ guchar *, guint,
+ ColorManProfileType, const gchar *,
+ guchar *, guint)
{
/* no op */
return nullptr;
}
-void color_man_free(ColorMan *UNUSED(cm))
+void color_man_free(ColorMan *)
{
/* no op */
}
/* no op */
}
-void color_man_correct_region(ColorMan *UNUSED(cm), GdkPixbuf *UNUSED(pixbuf), gint UNUSED(x), gint UNUSED(y), gint UNUSED(w), gint UNUSED(h))
+void color_man_correct_region(ColorMan *, GdkPixbuf *, gint, gint, gint, gint)
{
/* no op */
}
-gboolean color_man_get_status(ColorMan *UNUSED(cm), gchar **UNUSED(image_profile), gchar **UNUSED(screen_profile))
+gboolean color_man_get_status(ColorMan *, gchar **, gchar **)
{
return FALSE;
}
-guchar *heif_color_profile(FileData *UNUSED(fd), guint *UNUSED(profile_len))
+guchar *heif_color_profile(FileData *, guint *)
{
return nullptr;
}