Initial checkin of Pika from heckimp

This commit is contained in:
2023-09-25 15:35:21 -07:00
commit 891e999216
6761 changed files with 5240685 additions and 0 deletions

View File

@ -0,0 +1,29 @@
libapplayermodeslegacy_sources = [
'pikaoperationadditionlegacy.c',
'pikaoperationburnlegacy.c',
'pikaoperationdarkenonlylegacy.c',
'pikaoperationdifferencelegacy.c',
'pikaoperationdividelegacy.c',
'pikaoperationdodgelegacy.c',
'pikaoperationgrainextractlegacy.c',
'pikaoperationgrainmergelegacy.c',
'pikaoperationhardlightlegacy.c',
'pikaoperationhslcolorlegacy.c',
'pikaoperationhsvhuelegacy.c',
'pikaoperationhsvsaturationlegacy.c',
'pikaoperationhsvvaluelegacy.c',
'pikaoperationlightenonlylegacy.c',
'pikaoperationmultiplylegacy.c',
'pikaoperationscreenlegacy.c',
'pikaoperationsoftlightlegacy.c',
'pikaoperationsubtractlegacy.c',
]
libapplayermodeslegacy = static_library('applayermodeslegacy',
libapplayermodeslegacy_sources,
include_directories: [ rootInclude, rootAppInclude, ],
c_args: '-DG_LOG_DOMAIN="Pika-Layer-Modes-Legacy"',
dependencies: [
cairo, gegl, gdk_pixbuf,
],
)

View File

@ -0,0 +1,130 @@
/* 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
*
* pikaoperationadditionmode.c
* Copyright (C) 2008 Michael Natterer <mitch@gimp.org>
* 2012 Ville Sokk <ville.sokk@gmail.com>
*
* 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/>.
*/
#include "config.h"
#include <gegl-plugin.h>
#include "../operations-types.h"
#include "pikaoperationadditionlegacy.h"
static gboolean pika_operation_addition_legacy_process (GeglOperation *op,
void *in,
void *layer,
void *mask,
void *out,
glong samples,
const GeglRectangle *roi,
gint level);
G_DEFINE_TYPE (PikaOperationAdditionLegacy, pika_operation_addition_legacy,
PIKA_TYPE_OPERATION_LAYER_MODE)
static void
pika_operation_addition_legacy_class_init (PikaOperationAdditionLegacyClass *klass)
{
GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
PikaOperationLayerModeClass *layer_mode_class = PIKA_OPERATION_LAYER_MODE_CLASS (klass);
gegl_operation_class_set_keys (operation_class,
"name", "pika:addition-legacy",
"description", "PIKA addition mode operation",
NULL);
layer_mode_class->process = pika_operation_addition_legacy_process;
}
static void
pika_operation_addition_legacy_init (PikaOperationAdditionLegacy *self)
{
}
static gboolean
pika_operation_addition_legacy_process (GeglOperation *op,
void *in_p,
void *layer_p,
void *mask_p,
void *out_p,
glong samples,
const GeglRectangle *roi,
gint level)
{
PikaOperationLayerMode *layer_mode = (gpointer) op;
gfloat *in = in_p;
gfloat *out = out_p;
gfloat *layer = layer_p;
gfloat *mask = mask_p;
gfloat opacity = layer_mode->opacity;
const gboolean has_mask = mask != NULL;
while (samples--)
{
gfloat comp_alpha, new_alpha;
comp_alpha = MIN (in[ALPHA], layer[ALPHA]) * opacity;
if (has_mask)
comp_alpha *= *mask;
new_alpha = in[ALPHA] + (1.0f - in[ALPHA]) * comp_alpha;
if (comp_alpha && new_alpha)
{
gfloat ratio = comp_alpha / new_alpha;
gint b;
for (b = RED; b < ALPHA; b++)
{
gfloat comp = in[b] + layer[b];
comp = CLAMP (comp, 0.0f, 1.0f);
out[b] = comp * ratio + in[b] * (1.0f - ratio);
}
}
else
{
gint b;
for (b = RED; b < ALPHA; b++)
{
out[b] = in[b];
}
}
out[ALPHA] = in[ALPHA];
in += 4;
layer += 4;
out += 4;
if (has_mask)
mask++;
}
return TRUE;
}

View File

@ -0,0 +1,57 @@
/* 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
*
* pikaoperationadditionlegacy.h
* Copyright (C) 2008 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_OPERATION_ADDITION_LEGACY_H__
#define __PIKA_OPERATION_ADDITION_LEGACY_H__
#include "operations/layer-modes/pikaoperationlayermode.h"
#define PIKA_TYPE_OPERATION_ADDITION_LEGACY (pika_operation_addition_legacy_get_type ())
#define PIKA_OPERATION_ADDITION_LEGACY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PIKA_TYPE_OPERATION_ADDITION_LEGACY, PikaOperationAdditionLegacy))
#define PIKA_OPERATION_ADDITION_LEGACY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PIKA_TYPE_OPERATION_ADDITION_LEGACY, PikaOperationAdditionLegacyClass))
#define PIKA_IS_OPERATION_ADDITION_LEGACY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PIKA_TYPE_OPERATION_ADDITION_LEGACY))
#define PIKA_IS_OPERATION_ADDITION_LEGACY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PIKA_TYPE_OPERATION_ADDITION_LEGACY))
#define PIKA_OPERATION_ADDITION_LEGACY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PIKA_TYPE_OPERATION_ADDITION_LEGACY, PikaOperationAdditionLegacyClass))
typedef struct _PikaOperationAdditionLegacy PikaOperationAdditionLegacy;
typedef struct _PikaOperationAdditionLegacyClass PikaOperationAdditionLegacyClass;
struct _PikaOperationAdditionLegacy
{
PikaOperationLayerMode parent_instance;
};
struct _PikaOperationAdditionLegacyClass
{
PikaOperationLayerModeClass parent_class;
};
GType pika_operation_addition_legacy_get_type (void) G_GNUC_CONST;
#endif /* __PIKA_OPERATION_ADDITION_LEGACY_H__ */

View File

@ -0,0 +1,132 @@
/* 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
*
* pikaoperationburnmode.c
* Copyright (C) 2008 Michael Natterer <mitch@gimp.org>
* 2012 Ville Sokk <ville.sokk@gmail.com>
*
* 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/>.
*/
#include "config.h"
#include <gegl-plugin.h>
#include "../operations-types.h"
#include "pikaoperationburnlegacy.h"
static gboolean pika_operation_burn_legacy_process (GeglOperation *op,
void *in,
void *layer,
void *mask,
void *out,
glong samples,
const GeglRectangle *roi,
gint level);
G_DEFINE_TYPE (PikaOperationBurnLegacy, pika_operation_burn_legacy,
PIKA_TYPE_OPERATION_LAYER_MODE)
static void
pika_operation_burn_legacy_class_init (PikaOperationBurnLegacyClass *klass)
{
GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
PikaOperationLayerModeClass *layer_mode_class = PIKA_OPERATION_LAYER_MODE_CLASS (klass);
gegl_operation_class_set_keys (operation_class,
"name", "pika:burn-legacy",
"description", "PIKA burn mode operation",
NULL);
layer_mode_class->process = pika_operation_burn_legacy_process;
}
static void
pika_operation_burn_legacy_init (PikaOperationBurnLegacy *self)
{
}
static gboolean
pika_operation_burn_legacy_process (GeglOperation *op,
void *in_p,
void *layer_p,
void *mask_p,
void *out_p,
glong samples,
const GeglRectangle *roi,
gint level)
{
PikaOperationLayerMode *layer_mode = (gpointer) op;
gfloat *in = in_p;
gfloat *out = out_p;
gfloat *layer = layer_p;
gfloat *mask = mask_p;
gfloat opacity = layer_mode->opacity;
while (samples--)
{
gfloat comp_alpha, new_alpha;
comp_alpha = MIN (in[ALPHA], layer[ALPHA]) * opacity;
if (mask)
comp_alpha *= *mask;
new_alpha = in[ALPHA] + (1.0f - in[ALPHA]) * comp_alpha;
if (comp_alpha && new_alpha)
{
gfloat ratio = comp_alpha / new_alpha;
gint b;
for (b = RED; b < ALPHA; b++)
{
gfloat comp = 1.0f - (1.0f - in[b]) / layer[b];
/* The CLAMP macro is deliberately inlined and
* written to map comp == NAN (0 / 0) -> 1
*/
comp = comp < 0.0f ? 0.0f : comp < 1.0f ? comp : 1.0f;
out[b] = comp * ratio + in[b] * (1.0f - ratio);
}
}
else
{
gint b;
for (b = RED; b < ALPHA; b++)
{
out[b] = in[b];
}
}
out[ALPHA] = in[ALPHA];
in += 4;
layer += 4;
out += 4;
if (mask)
mask++;
}
return TRUE;
}

View File

@ -0,0 +1,57 @@
/* 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
*
* pikaoperationburnlegacy.h
* Copyright (C) 2008 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_OPERATION_BURN_LEGACY_H__
#define __PIKA_OPERATION_BURN_LEGACY_H__
#include "operations/layer-modes/pikaoperationlayermode.h"
#define PIKA_TYPE_OPERATION_BURN_LEGACY (pika_operation_burn_legacy_get_type ())
#define PIKA_OPERATION_BURN_LEGACY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PIKA_TYPE_OPERATION_BURN_LEGACY, PikaOperationBurnLegacy))
#define PIKA_OPERATION_BURN_LEGACY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PIKA_TYPE_OPERATION_BURN_LEGACY, PikaOperationBurnLegacyClass))
#define PIKA_IS_OPERATION_BURN_LEGACY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PIKA_TYPE_OPERATION_BURN_LEGACY))
#define PIKA_IS_OPERATION_BURN_LEGACY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PIKA_TYPE_OPERATION_BURN_LEGACY))
#define PIKA_OPERATION_BURN_LEGACY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PIKA_TYPE_OPERATION_BURN_LEGACY, PikaOperationBurnLegacyClass))
typedef struct _PikaOperationBurnLegacy PikaOperationBurnLegacy;
typedef struct _PikaOperationBurnLegacyClass PikaOperationBurnLegacyClass;
struct _PikaOperationBurnLegacy
{
PikaOperationLayerMode parent_instance;
};
struct _PikaOperationBurnLegacyClass
{
PikaOperationLayerModeClass parent_class;
};
GType pika_operation_burn_legacy_get_type (void) G_GNUC_CONST;
#endif /* __PIKA_OPERATION_BURN_LEGACY_H__ */

View File

