Commit bbc0c43f authored by Samuel Zachara's avatar Samuel Zachara Committed by Debarshi Ray

Add Instagram Clarendon

Analysis: https://rishi.fedorapeople.org/instagram/clarendon/

!129
parent a5d835d0
Pipeline #182468 passed with stages
in 16 minutes and 42 seconds
......@@ -6,6 +6,7 @@ sources = files(
'photos-gegl.c',
'photos-glib.c',
'photos-jpeg-count.c',
'photos-operation-insta-clarendon.c',
'photos-operation-insta-curve.c',
'photos-operation-insta-filter.c',
'photos-operation-insta-hefe.c',
......
......@@ -25,6 +25,7 @@
#include "photos-debug.h"
#include "photos-gegl.h"
#include "photos-operation-insta-clarendon.h"
#include "photos-operation-insta-curve.h"
#include "photos-operation-insta-filter.h"
#include "photos-operation-insta-hefe.h"
......@@ -631,6 +632,7 @@ photos_gegl_ensure_builtins (void)
if (g_once_init_enter (&once_init_value))
{
g_type_ensure (PHOTOS_TYPE_OPERATION_INSTA_CLARENDON);
g_type_ensure (PHOTOS_TYPE_OPERATION_INSTA_CURVE);
g_type_ensure (PHOTOS_TYPE_OPERATION_INSTA_FILTER);
g_type_ensure (PHOTOS_TYPE_OPERATION_INSTA_HEFE);
......
/*
* Photos - access, organize and share your photos on GNOME
* Copyright © 2020 Samuel Zachara
*
* 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 <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <math.h>
#include <babl/babl.h>
#include <gegl.h>
#include "photos-operation-insta-clarendon.h"
struct _PhotosOperationInstaClarendon
{
GeglOperationPointFilter parent_instance;
};
G_DEFINE_TYPE (PhotosOperationInstaClarendon, photos_operation_insta_clarendon, GEGL_TYPE_OPERATION_POINT_FILTER);
static void
photos_operation_insta_clarendon_prepare (GeglOperation *operation)
{
const Babl *format;
format = babl_format ("R'G'B' u8");
gegl_operation_set_format (operation, "input", format);
gegl_operation_set_format (operation, "output", format);
}
static gboolean
photos_operation_insta_clarendon_process (GeglOperation *operation,
void *in_buf,
void *out_buf,
glong n_pixels,
const GeglRectangle *roi,
gint level)
{
guint8 *in = in_buf;
guint8 *out = out_buf;
glong i;
for (i = 0; i < n_pixels; i++)
{
const guint32 b = (guint32) in[2];
const guint32 b2 = b * b;
const guint32 b3 = b2 * b;
const guint32 b4 = b3 * b;
const guint32 g = (guint32) in[1];
const guint32 g2 = g * g;
const guint32 g3 = g2 * g;
const guint32 g4 = g3 * g;
const guint32 r = (guint32) in[0];
const guint32 r2 = r * r;
const guint32 r3 = r2 * r;
const guint32 r4 = r3 * r;
gint32 r_out = 18.37f
- 1.05f * r
- 0.0276f * g
+ 0.03275f * r2
- 0.001056f * r * g
- 0.000152f * r3
+ 2.006e-6f * r2 * g
+ 2.091e-7f * r4
+ 9.682e-9f * r3 * g;
gint32 g_out = 6.87f - 0.1453 * g + 0.02435 * g2 - 0.0001355 * g3 + 2.267e-7 * g4;
gint32 b_out = 13.3f
+ 0.4149f * b
- 0.08369f * g
+ 0.01699f * b2
- 0.001413f * b * g
- 9.235e-5f * b3
+ 1.239e-5f *b2 * g
+ 1.334e-7f * b4
- 2.221e-8f * b3 * g;
out[0] = (guint8) CLAMP(r_out, 0, 255);
out[1] = (guint8) CLAMP(g_out, 0, 255);
out[2] = (guint8) CLAMP(b_out, 0, 255);
in += 3;
out += 3;
}
return TRUE;
}
static void
photos_operation_insta_clarendon_init (PhotosOperationInstaClarendon *self)
{
}
static void
photos_operation_insta_clarendon_class_init (PhotosOperationInstaClarendonClass *class)
{
GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (class);
GeglOperationPointFilterClass *point_filter_class = GEGL_OPERATION_POINT_FILTER_CLASS (class);
operation_class->opencl_support = FALSE;
operation_class->prepare = photos_operation_insta_clarendon_prepare;
point_filter_class->process = photos_operation_insta_clarendon_process;
gegl_operation_class_set_keys (operation_class,
"name", "photos:insta-clarendon",
"title", "Insta Clarendon",
"description", "Apply the Clarendon filter to an image",
"categories", "hidden",
NULL);
}
/*
* Photos - access, organize and share your photos on GNOME
* Copyright © 2020 Samuel Zachara
*
* 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 <http://www.gnu.org/licenses/>.
*/
#ifndef PHOTOS_OPERATION_INSTA_CLARENDON_H
#define PHOTOS_OPERATION_INSTA_CLARENDON_H
#include <gegl-plugin.h>
G_BEGIN_DECLS
#define PHOTOS_TYPE_OPERATION_INSTA_CLARENDON (photos_operation_insta_clarendon_get_type ())
G_DECLARE_FINAL_TYPE (PhotosOperationInstaClarendon,
photos_operation_insta_clarendon,
PHOTOS,
OPERATION_INSTA_CLARENDON,
GeglOperationPointFilter);
G_END_DECLS
#endif /* PHOTOS_OPERATION_INSTA_CLARENDON_H */
......@@ -26,12 +26,14 @@ typedef enum
PHOTOS_OPERATION_INSTA_PRESET_NONE,
PHOTOS_OPERATION_INSTA_PRESET_1947,
PHOTOS_OPERATION_INSTA_PRESET_CALISTOGA,
PHOTOS_OPERATION_INSTA_PRESET_TRENCIN,
PHOTOS_OPERATION_INSTA_PRESET_CAAP,
PHOTOS_OPERATION_INSTA_PRESET_MOGADISHU,
PHOTOS_OPERATION_INSTA_PRESET_HOMETOWN,
PHOTOS_OPERATION_INSTA_PRESET_1977 = PHOTOS_OPERATION_INSTA_PRESET_1947,
PHOTOS_OPERATION_INSTA_PRESET_BRANNAN = PHOTOS_OPERATION_INSTA_PRESET_CALISTOGA,
PHOTOS_OPERATION_INSTA_PRESET_CLARENDON = PHOTOS_OPERATION_INSTA_PRESET_TRENCIN,
PHOTOS_OPERATION_INSTA_PRESET_HEFE = PHOTOS_OPERATION_INSTA_PRESET_CAAP,
PHOTOS_OPERATION_INSTA_PRESET_GOTHAM = PHOTOS_OPERATION_INSTA_PRESET_MOGADISHU,
PHOTOS_OPERATION_INSTA_PRESET_NASHVILLE = PHOTOS_OPERATION_INSTA_PRESET_HOMETOWN,
......
......@@ -1013,6 +1013,7 @@ photos_operation_insta_curve_prepare (GeglOperation *operation)
case PHOTOS_OPERATION_INSTA_PRESET_NONE:
case PHOTOS_OPERATION_INSTA_PRESET_HEFE:
case PHOTOS_OPERATION_INSTA_PRESET_CLARENDON:
default:
g_assert_not_reached ();
}
......
......@@ -82,6 +82,13 @@ photos_operation_insta_filter_setup (PhotosOperationInstaFilter *self)
self->nodes = g_list_prepend (self->nodes, node);
break;
case PHOTOS_OPERATION_INSTA_PRESET_CLARENDON:
node = gegl_node_new_child (operation->node,
"operation", "photos:insta-clarendon",
NULL);
self->nodes = g_list_prepend (self->nodes, node);
break;
case PHOTOS_OPERATION_INSTA_PRESET_GOTHAM:
node = gegl_node_new_child (operation->node,
"operation", "photos:insta-curve",
......
......@@ -199,25 +199,31 @@ photos_tool_filters_init (PhotosToolFilters *self)
gtk_grid_attach (GTK_GRID (self->grid), button, 0, row, 1, 1);
self->buttons = g_list_prepend (self->buttons, button);
button = photos_tool_filter_button_new (group, _("Mogadishu"));
button = photos_tool_filter_button_new (group, _("Trencin"));
gtk_actionable_set_action_name (GTK_ACTIONABLE (button), "app.insta-current");
gtk_actionable_set_action_target (GTK_ACTIONABLE (button), "n", (gint16) PHOTOS_OPERATION_INSTA_PRESET_MOGADISHU);
gtk_actionable_set_action_target (GTK_ACTIONABLE (button), "n", (gint16) PHOTOS_OPERATION_INSTA_PRESET_TRENCIN);
gtk_grid_attach (GTK_GRID (self->grid), button, 1, row, 1, 1);
self->buttons = g_list_prepend (self->buttons, button);
row++;
button = photos_tool_filter_button_new (group, _("Mogadishu"));
gtk_actionable_set_action_name (GTK_ACTIONABLE (button), "app.insta-current");
gtk_actionable_set_action_target (GTK_ACTIONABLE (button), "n", (gint16) PHOTOS_OPERATION_INSTA_PRESET_MOGADISHU);
gtk_grid_attach (GTK_GRID (self->grid), button, 0, row, 1, 1);
self->buttons = g_list_prepend (self->buttons, button);
button = photos_tool_filter_button_new (group, _("Caap"));
gtk_actionable_set_action_name (GTK_ACTIONABLE (button), "app.insta-current");
gtk_actionable_set_action_target (GTK_ACTIONABLE (button), "n", (gint16) PHOTOS_OPERATION_INSTA_PRESET_CAAP);
gtk_grid_attach (GTK_GRID (self->grid), button, 0, row, 1, 1);
gtk_grid_attach (GTK_GRID (self->grid), button, 1, row, 1, 1);
self->buttons = g_list_prepend (self->buttons, button);
row++;
button = photos_tool_filter_button_new (group, _("Hometown"));
gtk_actionable_set_action_name (GTK_ACTIONABLE (button), "app.insta-current");
gtk_actionable_set_action_target (GTK_ACTIONABLE (button), "n", (gint16) PHOTOS_OPERATION_INSTA_PRESET_HOMETOWN);
gtk_grid_attach (GTK_GRID (self->grid), button, 1, row, 1, 1);
gtk_grid_attach (GTK_GRID (self->grid), button, 0, row, 1, 1);
self->buttons = g_list_prepend (self->buttons, button);
row++;
self->buttons = g_list_reverse (self->buttons);
}
......
......@@ -25,12 +25,14 @@ test_data = [
'photos-test-pipeline-edited-insta-filter-none.xml',
'photos-test-pipeline-edited-insta-filter-1977.xml',
'photos-test-pipeline-edited-insta-filter-brannan.xml',
'photos-test-pipeline-edited-insta-filter-clarendon.xml',
'photos-test-pipeline-edited-insta-filter-gotham.xml',
'photos-test-pipeline-edited-insta-filter-hefe.xml',
'photos-test-pipeline-edited-insta-filter-nashville.xml',
'photos-test-pipeline-edited-magic-filter-none.xml',
'photos-test-pipeline-edited-magic-filter-1947.xml',
'photos-test-pipeline-edited-magic-filter-calistoga.xml',
'photos-test-pipeline-edited-insta-filter-trencin.xml',
'photos-test-pipeline-edited-magic-filter-caap.xml',
'photos-test-pipeline-edited-magic-filter-mogadishu.xml',
'photos-test-pipeline-edited-magic-filter-hometown.xml',
......
<?xml version='1.0' encoding='UTF-8'?>
<gegl>
<node operation='photos:insta-filter'>
<params>
<param name='preset'>clarendon</param>
</params>
</node>
</gegl>
<?xml version='1.0' encoding='UTF-8'?>
<gegl>
<node operation='photos:magic-filter'>
<params>
<param name='preset'>trencin</param>
</params>
</node>
</gegl>
......@@ -352,6 +352,28 @@ photos_test_pipeline_insta_filter_brannan (PhotosTestPipelineFixture *fixture, g
}
static void
photos_test_pipeline_insta_filter_clarendon (PhotosTestPipelineFixture *fixture, gconstpointer user_data)
{
g_autoptr (PhotosPipeline) pipeline = NULL;
const gchar *const filenames[] = { "photos-test-pipeline-edited-insta-filter-clarendon.xml", NULL };
photos_test_pipeline_pipeline_new_async (NULL, filenames, NULL, photos_test_pipeline_async, fixture);
g_main_loop_run (fixture->loop);
{
g_autoptr (GError) error = NULL;
pipeline = photos_pipeline_new_finish (fixture->res, &error);
g_assert_no_error (error);
}
photos_test_pipeline_check_insta_filter (pipeline,
PHOTOS_OPERATION_INSTA_PRESET_CLARENDON,
PHOTOS_OPERATION_INSTA_PRESET_TRENCIN);
}
static void
photos_test_pipeline_insta_filter_gotham (PhotosTestPipelineFixture *fixture, gconstpointer user_data)
{
......@@ -484,6 +506,28 @@ photos_test_pipeline_magic_filter_calistoga (PhotosTestPipelineFixture *fixture,
}
static void
photos_test_pipeline_magic_filter_trencin (PhotosTestPipelineFixture *fixture, gconstpointer user_data)
{
g_autoptr (PhotosPipeline) pipeline = NULL;
const gchar *const filenames[] = { "photos-test-pipeline-edited-magic-filter-trencin.xml", NULL };
photos_test_pipeline_pipeline_new_async (NULL, filenames, NULL, photos_test_pipeline_async, fixture);
g_main_loop_run (fixture->loop);
{
g_autoptr (GError) error = NULL;
pipeline = photos_pipeline_new_finish (fixture->res, &error);
g_assert_no_error (error);
}
photos_test_pipeline_check_insta_filter (pipeline,
PHOTOS_OPERATION_INSTA_PRESET_TRENCIN,
PHOTOS_OPERATION_INSTA_PRESET_CLARENDON);
}
static void
photos_test_pipeline_magic_filter_mogadishu (PhotosTestPipelineFixture *fixture, gconstpointer user_data)
{
......@@ -1817,6 +1861,13 @@ main (gint argc, gchar *argv[])
photos_test_pipeline_insta_filter_brannan,
photos_test_pipeline_teardown);
g_test_add ("/pipeline/new/insta-filter-clarendon",
PhotosTestPipelineFixture,
NULL,
photos_test_pipeline_setup,
photos_test_pipeline_insta_filter_clarendon,
photos_test_pipeline_teardown);
g_test_add ("/pipeline/new/insta-filter-gotham",
PhotosTestPipelineFixture,
NULL,
......@@ -1859,6 +1910,13 @@ main (gint argc, gchar *argv[])
photos_test_pipeline_magic_filter_calistoga,
photos_test_pipeline_teardown);
g_test_add ("/pipeline/new/magic-filter-trencin",
PhotosTestPipelineFixture,
NULL,
photos_test_pipeline_setup,
photos_test_pipeline_magic_filter_trencin,
photos_test_pipeline_teardown);
g_test_add ("/pipeline/new/magic-filter-mogadishu",
PhotosTestPipelineFixture,
NULL,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment