diff --git a/ChangeLog b/ChangeLog index 4be5e17181..d987d0812f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2008-01-21 Michael Natterer + + * app/gegl/gimplevelsconfig.[ch]: add utility function + gimp_levels_config_to_levels_cruft() which fills the old Levels + struct from a GimpLevelsConfig object. + + * app/tools/gimplevelstool.c: use it. + 2008-01-21 Michael Natterer * app/gegl/gimpcolorizeconfig.h diff --git a/app/gegl/gimplevelsconfig.c b/app/gegl/gimplevelsconfig.c index eedbda8be3..9593314304 100644 --- a/app/gegl/gimplevelsconfig.c +++ b/app/gegl/gimplevelsconfig.c @@ -30,6 +30,9 @@ #include "base/gimphistogram.h" +/* temp cruft */ +#include "base/levels.h" + #include "gimplevelsconfig.h" @@ -409,3 +412,37 @@ gimp_levels_config_adjust_by_colors (GimpLevelsConfig *config, config->gamma[channel] = log (inten) / log (out_light); } } + + +/* temp cruft */ + +void +gimp_levels_config_to_levels_cruft (GimpLevelsConfig *config, + Levels *cruft, + gboolean is_color) +{ + GimpHistogramChannel channel; + + g_return_if_fail (GIMP_IS_LEVELS_CONFIG (config)); + g_return_if_fail (cruft != NULL); + + for (channel = GIMP_HISTOGRAM_VALUE; + channel <= GIMP_HISTOGRAM_ALPHA; + channel++) + { + cruft->gamma[channel] = config->gamma[channel]; + cruft->low_input[channel] = config->low_input[channel] * 255.999; + cruft->high_input[channel] = config->high_input[channel] * 255.999; + cruft->low_output[channel] = config->low_output[channel] * 255.999; + cruft->high_output[channel] = config->high_output[channel] * 255.999; + } + + if (! is_color) + { + cruft->gamma[1] = cruft->gamma[GIMP_HISTOGRAM_ALPHA]; + cruft->low_input[1] = cruft->low_input[GIMP_HISTOGRAM_ALPHA]; + cruft->high_input[1] = cruft->high_input[GIMP_HISTOGRAM_ALPHA]; + cruft->low_output[1] = cruft->low_output[GIMP_HISTOGRAM_ALPHA]; + cruft->high_output[1] = cruft->high_output[GIMP_HISTOGRAM_ALPHA]; + } +} diff --git a/app/gegl/gimplevelsconfig.h b/app/gegl/gimplevelsconfig.h index a2ba8be86e..4f72e1e033 100644 --- a/app/gegl/gimplevelsconfig.h +++ b/app/gegl/gimplevelsconfig.h @@ -72,6 +72,10 @@ void gimp_levels_config_adjust_by_colors (GimpLevelsConfig *config, const GimpRGB *gray, const GimpRGB *white); +/* temp cruft */ +void gimp_levels_config_to_levels_cruft (GimpLevelsConfig *config, + Levels *cruft, + gboolean is_color); #endif /* __GIMP_LEVELS_CONFIG_H__ */ diff --git a/app/tools/gimplevelstool.c b/app/tools/gimplevelstool.c index 5f546f6a13..0592a88bc7 100644 --- a/app/tools/gimplevelstool.c +++ b/app/tools/gimplevelstool.c @@ -284,35 +284,13 @@ gimp_levels_tool_get_operation (GimpImageMapTool *im_tool) static void gimp_levels_tool_map (GimpImageMapTool *image_map_tool) { - GimpLevelsTool *tool = GIMP_LEVELS_TOOL (image_map_tool); - GimpLevelsConfig *config = tool->config; - Levels *levels = tool->levels; - GimpHistogramChannel channel; + GimpLevelsTool *tool = GIMP_LEVELS_TOOL (image_map_tool); - for (channel = GIMP_HISTOGRAM_VALUE; - channel <= GIMP_HISTOGRAM_ALPHA; - channel++) - { - levels->gamma[channel] = config->gamma[channel]; - levels->low_input[channel] = config->low_input[channel] * 255.999; - levels->high_input[channel] = config->high_input[channel] * 255.999; - levels->low_output[channel] = config->low_output[channel] * 255.999; - levels->high_output[channel] = config->high_output[channel] * 255.999; - } - - /* FIXME: hack */ - if (! tool->color) - { - levels->gamma[1] = levels->gamma[GIMP_HISTOGRAM_ALPHA]; - levels->low_input[1] = levels->low_input[GIMP_HISTOGRAM_ALPHA]; - levels->high_input[1] = levels->high_input[GIMP_HISTOGRAM_ALPHA]; - levels->low_output[1] = levels->low_output[GIMP_HISTOGRAM_ALPHA]; - levels->high_output[1] = levels->high_output[GIMP_HISTOGRAM_ALPHA]; - } + gimp_levels_config_to_levels_cruft (tool->config, tool->levels, tool->color); gimp_lut_setup (tool->lut, (GimpLutFunc) levels_lut_func, - levels, + tool->levels, gimp_drawable_bytes (image_map_tool->drawable)); } @@ -853,6 +831,7 @@ static void levels_update_input_bar (GimpLevelsTool *tool) { /* Recalculate the transfer arrays */ + gimp_levels_config_to_levels_cruft (tool->config, tool->levels, tool->color); levels_calculate_transfers (tool->levels); switch (tool->channel)