@ -0,0 +1,128 @@
/* 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
*
* pikaoperationdarkenonlymode.c
* Copyright (C) 2008 Michael Natterer <mitch@gimp.org>
* 2012 Ville Sokk <ville.sokk@gmail.com>
*
* 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/>.
*/
#include "config.h"
#include <gegl-plugin.h>
#include "../operations-types.h"
#include "pikaoperationdarkenonlylegacy.h"
static gboolean pika_operation_darken_only_legacy_process (GeglOperation *op,
void *in,
void *layer,
void *mask,
void *out,
glong samples,
const GeglRectangle *roi,
gint level);
G_DEFINE_TYPE (PikaOperationDarkenOnlyLegacy, pika_operation_darken_only_legacy,
PIKA_TYPE_OPERATION_LAYER_MODE)
static void
pika_operation_darken_only_legacy_class_init (PikaOperationDarkenOnlyLegacyClass *klass)
{
GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
PikaOperationLayerModeClass *layer_mode_class = PIKA_OPERATION_LAYER_MODE_CLASS (klass);
gegl_operation_class_set_keys (operation_class,
"name", "pika:darken-only-legacy",
"description", "PIKA darken only mode operation",
NULL);
layer_mode_class->process = pika_operation_darken_only_legacy_process;
}
static void
pika_operation_darken_only_legacy_init (PikaOperationDarkenOnlyLegacy *self)
{
}
static gboolean
pika_operation_darken_only_legacy_process (GeglOperation *op,
void *in_p,
void *layer_p,
void *mask_p,
void *out_p,
glong samples,
const GeglRectangle *roi,
gint level)
{
PikaOperationLayerMode *layer_mode = (gpointer) op;
gfloat *in = in_p;
gfloat *out = out_p;
gfloat *layer = layer_p;
gfloat *mask = mask_p;
gfloat opacity = layer_mode->opacity;
while (samples--)
{
gfloat comp_alpha, new_alpha;
comp_alpha = MIN (in[ALPHA], layer[ALPHA]) * opacity;
if (mask)
comp_alpha *= *mask;
new_alpha = in[ALPHA] + (1.0f - in[ALPHA]) * comp_alpha;
if (new_alpha && comp_alpha)
{
gint b;
gfloat ratio = comp_alpha / new_alpha;
for (b = RED; b < ALPHA; b++)
{
gfloat comp = MIN (in[b], layer[b]);
out[b] = comp * ratio + in[b] * (1.0f - ratio);
}
}
else
{
gint b;
for (b = RED; b < ALPHA; b++)
{
out[b] = in[b];
}
}
out[ALPHA] = in[ALPHA];
in += 4;
layer += 4;
out += 4;
if (mask)
mask++;
}
return TRUE;
}

View File

@ -0,0 +1,57 @@
/* 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
*
* pikaoperationdarkenonlylegacy.h
* Copyright (C) 2008 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_OPERATION_DARKEN_ONLY_LEGACY_H__
#define __PIKA_OPERATION_DARKEN_ONLY_LEGACY_H__
#include "operations/layer-modes/pikaoperationlayermode.h"
#define PIKA_TYPE_OPERATION_DARKEN_ONLY_LEGACY (pika_operation_darken_only_legacy_get_type ())
#define PIKA_OPERATION_DARKEN_ONLY_LEGACY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PIKA_TYPE_OPERATION_DARKEN_ONLY_MODE, PikaOperationDarkenOnlyLegacy))
#define PIKA_OPERATION_DARKEN_ONLY_LEGACY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PIKA_TYPE_OPERATION_DARKEN_ONLY_MODE, PikaOperationDarkenOnlyLegacyClass))
#define PIKA_IS_OPERATION_DARKEN_ONLY_LEGACY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PIKA_TYPE_OPERATION_DARKEN_ONLY_MODE))
#define PIKA_IS_OPERATION_DARKEN_ONLY_LEGACY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PIKA_TYPE_OPERATION_DARKEN_ONLY_MODE))
#define PIKA_OPERATION_DARKEN_ONLY_LEGACY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PIKA_TYPE_OPERATION_DARKEN_ONLY_MODE, PikaOperationDarkenOnlyLegacyClass))
typedef struct _PikaOperationDarkenOnlyLegacy PikaOperationDarkenOnlyLegacy;
typedef struct _PikaOperationDarkenOnlyLegacyClass PikaOperationDarkenOnlyLegacyClass;
struct _PikaOperationDarkenOnlyLegacy
{
PikaOperationLayerMode parent_instance;
};
struct _PikaOperationDarkenOnlyLegacyClass
{
PikaOperationLayerModeClass parent_class;
};
GType pika_operation_darken_only_legacy_get_type (void) G_GNUC_CONST;
#endif /* __PIKA_OPERATION_DARKEN_ONLY_LEGACY_H__ */

View File

@ -0,0 +1,130 @@
/* 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
*
* pikaoperationdifferencemode.c
* Copyright (C) 2008 Michael Natterer <mitch@gimp.org>
* 2012 Ville Sokk <ville.sokk@gmail.com>
*
* 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/>.
*/
#include "config.h"
#include <gegl-plugin.h>
#include "../operations-types.h"
#include "pikaoperationdifferencelegacy.h"
static gboolean pika_operation_difference_legacy_process (GeglOperation *op,
void *in,
void *layer,
void *mask,
void *out,
glong samples,
const GeglRectangle *roi,
gint level);
G_DEFINE_TYPE (PikaOperationDifferenceLegacy, pika_operation_difference_legacy,
PIKA_TYPE_OPERATION_LAYER_MODE)
static void
pika_operation_difference_legacy_class_init (PikaOperationDifferenceLegacyClass *klass)
{
GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
PikaOperationLayerModeClass *layer_mode_class = PIKA_OPERATION_LAYER_MODE_CLASS (klass);
gegl_operation_class_set_keys (operation_class,
"name", "pika:difference-legacy",
"description", "PIKA difference mode operation",
NULL);
layer_mode_class->process = pika_operation_difference_legacy_process;
}
static void
pika_operation_difference_legacy_init (PikaOperationDifferenceLegacy *self)
{
}
static gboolean
pika_operation_difference_legacy_process (GeglOperation *op,
void *in_p,
void *layer_p,
void *mask_p,
void *out_p,
glong samples,
const GeglRectangle *roi,
gint level)
{
PikaOperationLayerMode *layer_mode = (gpointer) op;
gfloat *in = in_p;
gfloat *out = out_p;
gfloat *layer = layer_p;
gfloat *mask = mask_p;
gfloat opacity = layer_mode->opacity;
while (samples--)
{
gfloat comp_alpha, new_alpha;
comp_alpha = MIN (in[ALPHA], layer[ALPHA]) * opacity;
if (mask)
comp_alpha *= *mask;
new_alpha = in[ALPHA] + (1.0f - in[ALPHA]) * comp_alpha;
if (comp_alpha && new_alpha)
{
gfloat ratio = comp_alpha / new_alpha;
gint b;
for (b = RED; b < ALPHA; b++)
{
gfloat comp = in[b] - layer[b];
comp = (comp < 0.0f) ? -comp : comp;
out[b] = comp * ratio + in[b] * (1.0f - ratio);
}
}
else
{
gint b;
for (b = RED; b < ALPHA; b++)
{
out[b] = in[b];
}
}
out[ALPHA] = in[ALPHA];
in += 4;
layer += 4;
out += 4;
if (mask)
mask++;
}
return TRUE;
}

View File

@ -0,0 +1,57 @@
/* 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
*
* pikaoperationdifferencelegacy.h
* Copyright (C) 2008 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_OPERATION_DIFFERENCE_LEGACY_H__
#define __PIKA_OPERATION_DIFFERENCE_LEGACY_H__
#include "operations/layer-modes/pikaoperationlayermode.h"
#define PIKA_TYPE_OPERATION_DIFFERENCE_LEGACY (pika_operation_difference_legacy_get_type ())
#define PIKA_OPERATION_DIFFERENCE_LEGACY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PIKA_TYPE_OPERATION_DIFFERENCE_LEGACY, PikaOperationDifferenceLegacy))
#define PIKA_OPERATION_DIFFERENCE_LEGACY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PIKA_TYPE_OPERATION_DIFFERENCE_LEGACY, PikaOperationDifferenceLegacyClass))
#define PIKA_IS_OPERATION_DIFFERENCE_LEGACY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PIKA_TYPE_OPERATION_DIFFERENCE_LEGACY))
#define PIKA_IS_OPERATION_DIFFERENCE_LEGACY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PIKA_TYPE_OPERATION_DIFFERENCE_LEGACY))
#define PIKA_OPERATION_DIFFERENCE_LEGACY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PIKA_TYPE_OPERATION_DIFFERENCE_LEGACY, PikaOperationDifferenceLegacyClass))
typedef struct _PikaOperationDifferenceLegacy PikaOperationDifferenceLegacy;
typedef struct _PikaOperationDifferenceLegacyClass PikaOperationDifferenceLegacyClass;
struct _PikaOperationDifferenceLegacy
{
PikaOperationLayerMode parent_instance;
};
struct _PikaOperationDifferenceLegacyClass
{
PikaOperationLayerModeClass parent_class;
};
GType pika_operation_difference_legacy_get_type (void) G_GNUC_CONST;
#endif /* __PIKA_OPERATION_DIFFERENCE_LEGACY_H__ */

View File

@ -0,0 +1,131 @@
/* 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
*
* pikaoperationdividemode.c
* Copyright (C) 2008 Michael Natterer <mitch@gimp.org>
* 2012 Ville Sokk <ville.sokk@gmail.com>
*
* 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/>.
*/
#include "config.h"
#include <gegl-plugin.h>
#include "libpikamath/pikamath.h"
#include "../operations-types.h"
#include "pikaoperationdividelegacy.h"
static gboolean pika_operation_divide_legacy_process (GeglOperation *op,
void *in,
void *layer,
void *mask,
void *out,
glong samples,
const GeglRectangle *roi,
gint level);
G_DEFINE_TYPE (PikaOperationDivideLegacy, pika_operation_divide_legacy,
PIKA_TYPE_OPERATION_LAYER_MODE)
static void
pika_operation_divide_legacy_class_init (PikaOperationDivideLegacyClass *klass)
{
GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
PikaOperationLayerModeClass *layer_mode_class = PIKA_OPERATION_LAYER_MODE_CLASS (klass);
gegl_operation_class_set_keys (operation_class,
"name", "pika:divide-legacy",
"description", "PIKA divide mode operation",
NULL);
layer_mode_class->process = pika_operation_divide_legacy_process;
}
static void
pika_operation_divide_legacy_init (PikaOperationDivideLegacy *self)
{
}
static gboolean
pika_operation_divide_legacy_process (GeglOperation *op,
void *in_p,
void *layer_p,
void *mask_p,
void *out_p,
glong samples,
const GeglRectangle *roi,
gint level)
{
PikaOperationLayerMode *layer_mode = (gpointer) op;
gfloat *in = in_p;
gfloat *out = out_p;
gfloat *layer = layer_p;
gfloat *mask = mask_p;
gfloat opacity = layer_mode->opacity;
while (samples--)
{
gfloat comp_alpha, new_alpha;
comp_alpha = MIN (in[ALPHA], layer[ALPHA]) * opacity;
if (mask)
comp_alpha *= *mask;
new_alpha = in[ALPHA] + (1.0f - in[ALPHA]) * comp_alpha;
if (comp_alpha && new_alpha)
{
gint b;
gfloat ratio = comp_alpha / new_alpha;
for (b = RED; b < ALPHA; b++)
{
gfloat comp = in[b] / layer[b];
comp = SAFE_CLAMP (comp, 0.0f, 1.0f);
out[b] = comp * ratio + in[b] * (1.0f - ratio);
}
}
else
{
gint b;
for (b = RED; b < ALPHA; b++)
{
out[b] = in[b];
}
}
out[ALPHA] = in[ALPHA];
in += 4;
layer += 4;
out += 4;
if (mask)
mask++;
}
return TRUE;
}

