/* PIKA - Photo and Image Kooker Application
 * a rebranding of The GNU Image Manipulation Program (created with heckimp)
 * A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
 *
 * Original copyright, applying to most contents (license remains unchanged): 
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
 *
 * pikaimage-color-profile.h
 * Copyright (C) 2015-2018 Michael Natterer <mitch@gimp.org>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

#ifndef __PIKA_IMAGE_COLOR_PROFILE_H__
#define __PIKA_IMAGE_COLOR_PROFILE_H__


#define PIKA_ICC_PROFILE_PARASITE_NAME            "icc-profile"
#define PIKA_SIMULATION_ICC_PROFILE_PARASITE_NAME "simulation-icc-profile"


gboolean             pika_image_get_use_srgb_profile   (PikaImage           *image,
                                                        gboolean            *hidden_profile);
void                 pika_image_set_use_srgb_profile   (PikaImage           *image,
                                                        gboolean             use_srgb);

PikaColorProfile   * _pika_image_get_hidden_profile    (PikaImage           *image);
void                 _pika_image_set_hidden_profile    (PikaImage           *image,
                                                        PikaColorProfile    *profile,
                                                        gboolean             push_undo);

gboolean             pika_image_validate_icc_parasite  (PikaImage           *image,
                                                        const PikaParasite  *icc_parasite,
                                                        const gchar         *profile_type,
                                                        gboolean            *is_builtin,
                                                        GError             **error);
const PikaParasite * pika_image_get_icc_parasite       (PikaImage           *image);
void                 pika_image_set_icc_parasite       (PikaImage           *image,
                                                        const PikaParasite  *icc_parasite,
                                                        const gchar         *profile_type);

gboolean             pika_image_validate_icc_profile   (PikaImage           *image,
                                                        const guint8        *data,
                                                        gsize                length,
                                                        const gchar         *profile_type,
                                                        gboolean            *is_builtin,
                                                        GError             **error);
const guint8       * pika_image_get_icc_profile        (PikaImage           *image,
                                                        gsize               *length);
gboolean             pika_image_set_icc_profile        (PikaImage           *image,
                                                        const guint8        *data,
                                                        gsize                length,
                                                        const gchar         *profile_type,
                                                        GError             **error);

gboolean             pika_image_validate_color_profile (PikaImage           *image,
                                                        PikaColorProfile    *profile,
                                                        gboolean            *is_builtin,
                                                        GError             **error);
PikaColorProfile   * pika_image_get_color_profile      (PikaImage           *image);
gboolean             pika_image_set_color_profile      (PikaImage           *image,
                                                        PikaColorProfile    *profile,
                                                        GError             **error);

PikaColorProfile   * pika_image_get_simulation_profile (PikaImage           *image);
gboolean             pika_image_set_simulation_profile (PikaImage           *image,
                                                        PikaColorProfile    *profile);

PikaColorRenderingIntent
                     pika_image_get_simulation_intent  (PikaImage           *image);
void                 pika_image_set_simulation_intent  (PikaImage                *image,
                                                        PikaColorRenderingIntent intent);

gboolean             pika_image_get_simulation_bpc     (PikaImage           *image);
void                 pika_image_set_simulation_bpc     (PikaImage           *image,
                                                        gboolean             bpc);

gboolean             pika_image_validate_color_profile_by_format
                                                       (const Babl          *format,
                                                        PikaColorProfile    *profile,
                                                        gboolean            *is_builtin,
                                                        GError             **error);

PikaColorProfile   * pika_image_get_builtin_color_profile
                                                       (PikaImage           *image);

gboolean             pika_image_assign_color_profile   (PikaImage           *image,
                                                        PikaColorProfile    *dest_profile,
                                                        PikaProgress        *progress,
                                                        GError             **error);

gboolean             pika_image_convert_color_profile  (PikaImage           *image,
                                                        PikaColorProfile    *dest_profile,
                                                        PikaColorRenderingIntent  intent,
                                                        gboolean             bpc,
                                                        PikaProgress        *progress,
                                                        GError             **error);

void                 pika_image_import_color_profile   (PikaImage           *image,
                                                        PikaContext         *context,
                                                        PikaProgress        *progress,
                                                        gboolean             interactive);

PikaColorTransform * pika_image_get_color_transform_to_srgb_u8
                                                       (PikaImage           *image);
PikaColorTransform * pika_image_get_color_transform_from_srgb_u8
                                                       (PikaImage           *image);

PikaColorTransform * pika_image_get_color_transform_to_srgb_double
                                                       (PikaImage           *image);
PikaColorTransform * pika_image_get_color_transform_from_srgb_double
                                                       (PikaImage           *image);

void                 pika_image_color_profile_pixel_to_rgb
                                                       (PikaImage           *image,
                                                        const Babl          *pixel_format,
                                                        gpointer             pixel,
                                                        PikaRGB             *color);
void                 pika_image_color_profile_rgb_to_pixel
                                                       (PikaImage           *image,
                                                        const PikaRGB       *color,
                                                        const Babl          *pixel_format,
                                                        gpointer             pixel);


/*  internal API, to be called only from pikaimage.c  */

void                 _pika_image_free_color_profile    (PikaImage           *image);
void                 _pika_image_free_color_transforms (PikaImage           *image);
void                 _pika_image_update_color_profile  (PikaImage           *image,
                                                        const PikaParasite  *icc_parasite);
void                 _pika_image_update_simulation_profile
                                                       (PikaImage           *image,
                                                        const PikaParasite  *icc_parasite);


#endif /* __PIKA_IMAGE_COLOR_PROFILE_H__ */
