mirror of
https://gitlab.gnome.org/GNOME/gimp
synced 2024-10-21 20:12:30 +00:00
added new function gimp_bpp_to_babl_format_linear().
2007-12-30 Sven Neumann <sven@gimp.org> * app/gegl/gimp-gegl-utils.[ch]: added new function gimp_bpp_to_babl_format_linear(). * app/gegl/gimpoperationtilesink.[ch] * app/gegl/gimpoperationtilesource.[ch]: added boolean property to toggle between linear and gamma-corrected data. * app/core/gimpdrawable-invert.c: assume linear data to be closer to the original definition of the invert operation in GIMP. Enable the GEGL code path per default. svn path=/trunk/; revision=24491
This commit is contained in:
parent
cfe312bc5e
commit
cd270aac4c
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
|||
2007-12-30 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/gegl/gimp-gegl-utils.[ch]: added new function
|
||||
gimp_bpp_to_babl_format_linear().
|
||||
|
||||
* app/gegl/gimpoperationtilesink.[ch]
|
||||
* app/gegl/gimpoperationtilesource.[ch]: added boolean property to
|
||||
toggle between linear and gamma-corrected data.
|
||||
|
||||
* app/core/gimpdrawable-invert.c: assume linear data to be closer
|
||||
to the original definition of the invert operation in GIMP.
|
||||
Enable the GEGL code path per default.
|
||||
|
||||
2007-12-30 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/core/gimpdrawable-invert.c (gimp_drawable_invert): moved
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* #define ENABLE_GEGL */
|
||||
#define ENABLE_GEGL
|
||||
#ifdef ENABLE_GEGL
|
||||
|
||||
#include "config.h"
|
||||
|
@ -57,10 +57,12 @@ gimp_drawable_invert (GimpDrawable *drawable,
|
|||
input = gegl_node_new_child (gegl,
|
||||
"operation", "gimp-tilemanager-source",
|
||||
"tile-manager", gimp_drawable_get_tiles (drawable),
|
||||
"linear", TRUE,
|
||||
NULL);
|
||||
output = gegl_node_new_child (gegl,
|
||||
"operation", "gimp-tilemanager-sink",
|
||||
"tile-manager", gimp_drawable_get_shadow_tiles (drawable),
|
||||
"linear", TRUE,
|
||||
NULL);
|
||||
invert = gegl_node_new_child (gegl,
|
||||
"operation", "invert",
|
||||
|
|
|
@ -28,6 +28,15 @@
|
|||
#include "gimp-gegl-utils.h"
|
||||
|
||||
|
||||
/**
|
||||
* gimp_bpp_to_babl_format:
|
||||
* @bpp: bytes per pixel
|
||||
*
|
||||
* Return the Babl format to use for a given number of bytes per pixel.
|
||||
* This function assumes that the data is 8bit gamma-corrected data.
|
||||
*
|
||||
* Return value: the Babl format to use
|
||||
**/
|
||||
const Babl *
|
||||
gimp_bpp_to_babl_format (guint bpp)
|
||||
{
|
||||
|
@ -47,3 +56,32 @@ gimp_bpp_to_babl_format (guint bpp)
|
|||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_bpp_to_babl_format_linear:
|
||||
* @bpp: bytes per pixel
|
||||
*
|
||||
* Return the Babl format to use for a given number of bytes per pixel.
|
||||
* This function assumes that the data is 8bit linear.
|
||||
*
|
||||
* Return value: the Babl format to use
|
||||
**/
|
||||
const Babl *
|
||||
gimp_bpp_to_babl_format_linear (guint bpp)
|
||||
{
|
||||
g_return_val_if_fail (bpp > 0 && bpp <= 4, NULL);
|
||||
|
||||
switch (bpp)
|
||||
{
|
||||
case 1:
|
||||
return babl_format ("Y u8");
|
||||
case 2:
|
||||
return babl_format ("YA u8");
|
||||
case 3:
|
||||
return babl_format ("RGB u8");
|
||||
case 4:
|
||||
return babl_format ("RGBA u8");
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -23,7 +23,9 @@
|
|||
#define __GIMP_GEGL_UTILS_H__
|
||||
|
||||
|
||||
const Babl * gimp_bpp_to_babl_format (guint bpp) G_GNUC_CONST;
|
||||
const Babl * gimp_bpp_to_babl_format (guint bpp) G_GNUC_CONST;
|
||||
const Babl * gimp_bpp_to_babl_format_linear (guint bpp) G_GNUC_CONST;
|
||||
|
||||
|
||||
|
||||
#endif /* __GIMP_GEGL_UTILS_H__ */
|
||||
|
|
|
@ -43,7 +43,8 @@
|
|||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_TILE_MANAGER
|
||||
PROP_TILE_MANAGER,
|
||||
PROP_LINEAR
|
||||
};
|
||||
|
||||
enum
|
||||
|
@ -109,6 +110,14 @@ gimp_operation_tile_sink_class_init (GimpOperationTileSinkClass * klass)
|
|||
GIMP_TYPE_TILE_MANAGER,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT));
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_LINEAR,
|
||||
g_param_spec_boolean ("linear",
|
||||
"Linear data",
|
||||
"Should the data written to the tile-manager be linear or gamma-corrected?",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -144,6 +153,10 @@ gimp_operation_tile_sink_get_property (GObject *object,
|
|||
g_value_set_boxed (value, self->tile_manager);
|
||||
break;
|
||||
|
||||
case PROP_LINEAR:
|
||||
g_value_set_boolean (value, self->linear);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
|
@ -166,6 +179,10 @@ gimp_operation_tile_sink_set_property (GObject *object,
|
|||
self->tile_manager = g_value_dup_boxed (value);
|
||||
break;
|
||||
|
||||
case PROP_LINEAR:
|
||||
self->linear = g_value_get_boolean (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
|
@ -184,10 +201,15 @@ gimp_operation_tile_sink_process (GeglOperation *operation,
|
|||
const Babl *format;
|
||||
const GeglRectangle *extent;
|
||||
PixelRegion destPR;
|
||||
const guint bpp = tile_manager_bpp (self->tile_manager);
|
||||
gpointer pr;
|
||||
|
||||
extent = gegl_operation_result_rect (operation, context_id);
|
||||
format = gimp_bpp_to_babl_format (tile_manager_bpp (self->tile_manager));
|
||||
|
||||
if (self->linear)
|
||||
format = gimp_bpp_to_babl_format_linear (bpp);
|
||||
else
|
||||
format = gimp_bpp_to_babl_format (bpp);
|
||||
|
||||
input = GEGL_BUFFER (gegl_operation_get_data (operation, context_id,
|
||||
"input"));
|
||||
|
|
|
@ -39,6 +39,7 @@ struct _GimpOperationTileSink
|
|||
GeglOperationSink parent_instance;
|
||||
|
||||
TileManager *tile_manager;
|
||||
gboolean linear; /* should linear data be assumed */
|
||||
};
|
||||
|
||||
struct _GimpOperationTileSinkClass
|
||||
|
|
|
@ -40,7 +40,8 @@
|
|||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_TILE_MANAGER
|
||||
PROP_TILE_MANAGER,
|
||||
PROP_LINEAR
|
||||
};
|
||||
|
||||
|
||||
|
@ -97,6 +98,14 @@ gimp_operation_tile_source_class_init (GimpOperationTileSourceClass * klass)
|
|||
GIMP_TYPE_TILE_MANAGER,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT));
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_LINEAR,
|
||||
g_param_spec_boolean ("linear",
|
||||
"Linear data",
|
||||
"Should the data read from the tile-manager assumed to be linear or gamma-corrected?",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -132,6 +141,10 @@ gimp_operation_tile_source_get_property (GObject *object,
|
|||
g_value_set_boxed (value, self->tile_manager);
|
||||
break;
|
||||
|
||||
case PROP_LINEAR:
|
||||
g_value_set_boolean (value, self->linear);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
|
@ -154,6 +167,10 @@ gimp_operation_tile_source_set_property (GObject *object,
|
|||
self->tile_manager = g_value_dup_boxed (value);
|
||||
break;
|
||||
|
||||
case PROP_LINEAR:
|
||||
self->linear = g_value_get_boolean (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
|
@ -189,10 +206,15 @@ gimp_operation_tile_source_process (GeglOperation *operation,
|
|||
const Babl *format;
|
||||
const GeglRectangle *extent;
|
||||
PixelRegion srcPR;
|
||||
const guint bpp = tile_manager_bpp (self->tile_manager);
|
||||
gpointer pr;
|
||||
|
||||
extent = gegl_operation_result_rect (operation, context_id);
|
||||
format = gimp_bpp_to_babl_format (tile_manager_bpp (self->tile_manager));
|
||||
|
||||
if (self->linear)
|
||||
format = gimp_bpp_to_babl_format_linear (bpp);
|
||||
else
|
||||
format = gimp_bpp_to_babl_format (bpp);
|
||||
|
||||
output = gegl_buffer_new (extent, format);
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ struct _GimpOperationTileSource
|
|||
GeglOperationSource parent_instance;
|
||||
|
||||
TileManager *tile_manager;
|
||||
gboolean linear; /* should linear data be assumed */
|
||||
};
|
||||
|
||||
struct _GimpOperationTileSourceClass
|
||||
|
|
Loading…
Reference in a new issue