View File

@ -0,0 +1,57 @@
/* 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
*
* pikaoperationdividelegacy.h
* Copyright (C) 2008 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_OPERATION_DIVIDE_LEGACY_H__
#define __PIKA_OPERATION_DIVIDE_LEGACY_H__
#include "operations/layer-modes/pikaoperationlayermode.h"
#define PIKA_TYPE_OPERATION_DIVIDE_LEGACY (pika_operation_divide_legacy_get_type ())
#define PIKA_OPERATION_DIVIDE_LEGACY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PIKA_TYPE_OPERATION_DIVIDE_LEGACY, PikaOperationDivideLegacy))
#define PIKA_OPERATION_DIVIDE_LEGACY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PIKA_TYPE_OPERATION_DIVIDE_LEGACY, PikaOperationDivideLegacyClass))
#define PIKA_IS_OPERATION_DIVIDE_LEGACY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PIKA_TYPE_OPERATION_DIVIDE_LEGACY))
#define PIKA_IS_OPERATION_DIVIDE_LEGACY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PIKA_TYPE_OPERATION_DIVIDE_LEGACY))
#define PIKA_OPERATION_DIVIDE_LEGACY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PIKA_TYPE_OPERATION_DIVIDE_LEGACY, PikaOperationDivideLegacyClass))
typedef struct _PikaOperationDivideLegacy PikaOperationDivideLegacy;
typedef struct _PikaOperationDivideLegacyClass PikaOperationDivideLegacyClass;
struct _PikaOperationDivideLegacy
{
PikaOperationLayerMode parent_instance;
};
struct _PikaOperationDivideLegacyClass
{
PikaOperationLayerModeClass parent_class;
};
GType pika_operation_divide_legacy_get_type (void) G_GNUC_CONST;
#endif /* __PIKA_OPERATION_DIVIDE_LEGACY_H__ */

View File

@ -0,0 +1,131 @@
/* 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
*
* pikaoperationdodgelegacy.c
* Copyright (C) 2008 Michael Natterer <mitch@gimp.org>
* 2012 Ville Sokk <ville.sokk@gmail.com>
*
* 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/>.
*/
#include "config.h"
#include <gegl-plugin.h>
#include "libpikamath/pikamath.h"
#include "../operations-types.h"
#include "pikaoperationdodgelegacy.h"
static gboolean pika_operation_dodge_legacy_process (GeglOperation *op,
void *in,
void *layer,
void *mask,
void *out,
glong samples,
const GeglRectangle *roi,
gint level);
G_DEFINE_TYPE (PikaOperationDodgeLegacy, pika_operation_dodge_legacy,
PIKA_TYPE_OPERATION_LAYER_MODE)
static void
pika_operation_dodge_legacy_class_init (PikaOperationDodgeLegacyClass *klass)
{
GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
PikaOperationLayerModeClass *layer_mode_class = PIKA_OPERATION_LAYER_MODE_CLASS (klass);
gegl_operation_class_set_keys (operation_class,
"name", "pika:dodge-legacy",
"description", "PIKA dodge mode operation",
NULL);
layer_mode_class->process = pika_operation_dodge_legacy_process;
}
static void
pika_operation_dodge_legacy_init (PikaOperationDodgeLegacy *self)
{
}
static gboolean
pika_operation_dodge_legacy_process (GeglOperation *op,
void *in_p,
void *layer_p,
void *mask_p,
void *out_p,
glong samples,
const GeglRectangle *roi,
gint level)
{
PikaOperationLayerMode *layer_mode = (gpointer) op;
gfloat *in = in_p;
gfloat *out = out_p;
gfloat *layer = layer_p;
gfloat *mask = mask_p;
gfloat opacity = layer_mode->opacity;
while (samples--)
{
gfloat comp_alpha, new_alpha;
comp_alpha = MIN (in[ALPHA], layer[ALPHA]) * opacity;
if (mask)
comp_alpha *= *mask;
new_alpha = in[ALPHA] + (1.0f - in[ALPHA]) * comp_alpha;
if (comp_alpha && new_alpha)
{
gint b;
gfloat ratio = comp_alpha / new_alpha;
for (b = RED; b < ALPHA; b++)
{
gfloat comp = in[b] / (1.0f - layer[b]);
comp = SAFE_CLAMP (comp, 0.0f, 1.0f);
out[b] = comp * ratio + in[b] * (1.0f - ratio);
}
}
else
{
gint b;
for (b = RED; b < ALPHA; b++)
{
out[b] = in[b];
}
}
out[ALPHA] = in[ALPHA];
in += 4;
layer += 4;
out += 4;
if (mask)
mask++;
}
return TRUE;
}

View File

@ -0,0 +1,57 @@
/* 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
*
* pikaoperationdodgelegacy.h
* Copyright (C) 2008 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_OPERATION_DODGE_LEGACY_H__
#define __PIKA_OPERATION_DODGE_LEGACY_H__
#include "operations/layer-modes/pikaoperationlayermode.h"
#define PIKA_TYPE_OPERATION_DODGE_LEGACY (pika_operation_dodge_legacy_get_type ())
#define PIKA_OPERATION_DODGE_LEGACY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PIKA_TYPE_OPERATION_DODGE_LEGACY, PikaOperationDodgeLegacy))
#define PIKA_OPERATION_DODGE_LEGACY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PIKA_TYPE_OPERATION_DODGE_LEGACY, PikaOperationDodgeLegacyClass))
#define PIKA_IS_OPERATION_DODGE_LEGACY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PIKA_TYPE_OPERATION_DODGE_LEGACY))
#define PIKA_IS_OPERATION_DODGE_LEGACY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PIKA_TYPE_OPERATION_DODGE_LEGACY))
#define PIKA_OPERATION_DODGE_LEGACY_GET_CLASS(obj)(G_TYPE_INSTANCE_GET_CLASS ((obj), PIKA_TYPE_OPERATION_DODGE_LEGACY, PikaOperationDodgeLegacyClass))
typedef struct _PikaOperationDodgeLegacy PikaOperationDodgeLegacy;
typedef struct _PikaOperationDodgeLegacyClass PikaOperationDodgeLegacyClass;
struct _PikaOperationDodgeLegacy
{
PikaOperationLayerMode parent_instance;
};
struct _PikaOperationDodgeLegacyClass
{
PikaOperationLayerModeClass parent_class;
};
GType pika_operation_dodge_legacy_get_type (void) G_GNUC_CONST;
#endif /* __PIKA_OPERATION_DODGE_LEGACY_H__ */

View File

@ -0,0 +1,129 @@
/* 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
*
* pikaoperationgrainextractmode.c
* Copyright (C) 2008 Michael Natterer <mitch@gimp.org>
* 2012 Ville Sokk <ville.sokk@gmail.com>
*
* 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/>.
*/
#include "config.h"
#include <gegl-plugin.h>
#include "../operations-types.h"
#include "pikaoperationgrainextractlegacy.h"
static gboolean pika_operation_grain_extract_legacy_process (GeglOperation *op,
void *in,
void *layer,
void *mask,
void *out,
glong samples,
const GeglRectangle *roi,
gint level);
G_DEFINE_TYPE (PikaOperationGrainExtractLegacy, pika_operation_grain_extract_legacy,
PIKA_TYPE_OPERATION_LAYER_MODE)
static void
pika_operation_grain_extract_legacy_class_init (PikaOperationGrainExtractLegacyClass *klass)
{
GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
PikaOperationLayerModeClass *layer_mode_class = PIKA_OPERATION_LAYER_MODE_CLASS (klass);
gegl_operation_class_set_keys (operation_class,
"name", "pika:grain-extract-legacy",
"description", "PIKA grain extract mode operation",
NULL);
layer_mode_class->process = pika_operation_grain_extract_legacy_process;
}
static void
pika_operation_grain_extract_legacy_init (PikaOperationGrainExtractLegacy *self)
{
}
static gboolean
pika_operation_grain_extract_legacy_process (GeglOperation *op,
void *in_p,
void *layer_p,
void *mask_p,
void *out_p,
glong samples,
const GeglRectangle *roi,
gint level)
{
PikaOperationLayerMode *layer_mode = (gpointer) op;
gfloat *in = in_p;
gfloat *out = out_p;
gfloat *layer = layer_p;
gfloat *mask = mask_p;
gfloat opacity = layer_mode->opacity;
while (samples--)
{
gfloat comp_alpha, new_alpha;
comp_alpha = MIN (in[ALPHA], layer[ALPHA]) * opacity;
if (mask)
comp_alpha *= *mask;
new_alpha = in[ALPHA] + (1.0f - in[ALPHA]) * comp_alpha;
if (comp_alpha && new_alpha)
{
gfloat ratio = comp_alpha / new_alpha;
gint b;
for (b = RED; b < ALPHA; b++)
{
gfloat comp = in[b] - layer[b] + 128.0f / 255.0f;
comp = CLAMP (comp, 0.0f, 1.0f);
out[b] = comp * ratio + in[b] * (1.0f - ratio);
}
}
else
{
gint b;
for (b = RED; b < ALPHA; b++)
{
out[b] = in[b];
}
}
out[ALPHA] = in[ALPHA];
in += 4;
layer += 4;
out += 4;
if (mask)
mask++;
}
return TRUE;
}

View File

@ -0,0 +1,57 @@
/* 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
*
* pikaoperationgrainextractlegacy.h
* Copyright (C) 2008 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_OPERATION_GRAIN_EXTRACT_LEGACY_H__
#define __PIKA_OPERATION_GRAIN_EXTRACT_LEGACY_H__
#include "operations/layer-modes/pikaoperationlayermode.h"
#define PIKA_TYPE_OPERATION_GRAIN_EXTRACT_LEGACY (pika_operation_grain_extract_legacy_get_type ())
#define PIKA_OPERATION_GRAIN_EXTRACT_LEGACY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PIKA_TYPE_OPERATION_GRAIN_EXTRACT_LEGACY, PikaOperationGrainExtractLegacy))
#define PIKA_OPERATION_GRAIN_EXTRACT_LEGACY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PIKA_TYPE_OPERATION_GRAIN_EXTRACT_LEGACY, PikaOperationGrainExtractLegacyClass))
#define PIKA_IS_OPERATION_GRAIN_EXTRACT_LEGACY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PIKA_TYPE_OPERATION_GRAIN_EXTRACT_LEGACY))
#define PIKA_IS_OPERATION_GRAIN_EXTRACT_LEGACY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PIKA_TYPE_OPERATION_GRAIN_EXTRACT_LEGACY))
#define PIKA_OPERATION_GRAIN_EXTRACT_LEGACY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PIKA_TYPE_OPERATION_GRAIN_EXTRACT_LEGACY, PikaOperationGrainExtractLegacyClass))
typedef struct _PikaOperationGrainExtractLegacy PikaOperationGrainExtractLegacy;
typedef struct _PikaOperationGrainExtractLegacyClass PikaOperationGrainExtractLegacyClass;
struct _PikaOperationGrainExtractLegacy
{
PikaOperationLayerMode parent_instance;
};
struct _PikaOperationGrainExtractLegacyClass
{
PikaOperationLayerModeClass parent_class;
};
GType pika_operation_grain_extract_legacy_get_type (void) G_GNUC_CONST;
#endif /* __PIKA_OPERATION_GRAIN_EXTRACT_LEGACY_H__ */

View File

@ -0,0 +1,129 @@
/* 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
*
* pikaoperationgrainmergemode.c
* Copyright (C) 2008 Michael Natterer <mitch@gimp.org>
* 2012 Ville Sokk <ville.sokk@gmail.com>
*
* 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/>.
*/
#include "config.h"
#include <gegl-plugin.h>
#include "../operations-types.h"
#include "pikaoperationgrainmergelegacy.h"
static gboolean pika_operation_grain_merge_legacy_process (GeglOperation *op,
void *in,
void *layer,
void *mask,
void *out,
glong samples,
const GeglRectangle *roi,
gint level);
G_DEFINE_TYPE (PikaOperationGrainMergeLegacy, pika_operation_grain_merge_legacy,
PIKA_TYPE_OPERATION_LAYER_MODE)
static void
pika_operation_grain_merge_legacy_class_init (PikaOperationGrainMergeLegacyClass *klass)
{
GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
PikaOperationLayerModeClass *layer_mode_class = PIKA_OPERATION_LAYER_MODE_CLASS (klass);
gegl_operation_class_set_keys (operation_class,
"name", "pika:grain-merge-legacy",
"description", "PIKA grain merge mode operation",
NULL);
layer_mode_class->process = pika_operation_grain_merge_legacy_process;
}
static void
pika_operation_grain_merge_legacy_init (PikaOperationGrainMergeLegacy *self)
{
}
static gboolean
pika_operation_grain_merge_legacy_process (GeglOperation *op,
void *in_p,
void *layer_p,
void *mask_p,
void *out_p,
glong samples,
const GeglRectangle *roi,
gint level)
{
PikaOperationLayerMode *layer_mode = (gpointer) op;
gfloat *in = in_p;
gfloat *out = out_p;
gfloat *layer = layer_p;
gfloat *mask = mask_p;
gfloat opacity = layer_mode->opacity;
while (samples--)
{
gfloat comp_alpha, new_alpha;
comp_alpha = MIN (in[ALPHA], layer[ALPHA]) * opacity;
if (mask)
comp_alpha *= *mask;
new_alpha = in[ALPHA] + (1.0f - in[ALPHA]) * comp_alpha;
if (comp_alpha && new_alpha)
{
gfloat ratio = comp_alpha / new_alpha;
gint b;
for (b = RED; b < ALPHA; b++)
{
gfloat comp = in[b] + layer[b] - 128.0f / 255.0f;
comp = CLAMP (comp, 0.0f, 1.0f);
out[b] = comp * ratio + in[b] * (1.0f - ratio);
}
}
else
{
gint b;
for (b = RED; b < ALPHA; b++)
{
out[b] = in[b];
}
}
out[ALPHA] = in[ALPHA];
in += 4;
layer += 4;
out += 4;
if (mask)
mask ++;
}
return TRUE;
}

View File

@ -0,0 +1,57 @@
/* 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
*
* pikaoperationgrainmergelegacy.h
* Copyright (C) 2008 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_OPERATION_GRAIN_MERGE_LEGACY_H__
#define __PIKA_OPERATION_GRAIN_MERGE_LEGACY_H__
#include "operations/layer-modes/pikaoperationlayermode.h"
#define PIKA_TYPE_OPERATION_GRAIN_MERGE_LEGACY (pika_operation_grain_merge_legacy_get_type ())
#define PIKA_OPERATION_GRAIN_MERGE_LEGACY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PIKA_TYPE_OPERATION_GRAIN_MERGE_LEGACY, PikaOperationGrainMergeLegacy))
#define PIKA_OPERATION_GRAIN_MERGE_LEGACY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PIKA_TYPE_OPERATION_GRAIN_MERGE_LEGACY, PikaOperationGrainMergeLegacyClass))
#define PIKA_IS_OPERATION_GRAIN_MERGE_LEGACY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PIKA_TYPE_OPERATION_GRAIN_MERGE_LEGACY))
#define PIKA_IS_OPERATION_GRAIN_MERGE_LEGACY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PIKA_TYPE_OPERATION_GRAIN_MERGE_LEGACY))
#define PIKA_OPERATION_GRAIN_MERGE_LEGACY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PIKA_TYPE_OPERATION_GRAIN_MERGE_LEGACY, PikaOperationGrainMergeLegacyClass))
typedef struct _PikaOperationGrainMergeLegacy PikaOperationGrainMergeLegacy;
typedef struct _PikaOperationGrainMergeLegacyClass PikaOperationGrainMergeLegacyClass;
struct _PikaOperationGrainMergeLegacy
{
PikaOperationLayerMode parent_instance;
};
struct _PikaOperationGrainMergeLegacyClass
{
PikaOperationLayerModeClass parent_class;
};
GType pika_operation_grain_merge_legacy_get_type (void) G_GNUC_CONST;
#endif /* __PIKA_OPERATION_GRAIN_MERGE_LEGACY_H__ */

View File

@ -0,0 +1,139 @@
/* 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
*
* pikaoperationhardlightmode.c
* Copyright (C) 2008 Michael Natterer <mitch@gimp.org>
* 2012 Ville Sokk <ville.sokk@gmail.com>
*
* 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/>.
*/
#include "config.h"
#include <gegl-plugin.h>
#include "../operations-types.h"
#include "pikaoperationhardlightlegacy.h"
static gboolean pika_operation_hardlight_legacy_process (GeglOperation *op,
void *in,
void *layer,
void *mask,
void *out,
glong samples,
const GeglRectangle *roi,
gint level);
G_DEFINE_TYPE (PikaOperationHardlightLegacy, pika_operation_hardlight_legacy,
PIKA_TYPE_OPERATION_LAYER_MODE)
static void
pika_operation_hardlight_legacy_class_init (PikaOperationHardlightLegacyClass *klass)
{
GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
PikaOperationLayerModeClass *layer_mode_class = PIKA_OPERATION_LAYER_MODE_CLASS (klass);
gegl_operation_class_set_keys (operation_class,
"name", "pika:hardlight-legacy",
"description", "PIKA hardlight mode operation",
NULL);
layer_mode_class->process = pika_operation_hardlight_legacy_process;
}
static void
pika_operation_hardlight_legacy_init (PikaOperationHardlightLegacy *self)
{
}
static gboolean
pika_operation_hardlight_legacy_process (GeglOperation *op,
void *in_p,
void *layer_p,
void *mask_p,
void *out_p,
glong samples,
const GeglRectangle *roi,
gint level)
{
PikaOperationLayerMode *layer_mode = (gpointer) op;
gfloat *in = in_p;
gfloat *out = out_p;
gfloat *layer = layer_p;
gfloat *mask = mask_p;
gfloat opacity = layer_mode->opacity;
while (samples--)
{
gfloat comp_alpha, new_alpha;
comp_alpha = MIN (in[ALPHA], layer[ALPHA]) * opacity;
if (mask)
comp_alpha *= *mask;
new_alpha = in[ALPHA] + (1.0f - in[ALPHA]) * comp_alpha;
if (comp_alpha && new_alpha)
{
gfloat ratio = comp_alpha / new_alpha;
gint b;
for (b = RED; b < ALPHA; b++)
{
gfloat comp;
if (layer[b] > 128.0f / 255.0f)
{
comp = (1.0 - in[b]) * (1.0 - (layer[b] - 128.0f / 255.0f) * 2.0f);
comp = MIN (1.0f - comp, 1.0f);
}
else
{
comp = in[b] * (layer[b] * 2.0f);
comp = MIN (comp, 1.0f);
}
out[b] = comp * ratio + in[b] * (1.0f - ratio);
}
}
else
{
gint b;
for (b = RED; b < ALPHA; b++)
{
out[b] = in[b];
}
}
out[ALPHA] = in[ALPHA];
in += 4;
layer += 4;
out += 4;
if (mask)
mask ++;
}
return TRUE;
}

View File

@ -0,0 +1,57 @@
/* 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
*
* pikaoperationhardlightlegacy.h
* Copyright (C) 2008 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_OPERATION_HARDLIGHT_LEGACY_H__
#define __PIKA_OPERATION_HARDLIGHT_LEGACY_H__
#include "operations/layer-modes/pikaoperationlayermode.h"
#define PIKA_TYPE_OPERATION_HARDLIGHT_LEGACY (pika_operation_hardlight_legacy_get_type ())
#define PIKA_OPERATION_HARDLIGHT_LEGACY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PIKA_TYPE_OPERATION_HARDLIGHT_LEGACY, PikaOperationHardlightLegacy))
#define PIKA_OPERATION_HARDLIGHT_LEGACY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PIKA_TYPE_OPERATION_HARDLIGHT_LEGACY, PikaOperationHardlightLegacyClass))
#define PIKA_IS_OPERATION_HARDLIGHT_LEGACY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PIKA_TYPE_OPERATION_HARDLIGHT_LEGACY))
#define PIKA_IS_OPERATION_HARDLIGHT_LEGACY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PIKA_TYPE_OPERATION_HARDLIGHT_LEGACY))
#define PIKA_OPERATION_HARDLIGHT_LEGACY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PIKA_TYPE_OPERATION_HARDLIGHT_LEGACY, PikaOperationHardlightLegacyClass))
typedef struct _PikaOperationHardlightLegacy PikaOperationHardlightLegacy;
typedef struct _PikaOperationHardlightLegacyClass PikaOperationHardlightLegacyClass;
struct _PikaOperationHardlightLegacy
{
PikaOperationLayerMode parent_instance;
};
struct _PikaOperationHardlightLegacyClass
{
PikaOperationLayerModeClass parent_class;
};
GType pika_operation_hardlight_legacy_get_type (void) G_GNUC_CONST;
#endif /* __PIKA_OPERATION_HARDLIGHT_LEGACY_H__ */

View File

@ -0,0 +1,145 @@
/* 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
*
* pikaoperationcolormode.c
* Copyright (C) 2008 Michael Natterer <mitch@gimp.org>
* 2012 Ville Sokk <ville.sokk@gmail.com>
*
* 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/>.
*/
#include "config.h"
#include <gegl-plugin.h>
#include <cairo.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "libpikacolor/pikacolor.h"
#include "../operations-types.h"
#include "pikaoperationhslcolorlegacy.h"
static gboolean pika_operation_hsl_color_legacy_process (GeglOperation *op,
void *in,
void *layer,
void *mask,
void *out,
glong samples,
const GeglRectangle *roi,
gint level);
G_DEFINE_TYPE (PikaOperationHslColorLegacy, pika_operation_hsl_color_legacy,
PIKA_TYPE_OPERATION_LAYER_MODE)
static void
pika_operation_hsl_color_legacy_class_init (PikaOperationHslColorLegacyClass *klass)
{
GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
PikaOperationLayerModeClass *layer_mode_class = PIKA_OPERATION_LAYER_MODE_CLASS (klass);
gegl_operation_class_set_keys (operation_class,
"name", "pika:hsl-color-legacy",
"description", "PIKA color mode operation",
NULL);
layer_mode_class->process = pika_operation_hsl_color_legacy_process;
}
static void
pika_operation_hsl_color_legacy_init (PikaOperationHslColorLegacy *self)
{
}
static gboolean
pika_operation_hsl_color_legacy_process (GeglOperation *op,
void *in_p,
void *layer_p,
void *mask_p,
void *out_p,
glong samples,
const GeglRectangle *roi,
gint level)
{
PikaOperationLayerMode *layer_mode = (gpointer) op;
gfloat *in = in_p;
gfloat *out = out_p;
gfloat *layer = layer_p;
gfloat *mask = mask_p;
gfloat opacity = layer_mode->opacity;
while (samples--)
{
PikaHSL layer_hsl, out_hsl;
PikaRGB layer_rgb = {layer[0], layer[1], layer[2]};
PikaRGB out_rgb = {in[0], in[1], in[2]};
gfloat comp_alpha, new_alpha;
comp_alpha = MIN (in[ALPHA], layer[ALPHA]) * opacity;
if (mask)
comp_alpha *= *mask;
new_alpha = in[ALPHA] + (1.0f - in[ALPHA]) * comp_alpha;
if (comp_alpha && new_alpha)
{
gint b;
gfloat out_tmp[3];
gfloat ratio = comp_alpha / new_alpha;
pika_rgb_to_hsl (&layer_rgb, &layer_hsl);
pika_rgb_to_hsl (&out_rgb, &out_hsl);
out_hsl.h = layer_hsl.h;
out_hsl.s = layer_hsl.s;
pika_hsl_to_rgb (&out_hsl, &out_rgb);
out_tmp[0] = out_rgb.r;
out_tmp[1] = out_rgb.g;
out_tmp[2] = out_rgb.b;
for (b = RED; b < ALPHA; b++)
{
out[b] = out_tmp[b] * ratio + in[b] * (1.0f - ratio);
}
}
else
{
gint b;
for (b = RED; b < ALPHA; b++)
{
out[b] = in[b];
}
}
out[ALPHA] = in[ALPHA];
in += 4;
layer += 4;
out += 4;
if (mask)
mask++;
}
return TRUE;
}

View File

@ -0,0 +1,57 @@
/* 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
*
* pikaoperationhslcolorlegacy.h
* Copyright (C) 2008 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_OPERATION_HSL_COLOR_LEGACY_H__
#define __PIKA_OPERATION_HSL_COLOR_LEGACY_H__
#include "operations/layer-modes/pikaoperationlayermode.h"
#define PIKA_TYPE_OPERATION_HSL_COLOR_LEGACY (pika_operation_hsl_color_legacy_get_type ())
#define PIKA_OPERATION_HSL_COLOR_LEGACY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PIKA_TYPE_OPERATION_HSL_COLOR_LEGACY, PikaOperationHslColorLegacy))
#define PIKA_OPERATION_HSL_COLOR_LEGACY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PIKA_TYPE_OPERATION_HSL_COLOR_LEGACY, PikaOperationHslColorLegacyClass))
#define PIKA_IS_OPERATION_HSL_COLOR_LEGACY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PIKA_TYPE_OPERATION_HSL_COLOR_LEGACY))
#define PIKA_IS_OPERATION_HSL_COLOR_LEGACY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PIKA_TYPE_OPERATION_HSL_COLOR_LEGACY))
#define PIKA_OPERATION_HSL_COLOR_LEGACY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PIKA_TYPE_OPERATION_HSL_COLOR_LEGACY, PikaOperationHslColorLegacyClass))
typedef struct _PikaOperationHslColorLegacy PikaOperationHslColorLegacy;
typedef struct _PikaOperationHslColorLegacyClass PikaOperationHslColorLegacyClass;
struct _PikaOperationHslColorLegacy
{
PikaOperationLayerMode parent_instance;
};
struct _PikaOperationHslColorLegacyClass
{
PikaOperationLayerModeClass parent_class;
};
GType pika_operation_hsl_color_legacy_get_type (void) G_GNUC_CONST;
#endif /* __PIKA_OPERATION_HSL_COLOR_LEGACY_H__ */

View File

@ -0,0 +1,150 @@
/* 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
*
* pikaoperationhuemode.c
* Copyright (C) 2008 Michael Natterer <mitch@gimp.org>
* 2012 Ville Sokk <ville.sokk@gmail.com>
*
* 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/>.
*/
#include "config.h"
#include <cairo.h>
#include <gegl-plugin.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "libpikacolor/pikacolor.h"
#include "../operations-types.h"
#include "pikaoperationhsvhuelegacy.h"
static gboolean pika_operation_hsv_hue_legacy_process (GeglOperation *op,
void *in,
void *layer,
void *mask,
void *out,
glong samples,
const GeglRectangle *roi,
gint level);
G_DEFINE_TYPE (PikaOperationHsvHueLegacy, pika_operation_hsv_hue_legacy,
PIKA_TYPE_OPERATION_LAYER_MODE)
static void
pika_operation_hsv_hue_legacy_class_init (PikaOperationHsvHueLegacyClass *klass)
{
GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
PikaOperationLayerModeClass *layer_mode_class = PIKA_OPERATION_LAYER_MODE_CLASS (klass);
gegl_operation_class_set_keys (operation_class,
"name", "pika:hsv-hue-legacy",
"description", "PIKA hue mode operation",
NULL);
layer_mode_class->process = pika_operation_hsv_hue_legacy_process;
}
static void
pika_operation_hsv_hue_legacy_init (PikaOperationHsvHueLegacy *self)
{
}
static gboolean
pika_operation_hsv_hue_legacy_process (GeglOperation *op,
void *in_p,
void *layer_p,
void *mask_p,
void *out_p,
glong samples,
const GeglRectangle *roi,
gint level)
{
PikaOperationLayerMode *layer_mode = (gpointer) op;
gfloat *in = in_p;
gfloat *out = out_p;
gfloat *layer = layer_p;
gfloat *mask = mask_p;
gfloat opacity = layer_mode->opacity;
while (samples--)
{
PikaHSV layer_hsv, out_hsv;
PikaRGB layer_rgb = {layer[0], layer[1], layer[2]};
PikaRGB out_rgb = {in[0], in[1], in[2]};
gfloat comp_alpha, new_alpha;
comp_alpha = MIN (in[ALPHA], layer[ALPHA]) * opacity;
if (mask)
comp_alpha *= *mask;
new_alpha = in[ALPHA] + (1.0f - in[ALPHA]) * comp_alpha;
if (comp_alpha && new_alpha)
{
gint b;
gfloat out_tmp[3];
gfloat ratio = comp_alpha / new_alpha;
pika_rgb_to_hsv (&layer_rgb, &layer_hsv);
pika_rgb_to_hsv (&out_rgb, &out_hsv);
/* Composition should have no effect if saturation is zero.
* otherwise, black would be painted red (see bug #123296).
*/
if (layer_hsv.s)
{
out_hsv.h = layer_hsv.h;
}
pika_hsv_to_rgb (&out_hsv, &out_rgb);
out_tmp[0] = out_rgb.r;
out_tmp[1] = out_rgb.g;
out_tmp[2] = out_rgb.b;
for (b = RED; b < ALPHA; b++)
{
out[b] = out_tmp[b] * ratio + in[b] * (1.0f - ratio);
}
}
else
{
gint b;
for (b = RED; b < ALPHA; b++)
{
out[b] = in[b];
}
}
out[ALPHA] = in[ALPHA];
in += 4;
layer += 4;
out += 4;
if (mask)
mask++;
}
return TRUE;
}

View File

@ -0,0 +1,57 @@
/* 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
*
* pikaoperationhsvhuelegacy.h
* Copyright (C) 2008 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_OPERATION_HSV_HUE_LEGACY_H__
#define __PIKA_OPERATION_HSV_HUE_LEGACY_H__
#include "operations/layer-modes/pikaoperationlayermode.h"
#define PIKA_TYPE_OPERATION_HSV_HUE_LEGACY (pika_operation_hsv_hue_legacy_get_type ())
#define PIKA_OPERATION_HSV_HUE_LEGACY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PIKA_TYPE_OPERATION_HSV_HUE_LEGACY, PikaOperationHsvHueLegacy))
#define PIKA_OPERATION_HSV_HUE_LEGACY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PIKA_TYPE_OPERATION_HSV_HUE_LEGACY, PikaOperationHsvHueLegacyClass))
#define PIKA_IS_OPERATION_HSV_HUE_LEGACY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PIKA_TYPE_OPERATION_HSV_HUE_LEGACY))
#define PIKA_IS_OPERATION_HSV_HUE_LEGACY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PIKA_TYPE_OPERATION_HSV_HUE_LEGACY))
#define PIKA_OPERATION_HSV_HUE_LEGACY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PIKA_TYPE_OPERATION_HSV_HUE_LEGACY, PikaOperationHsvHueLegacyClass))
typedef struct _PikaOperationHsvHueLegacy PikaOperationHsvHueLegacy;
typedef struct _PikaOperationHsvHueLegacyClass PikaOperationHsvHueLegacyClass;
struct _PikaOperationHsvHueLegacy
{
PikaOperationLayerMode parent_instance;
};
struct _PikaOperationHsvHueLegacyClass
{
PikaOperationLayerModeClass parent_class;
};
GType pika_operation_hsv_hue_legacy_get_type (void) G_GNUC_CONST;
#endif /* __PIKA_OPERATION_HSV_HUE_LEGACY_H__ */

View File

@ -0,0 +1,144 @@
/* 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
*
* pikaoperationsaturationmode.c
* Copyright (C) 2008 Michael Natterer <mitch@gimp.org>
* 2012 Ville Sokk <ville.sokk@gmail.com>
*
* 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/>.
*/
#include "config.h"
#include <gegl-plugin.h>
#include <cairo.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "libpikacolor/pikacolor.h"
#include "../operations-types.h"
#include "pikaoperationhsvsaturationlegacy.h"
static gboolean pika_operation_hsv_saturation_legacy_process (GeglOperation *op,
void *in,
void *layer,
void *mask,
void *out,
glong samples,
const GeglRectangle *roi,
gint level);
G_DEFINE_TYPE (PikaOperationHsvSaturationLegacy, pika_operation_hsv_saturation_legacy,
PIKA_TYPE_OPERATION_LAYER_MODE)
static void
pika_operation_hsv_saturation_legacy_class_init (PikaOperationHsvSaturationLegacyClass *klass)
{
GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
PikaOperationLayerModeClass *layer_mode_class = PIKA_OPERATION_LAYER_MODE_CLASS (klass);
gegl_operation_class_set_keys (operation_class,
"name", "pika:hsv-saturation-legacy",
"description", "PIKA saturation mode operation",
NULL);
layer_mode_class->process = pika_operation_hsv_saturation_legacy_process;
}
static void
pika_operation_hsv_saturation_legacy_init (PikaOperationHsvSaturationLegacy *self)
{
}
static gboolean
pika_operation_hsv_saturation_legacy_process (GeglOperation *op,
void *in_p,
void *layer_p,
void *mask_p,
void *out_p,
glong samples,
const GeglRectangle *roi,
gint level)
{
PikaOperationLayerMode *layer_mode = (gpointer) op;
gfloat *in = in_p;
gfloat *out = out_p;
gfloat *layer = layer_p;
gfloat *mask = mask_p;
gfloat opacity = layer_mode->opacity;
while (samples--)
{
PikaHSV layer_hsv, out_hsv;
PikaRGB layer_rgb = {layer[0], layer[1], layer[2]};
PikaRGB out_rgb = {in[0], in[1], in[2]};
gfloat comp_alpha, new_alpha;
comp_alpha = MIN (in[ALPHA], layer[ALPHA]) * opacity;
if (mask)
comp_alpha *= *mask;
new_alpha = in[ALPHA] + (1.0f - in[ALPHA]) * comp_alpha;
if (comp_alpha && new_alpha)
{
gint b;
gfloat out_tmp[3];
gfloat ratio = comp_alpha / new_alpha;
pika_rgb_to_hsv (&layer_rgb, &layer_hsv);
pika_rgb_to_hsv (&out_rgb, &out_hsv);
out_hsv.s = layer_hsv.s;
pika_hsv_to_rgb (&out_hsv, &out_rgb);
out_tmp[0] = out_rgb.r;
out_tmp[1] = out_rgb.g;
out_tmp[2] = out_rgb.b;
for (b = RED; b < ALPHA; b++)
{
out[b] = out_tmp[b] * ratio + in[b] * (1.0f - ratio);
}
}
else
{
gint b;
for (b = RED; b < ALPHA; b++)
{
out[b] = in[b];
}
}
out[ALPHA] = in[ALPHA];
in += 4;
layer += 4;
out += 4;
if (mask)
mask++;
}
return TRUE;
}

View File

@ -0,0 +1,57 @@
/* 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
*
* pikaoperationhsvsaturationlegacy.h
* Copyright (C) 2008 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_OPERATION_HSV_SATURATION_LEGACY_H__
#define __PIKA_OPERATION_HSV_SATURATION_LEGACY_H__
#include "operations/layer-modes/pikaoperationlayermode.h"
#define PIKA_TYPE_OPERATION_HSV_SATURATION_LEGACY (pika_operation_hsv_saturation_legacy_get_type ())
#define PIKA_OPERATION_HSV_SATURATION_LEGACY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PIKA_TYPE_OPERATION_HSV_SATURATION_LEGACY, PikaOperationHsvSaturationLegacy))
#define PIKA_OPERATION_HSV_SATURATION_LEGACY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PIKA_TYPE_OPERATION_HSV_SATURATION_LEGACY, PikaOperationHsvSaturationLegacyClass))
#define PIKA_IS_OPERATION_HSV_SATURATION_LEGACY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PIKA_TYPE_OPERATION_HSV_SATURATION_LEGACY))
#define PIKA_IS_OPERATION_HSV_SATURATION_LEGACY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PIKA_TYPE_OPERATION_HSV_SATURATION_LEGACY))
#define PIKA_OPERATION_HSV_SATURATION_LEGACY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PIKA_TYPE_OPERATION_HSV_SATURATION_LEGACY, PikaOperationHsvSaturationLegacyClass))
typedef struct _PikaOperationHsvSaturationLegacy PikaOperationHsvSaturationLegacy;
typedef struct _PikaOperationHsvSaturationLegacyClass PikaOperationHsvSaturationLegacyClass;
struct _PikaOperationHsvSaturationLegacy
{
PikaOperationLayerMode parent_instance;
};
struct _PikaOperationHsvSaturationLegacyClass
{
PikaOperationLayerModeClass parent_class;
};
GType pika_operation_hsv_saturation_legacy_get_type (void) G_GNUC_CONST;
#endif /* __PIKA_OPERATION_HSV_SATURATION_LEGACY_H__ */

View File

@ -0,0 +1,144 @@
/* 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
*
* pikaoperationvaluemode.c
* Copyright (C) 2008 Michael Natterer <mitch@gimp.org>
* 2012 Ville Sokk <ville.sokk@gmail.com>
*
* 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/>.
*/
#include "config.h"
#include <gegl-plugin.h>
#include <cairo.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "libpikacolor/pikacolor.h"
#include "../operations-types.h"
#include "pikaoperationhsvvaluelegacy.h"
static gboolean pika_operation_hsv_value_legacy_process (GeglOperation *op,
void *in,
void *layer,
void *mask,
void *out,
glong samples,
const GeglRectangle *roi,
gint level);
G_DEFINE_TYPE (PikaOperationHsvValueLegacy, pika_operation_hsv_value_legacy,
PIKA_TYPE_OPERATION_LAYER_MODE)
static void
pika_operation_hsv_value_legacy_class_init (PikaOperationHsvValueLegacyClass *klass)
{
GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
PikaOperationLayerModeClass *layer_mode_class = PIKA_OPERATION_LAYER_MODE_CLASS (klass);
gegl_operation_class_set_keys (operation_class,
"name", "pika:hsv-value-legacy",
"description", "PIKA value mode operation",
NULL);
layer_mode_class->process = pika_operation_hsv_value_legacy_process;
}
static void
pika_operation_hsv_value_legacy_init (PikaOperationHsvValueLegacy *self)
{
}
static gboolean
pika_operation_hsv_value_legacy_process (GeglOperation *op,
void *in_p,
void *layer_p,
void *mask_p,
void *out_p,
glong samples,
const GeglRectangle *roi,
gint level)
{
PikaOperationLayerMode *layer_mode = (gpointer) op;
gfloat *in = in_p;
gfloat *out = out_p;
gfloat *layer = layer_p;
gfloat *mask = mask_p;
gfloat opacity = layer_mode->opacity;
while (samples--)
{
PikaHSV layer_hsv, out_hsv;
PikaRGB layer_rgb = {layer[0], layer[1], layer[2]};
PikaRGB out_rgb = {in[0], in[1], in[2]};
gfloat comp_alpha, new_alpha;
comp_alpha = MIN (in[ALPHA], layer[ALPHA]) * opacity;
if (mask)
comp_alpha *= *mask;
new_alpha = in[ALPHA] + (1.0f - in[ALPHA]) * comp_alpha;
if (comp_alpha && new_alpha)
{
gint b;
gfloat out_tmp[3];
gfloat ratio = comp_alpha / new_alpha;
pika_rgb_to_hsv (&layer_rgb, &layer_hsv);
pika_rgb_to_hsv (&out_rgb, &out_hsv);
out_hsv.v = layer_hsv.v;
pika_hsv_to_rgb (&out_hsv, &out_rgb);
out_tmp[0] = out_rgb.r;
out_tmp[1] = out_rgb.g;
out_tmp[2] = out_rgb.b;
for (b = RED; b < ALPHA; b++)
{
out[b] = out_tmp[b] * ratio + in[b] * (1.0f - ratio);
}
}
else
{
gint b;
for (b = RED; b < ALPHA; b++)
{
out[b] = in[b];
}
}
out[ALPHA] = in[ALPHA];
in += 4;
layer += 4;
out += 4;
if (mask)
mask++;
}
return TRUE;
}

View File

@ -0,0 +1,57 @@
/* 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
*
* pikaoperationhsvvaluelegacy.h
* Copyright (C) 2008 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_OPERATION_HSV_VALUE_LEGACY_H__
#define __PIKA_OPERATION_HSV_VALUE_LEGACY_H__
#include "operations/layer-modes/pikaoperationlayermode.h"
#define PIKA_TYPE_OPERATION_HSV_VALUE_LEGACY (pika_operation_hsv_value_legacy_get_type ())
#define PIKA_OPERATION_HSV_VALUE_LEGACY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PIKA_TYPE_OPERATION_HSV_VALUE_LEGACY, PikaOperationHsvValueLegacy))
#define PIKA_OPERATION_HSV_VALUE_LEGACY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PIKA_TYPE_OPERATION_HSV_VALUE_LEGACY, PikaOperationHsvValueLegacyClass))
#define PIKA_IS_OPERATION_HSV_VALUE_LEGACY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PIKA_TYPE_OPERATION_HSV_VALUE_LEGACY))
#define PIKA_IS_OPERATION_HSV_VALUE_LEGACY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PIKA_TYPE_OPERATION_HSV_VALUE_LEGACY))
#define PIKA_OPERATION_HSV_VALUE_LEGACY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PIKA_TYPE_OPERATION_HSV_VALUE_LEGACY, PikaOperationHsvValueLegacyClass))
typedef struct _PikaOperationHsvValueLegacy PikaOperationHsvValueLegacy;
typedef struct _PikaOperationHsvValueLegacyClass PikaOperationHsvValueLegacyClass;
struct _PikaOperationHsvValueLegacy
{
PikaOperationLayerMode parent_instance;
};
struct _PikaOperationHsvValueLegacyClass
{
PikaOperationLayerModeClass parent_class;
};
GType pika_operation_hsv_value_legacy_get_type (void) G_GNUC_CONST;
#endif /* __PIKA_OPERATION_HSV_VALUE_LEGACY_H__ */

View File

@ -0,0 +1,128 @@
/* 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
*
* pikaoperationlightenonlylegacy.c
* Copyright (C) 2008 Michael Natterer <mitch@gimp.org>
* 2012 Ville Sokk <ville.sokk@gmail.com>
*
* 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/>.
*/
#include "config.h"
#include <gegl-plugin.h>
#include "../operations-types.h"
#include "pikaoperationlightenonlylegacy.h"
static gboolean pika_operation_lighten_only_legacy_process (GeglOperation *op,
void *in,
void *layer,
void *mask,
void *out,
glong samples,
const GeglRectangle *roi,
gint level);
G_DEFINE_TYPE (PikaOperationLightenOnlyLegacy, pika_operation_lighten_only_legacy,
PIKA_TYPE_OPERATION_LAYER_MODE)
static void
pika_operation_lighten_only_legacy_class_init (PikaOperationLightenOnlyLegacyClass *klass)
{
GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
PikaOperationLayerModeClass *layer_mode_class = PIKA_OPERATION_LAYER_MODE_CLASS (klass);
gegl_operation_class_set_keys (operation_class,
"name", "pika:lighten-only-legacy",
"description", "PIKA lighten only legacy operation",
NULL);
layer_mode_class->process = pika_operation_lighten_only_legacy_process;
}
static void
pika_operation_lighten_only_legacy_init (PikaOperationLightenOnlyLegacy *self)
{
}
static gboolean
pika_operation_lighten_only_legacy_process (GeglOperation *op,
void *in_p,
void *layer_p,
void *mask_p,
void *out_p,
glong samples,
const GeglRectangle *roi,
gint level)
{
PikaOperationLayerMode *layer_mode = (gpointer) op;
gfloat *in = in_p;
gfloat *out = out_p;
gfloat *layer = layer_p;
gfloat *mask = mask_p;
gfloat opacity = layer_mode->opacity;
while (samples--)
{
gfloat comp_alpha, new_alpha;
comp_alpha = MIN (in[ALPHA], layer[ALPHA]) * opacity;
if (mask)
comp_alpha *= *mask;
new_alpha = in[ALPHA] + (1.0f - in[ALPHA]) * comp_alpha;
if (comp_alpha && new_alpha)
{
gint b;
gfloat ratio = comp_alpha / new_alpha;
for (b = RED; b < ALPHA; b++)
{
gfloat comp = MAX (layer[b], in[b]);
out[b] = comp * ratio + in[b] * (1.0f - ratio);
}
}
else
{
gint b;
for (b = RED; b < ALPHA; b++)
{
out[b] = in[b];
}
}
out[ALPHA] = in[ALPHA];
in += 4;
layer += 4;
out += 4;
if (mask)
mask++;
}
return TRUE;
}

View File

@ -0,0 +1,57 @@
/* 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
*
* pikaoperationlightenonlylegacy.h
* Copyright (C) 2008 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_OPERATION_LIGHTEN_ONLY_LEGACY_H__
#define __PIKA_OPERATION_LIGHTEN_ONLY_LEGACY_H__
#include "operations/layer-modes/pikaoperationlayermode.h"
#define PIKA_TYPE_OPERATION_LIGHTEN_ONLY_LEGACY (pika_operation_lighten_only_legacy_get_type ())
#define PIKA_OPERATION_LIGHTEN_ONLY_LEGACY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PIKA_TYPE_OPERATION_LIGHTEN_ONLY_LEGACY, PikaOperationLightenOnlyLegacy))
#define PIKA_OPERATION_LIGHTEN_ONLY_LEGACY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PIKA_TYPE_OPERATION_LIGHTEN_ONLY_LEGACY, PikaOperationLightenOnlyLegacyClass))
#define PIKA_IS_OPERATION_LIGHTEN_ONLY_LEGACY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PIKA_TYPE_OPERATION_LIGHTEN_ONLY_LEGACY))
#define PIKA_IS_OPERATION_LIGHTEN_ONLY_LEGACY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PIKA_TYPE_OPERATION_LIGHTEN_ONLY_LEGACY))
#define PIKA_OPERATION_LIGHTEN_ONLY_LEGACY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PIKA_TYPE_OPERATION_LIGHTEN_ONLY_LEGACY, PikaOperationLightenOnlyLegacyClass))
typedef struct _PikaOperationLightenOnlyLegacy PikaOperationLightenOnlyLegacy;
typedef struct _PikaOperationLightenOnlyLegacyClass PikaOperationLightenOnlyLegacyClass;
struct _PikaOperationLightenOnlyLegacy
{
PikaOperationLayerMode parent_instance;
};
struct _PikaOperationLightenOnlyLegacyClass
{
PikaOperationLayerModeClass parent_class;
};
GType pika_operation_lighten_only_legacy_get_type (void) G_GNUC_CONST;
#endif /* __PIKA_OPERATION_LIGHTEN_ONLY_LEGACY_H__ */

View File

@ -0,0 +1,128 @@
/* 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
*
* pikaoperationmultiplylegacy.c
* Copyright (C) 2008 Michael Natterer <mitch@gimp.org>
* 2012 Ville Sokk <ville.sokk@gmail.com>
*
* 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/>.
*/
#include "config.h"
#include <gegl-plugin.h>
#include "operations/operations-types.h"
#include "pikaoperationmultiplylegacy.h"
static gboolean pika_operation_multiply_legacy_process (GeglOperation *op,
void *in,
void *layer,
void *mask,
void *out,
glong samples,
const GeglRectangle *roi,
gint level);
G_DEFINE_TYPE (PikaOperationMultiplyLegacy, pika_operation_multiply_legacy,
PIKA_TYPE_OPERATION_LAYER_MODE)
static void
pika_operation_multiply_legacy_class_init (PikaOperationMultiplyLegacyClass *klass)
{
GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
PikaOperationLayerModeClass *layer_mode_class = PIKA_OPERATION_LAYER_MODE_CLASS (klass);
gegl_operation_class_set_keys (operation_class,
"name", "pika:multiply-legacy",
"description", "PIKA multiply legacy operation",
NULL);
layer_mode_class->process = pika_operation_multiply_legacy_process;
}
static void
pika_operation_multiply_legacy_init (PikaOperationMultiplyLegacy *self)
{
}
static gboolean
pika_operation_multiply_legacy_process (GeglOperation *op,
void *in_p,
void *layer_p,
void *mask_p,
void *out_p,
glong samples,
const GeglRectangle *roi,
gint level)
{
PikaOperationLayerMode *layer_mode = (gpointer) op;
gfloat *in = in_p;
gfloat *out = out_p;
gfloat *layer = layer_p;
gfloat *mask = mask_p;
gfloat opacity = layer_mode->opacity;
while (samples--)
{
gfloat comp_alpha, new_alpha;
comp_alpha = MIN (in[ALPHA], layer[ALPHA]) * opacity;
if (mask)
comp_alpha *= *mask;
new_alpha = in[ALPHA] + (1.0f - in[ALPHA]) * comp_alpha;
if (comp_alpha && new_alpha)
{
gfloat ratio = comp_alpha / new_alpha;
gint b;
for (b = RED; b < ALPHA; b++)
{
gfloat comp = layer[b] * in[b];
out[b] = comp * ratio + in[b] * (1.0f - ratio);
}
}
else
{
gint b;
for (b = RED; b < ALPHA; b++)
{
out[b] = in[b];
}
}
out[ALPHA] = in[ALPHA];
in += 4;
layer += 4;
out += 4;
if (mask)
mask++;
}
return TRUE;
}

View File

@ -0,0 +1,57 @@
/* 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
*
* pikaoperationmultiplylegacy.h
* Copyright (C) 2008 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_OPERATION_MULTIPLY_LEGACY_H__
#define __PIKA_OPERATION_MULTIPLY_LEGACY_H__
#include "operations/layer-modes/pikaoperationlayermode.h"
#define PIKA_TYPE_OPERATION_MULTIPLY_LEGACY (pika_operation_multiply_legacy_get_type ())
#define PIKA_OPERATION_MULTIPLY_LEGACY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PIKA_TYPE_OPERATION_MULTIPLY_LEGACY, PikaOperationMultiplyLegacy))
#define PIKA_OPERATION_MULTIPLY_LEGACY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PIKA_TYPE_OPERATION_MULTIPLY_LEGACY, PikaOperationMultiplyLegacyClass))
#define PIKA_IS_OPERATION_MULTIPLY_LEGACY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PIKA_TYPE_OPERATION_MULTIPLY_LEGACY))
#define PIKA_IS_OPERATION_MULTIPLY_LEGACY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PIKA_TYPE_OPERATION_MULTIPLY_LEGACY))
#define PIKA_OPERATION_MULTIPLY_LEGACY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PIKA_TYPE_OPERATION_MULTIPLY_LEGACY, PikaOperationMultiplyLegacyClass))
typedef struct _PikaOperationMultiplyLegacy PikaOperationMultiplyLegacy;
typedef struct _PikaOperationMultiplyLegacyClass PikaOperationMultiplyLegacyClass;
struct _PikaOperationMultiplyLegacy
{
PikaOperationLayerMode parent_instance;
};
struct _PikaOperationMultiplyLegacyClass
{
PikaOperationLayerModeClass parent_class;
};
GType pika_operation_multiply_legacy_get_type (void) G_GNUC_CONST;
#endif /* __PIKA_OPERATION_MULTIPLY_LEGACY_H__ */

View File

@ -0,0 +1,128 @@
/* 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
*
* pikaoperationscreenlegacy.c
* Copyright (C) 2008 Michael Natterer <mitch@gimp.org>
* 2012 Ville Sokk <ville.sokk@gmail.com>
*
* 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/>.
*/
#include "config.h"
#include <gegl-plugin.h>
#include "../operations-types.h"
#include "pikaoperationscreenlegacy.h"
static gboolean pika_operation_screen_legacy_process (GeglOperation *op,
void *in,
void *layer,
void *mask,
void *out,
glong samples,
const GeglRectangle *roi,
gint level);
G_DEFINE_TYPE (PikaOperationScreenLegacy, pika_operation_screen_legacy,
PIKA_TYPE_OPERATION_LAYER_MODE)
static void
pika_operation_screen_legacy_class_init (PikaOperationScreenLegacyClass *klass)
{
GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
PikaOperationLayerModeClass *layer_mode_class = PIKA_OPERATION_LAYER_MODE_CLASS (klass);
gegl_operation_class_set_keys (operation_class,
"name", "pika:screen-legacy",
"description", "PIKA screen mode operation",
NULL);
layer_mode_class->process = pika_operation_screen_legacy_process;
}
static void
pika_operation_screen_legacy_init (PikaOperationScreenLegacy *self)
{
}
static gboolean
pika_operation_screen_legacy_process (GeglOperation *op,
void *in_p,
void *layer_p,
void *mask_p,
void *out_p,
glong samples,
const GeglRectangle *roi,
gint level)
{
PikaOperationLayerMode *layer_mode = (gpointer) op;
gfloat *in = in_p;
gfloat *out = out_p;
gfloat *layer = layer_p;
gfloat *mask = mask_p;
gfloat opacity = layer_mode->opacity;
while (samples--)
{
gfloat comp_alpha, new_alpha;
comp_alpha = MIN (in[ALPHA], layer[ALPHA]) * opacity;
if (mask)
comp_alpha *= *mask;
new_alpha = in[ALPHA] + (1.0f - in[ALPHA]) * comp_alpha;
if (comp_alpha && new_alpha)
{
gfloat ratio = comp_alpha / new_alpha;
gint b;
for (b = RED; b < ALPHA; b++)
{
gfloat comp = 1.0f - (1.0f - in[b]) * (1.0f - layer[b]);
out[b] = comp * ratio + in[b] * (1.0f - ratio);
}
}
else
{
gint b;
for (b = RED; b < ALPHA; b++)
{
out[b] = in[b];
}
}
out[ALPHA] = in[ALPHA];
in += 4;
layer += 4;
out += 4;
if (mask)
mask++;
}
return TRUE;
}

View File

@ -0,0 +1,57 @@
/* 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
*
* pikaoperationscreenlegacy.h
* Copyright (C) 2008 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_OPERATION_SCREEN_LEGACY_H__
#define __PIKA_OPERATION_SCREEN_LEGACY_H__
#include "operations/layer-modes/pikaoperationlayermode.h"
#define PIKA_TYPE_OPERATION_SCREEN_LEGACY (pika_operation_screen_legacy_get_type ())
#define PIKA_OPERATION_SCREEN_LEGACY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PIKA_TYPE_OPERATION_SCREEN_LEGACY, PikaOperationScreenLegacy))
#define PIKA_OPERATION_SCREEN_LEGACY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PIKA_TYPE_OPERATION_SCREEN_LEGACY, PikaOperationScreenLegacyClass))
#define PIKA_IS_OPERATION_SCREEN_LEGACY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PIKA_TYPE_OPERATION_SCREEN_LEGACY))
#define PIKA_IS_OPERATION_SCREEN_LEGACY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PIKA_TYPE_OPERATION_SCREEN_LEGACY))
#define PIKA_OPERATION_SCREEN_LEGACY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PIKA_TYPE_OPERATION_SCREEN_LEGACY, PikaOperationScreenLegacyClass))
typedef struct _PikaOperationScreenLegacy PikaOperationScreenLegacy;
typedef struct _PikaOperationScreenLegacyClass PikaOperationScreenLegacyClass;
struct _PikaOperationScreenLegacy
{
PikaOperationLayerMode parent_instance;
};
struct _PikaOperationScreenLegacyClass
{
PikaOperationLayerModeClass parent_class;
};
GType pika_operation_screen_legacy_get_type (void) G_GNUC_CONST;
#endif /* __PIKA_OPERATION_SCREEN_LEGACY_H__ */

View File

@ -0,0 +1,161 @@
/* 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
*
* pikaoperationsoftlightmode.c
* Copyright (C) 2008 Michael Natterer <mitch@gimp.org>
* 2012 Ville Sokk <ville.sokk@gmail.com>
*
* 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/>.
*/
#include "config.h"
#include <gegl-plugin.h>
#include "../operations-types.h"
#include "pikaoperationsoftlightlegacy.h"
static gboolean pika_operation_softlight_legacy_process (GeglOperation *op,
void *in,
void *layer,
void *mask,
void *out,
glong samples,
const GeglRectangle *roi,
gint level);
G_DEFINE_TYPE (PikaOperationSoftlightLegacy, pika_operation_softlight_legacy,
PIKA_TYPE_OPERATION_LAYER_MODE)
static const gchar* reference_xml = "<?xml version='1.0' encoding='UTF-8'?>"
"<gegl>"
"<node operation='pika:softlight-legacy'>"
" <node operation='gegl:load'>"
" <params>"
" <param name='path'>B.png</param>"
" </params>"
" </node>"
"</node>"
"<node operation='gegl:load'>"
" <params>"
" <param name='path'>A.png</param>"
" </params>"
"</node>"
"</gegl>";
static void
pika_operation_softlight_legacy_class_init (PikaOperationSoftlightLegacyClass *klass)
{
GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
PikaOperationLayerModeClass *layer_mode_class = PIKA_OPERATION_LAYER_MODE_CLASS (klass);
gegl_operation_class_set_keys (operation_class,
"name", "pika:softlight-legacy",
"description", "PIKA softlight mode operation",
"reference-image", "soft-light-mode.png",
"reference-composition", reference_xml,
NULL);
layer_mode_class->process = pika_operation_softlight_legacy_process;
}
static void
pika_operation_softlight_legacy_init (PikaOperationSoftlightLegacy *self)
{
}
static gboolean
pika_operation_softlight_legacy_process (GeglOperation *op,
void *in_p,
void *layer_p,
void *mask_p,
void *out_p,
glong samples,
const GeglRectangle *roi,
gint level)
{
PikaOperationLayerMode *layer_mode = (gpointer) op;
gfloat *in = in_p;
gfloat *out = out_p;
gfloat *layer = layer_p;
gfloat *mask = mask_p;
gfloat opacity = layer_mode->opacity;
while (samples--)
{
gfloat comp_alpha, new_alpha;
comp_alpha = MIN (in[ALPHA], layer[ALPHA]) * opacity;
if (mask)
comp_alpha *= *mask;
new_alpha = in[ALPHA] + (1.0f - in[ALPHA]) * comp_alpha;
if (comp_alpha && new_alpha)
{
gfloat ratio = comp_alpha / new_alpha;
gint b;
for (b = RED; b < ALPHA; b++)
{
#if 0
/* softlight is now used for what PIKA formerly called
* OVERLAY. We fixed OVERLAY to use the right math
* (under the name NEW_OVERLAY), and redirect uses of
* the old OVERLAY blend mode here. This math was
* formerly used for OVERLAY and is exactly the same as
* the multiply, screen, comp math used below.
* See bug #673501.
*/
gfloat comp = in[b] * (in[b] + (2.0f * layer[b]) * (1.0f - in[b]));
#endif
gfloat multiply = in[b] * layer[b];
gfloat screen = 1.0f - (1.0f - in[b]) * (1.0f - layer[b]);
gfloat comp = (1.0f - in[b]) * multiply + in[b] * screen;
out[b] = comp * ratio + in[b] * (1.0f - ratio);
}
}
else
{
gint b;
for (b = RED; b < ALPHA; b++)
{
out[b] = in[b];
}
}
out[ALPHA] = in[ALPHA];
in += 4;
layer += 4;
out += 4;
if (mask)
mask ++;
}
return TRUE;
}

View File

@ -0,0 +1,57 @@
/* 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
*
* pikaoperationsoftlightlegacy.h
* Copyright (C) 2008 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_OPERATION_SOFTLIGHT_LEGACY_H__
#define __PIKA_OPERATION_SOFTLIGHT_LEGACY_H__
#include "operations/layer-modes/pikaoperationlayermode.h"
#define PIKA_TYPE_OPERATION_SOFTLIGHT_LEGACY (pika_operation_softlight_legacy_get_type ())
#define PIKA_OPERATION_SOFTLIGHT_LEGACY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PIKA_TYPE_OPERATION_SOFTLIGHT_LEGACY, PikaOperationSoftlightLegacy))
#define PIKA_OPERATION_SOFTLIGHT_LEGACY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PIKA_TYPE_OPERATION_SOFTLIGHT_LEGACY, PikaOperationSoftlightLegacyClass))
#define PIKA_IS_OPERATION_SOFTLIGHT_LEGACY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PIKA_TYPE_OPERATION_SOFTLIGHT_LEGACY))
#define PIKA_IS_OPERATION_SOFTLIGHT_LEGACY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PIKA_TYPE_OPERATION_SOFTLIGHT_LEGACY))
#define PIKA_OPERATION_SOFTLIGHT_LEGACY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PIKA_TYPE_OPERATION_SOFTLIGHT_LEGACY, PikaOperationSoftlightLegacyClass))
typedef struct _PikaOperationSoftlightLegacy PikaOperationSoftlightLegacy;
typedef struct _PikaOperationSoftlightLegacyClass PikaOperationSoftlightLegacyClass;
struct _PikaOperationSoftlightLegacy
{
PikaOperationLayerMode parent_instance;
};
struct _PikaOperationSoftlightLegacyClass
{
PikaOperationLayerModeClass parent_class;
};
GType pika_operation_softlight_legacy_get_type (void) G_GNUC_CONST;
#endif /* __PIKA_OPERATION_SOFTLIGHT_LEGACY_H__ */

View File

@ -0,0 +1,129 @@
/* 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
*
* pikaoperationsubtractmode.c
* Copyright (C) 2008 Michael Natterer <mitch@gimp.org>
* 2012 Ville Sokk <ville.sokk@gmail.com>
*
* 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/>.
*/
#include "config.h"
#include <gegl-plugin.h>
#include "../operations-types.h"
#include "pikaoperationsubtractlegacy.h"
static gboolean pika_operation_subtract_legacy_process (GeglOperation *op,
void *in,
void *layer,
void *mask,
void *out,
glong samples,
const GeglRectangle *roi,
gint level);
G_DEFINE_TYPE (PikaOperationSubtractLegacy, pika_operation_subtract_legacy,
PIKA_TYPE_OPERATION_LAYER_MODE)
static void
pika_operation_subtract_legacy_class_init (PikaOperationSubtractLegacyClass *klass)
{
GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
PikaOperationLayerModeClass *layer_mode_class = PIKA_OPERATION_LAYER_MODE_CLASS (klass);
gegl_operation_class_set_keys (operation_class,
"name", "pika:subtract-legacy",
"description", "PIKA subtract mode operation",
NULL);
layer_mode_class->process = pika_operation_subtract_legacy_process;
}
static void
pika_operation_subtract_legacy_init (PikaOperationSubtractLegacy *self)
{
}
static gboolean
pika_operation_subtract_legacy_process (GeglOperation *op,
void *in_p,
void *layer_p,
void *mask_p,
void *out_p,
glong samples,
const GeglRectangle *roi,
gint level)
{
PikaOperationLayerMode *layer_mode = (gpointer) op;
gfloat *in = in_p;
gfloat *out = out_p;
gfloat *layer = layer_p;
gfloat *mask = mask_p;
gfloat opacity = layer_mode->opacity;
while (samples--)
{
gfloat comp_alpha, new_alpha;
comp_alpha = MIN (in[ALPHA], layer[ALPHA]) * opacity;
if (mask)
comp_alpha *= *mask;
new_alpha = in[ALPHA] + (1.0f - in[ALPHA]) * comp_alpha;
if (comp_alpha && new_alpha)
{
gint b;
gfloat ratio = comp_alpha / new_alpha;
for (b = RED; b < ALPHA; b++)
{
gfloat comp = in[b] - layer[b];
comp = CLAMP (comp, 0.0f, 1.0f);
out[b] = comp * ratio + in[b] * (1.0f - ratio);
}
}
else
{
gint b;
for (b = RED; b < ALPHA; b++)
{
out[b] = in[b];
}
}
out[ALPHA] = in[ALPHA];
in += 4;
layer += 4;
out += 4;
if (mask)
mask++;
}
return TRUE;
}

View File

@ -0,0 +1,57 @@
/* 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
*
* pikaoperationsubtractlegacy.h
* Copyright (C) 2008 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_OPERATION_SUBTRACT_LEGACY_H__
#define __PIKA_OPERATION_SUBTRACT_LEGACY_H__
#include "operations/layer-modes/pikaoperationlayermode.h"
#define PIKA_TYPE_OPERATION_SUBTRACT_LEGACY (pika_operation_subtract_legacy_get_type ())
#define PIKA_OPERATION_SUBTRACT_LEGACY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PIKA_TYPE_OPERATION_SUBTRACT_LEGACY, PikaOperationSubtractLegacy))
#define PIKA_OPERATION_SUBTRACT_LEGACY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PIKA_TYPE_OPERATION_SUBTRACT_LEGACY, PikaOperationSubtractLegacyClass))
#define PIKA_IS_OPERATION_SUBTRACT_LEGACY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PIKA_TYPE_OPERATION_SUBTRACT_LEGACY))
#define PIKA_IS_OPERATION_SUBTRACT_LEGACY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PIKA_TYPE_OPERATION_SUBTRACT_LEGACY))
#define PIKA_OPERATION_SUBTRACT_LEGACY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PIKA_TYPE_OPERATION_SUBTRACT_LEGACY, PikaOperationSubtractLegacyClass))
typedef struct _PikaOperationSubtractLegacy PikaOperationSubtractLegacy;
typedef struct _PikaOperationSubtractLegacyClass PikaOperationSubtractLegacyClass;
struct _PikaOperationSubtractLegacy
{
PikaOperationLayerMode parent_instance;
};
struct _PikaOperationSubtractLegacyClass
{
PikaOperationLayerModeClass parent_class;
};
GType pika_operation_subtract_legacy_get_type (void) G_GNUC_CONST;
#endif /* __PIKA_OPERATION_SUBTRACT_LEGACY_H__ */