mirror of https://github.com/GNOME/gimp.git
app: use gimp_image_transform_rgb() instead of transform_color()
instead of fiddling with gimp_rgb_get_uchar() manually.
This commit is contained in:
parent
54108d9413
commit
dc8d6a3977
|
@ -19,9 +19,11 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <cairo.h>
|
||||
#include <gegl.h>
|
||||
|
||||
#include "libgimpbase/gimpbase.h"
|
||||
#include "libgimpcolor/gimpcolor.h"
|
||||
|
||||
#include "core-types.h"
|
||||
|
||||
|
@ -569,13 +571,10 @@ gimp_edit_fill_internal (GimpImage *image,
|
|||
|
||||
case GIMP_WHITE_FILL:
|
||||
{
|
||||
guchar tmp_col[MAX_CHANNELS];
|
||||
GimpRGB white;
|
||||
|
||||
tmp_col[RED] = 255;
|
||||
tmp_col[GREEN] = 255;
|
||||
tmp_col[BLUE] = 255;
|
||||
gimp_image_transform_color (image, drawable_type, col,
|
||||
GIMP_RGB, tmp_col);
|
||||
gimp_rgb_set (&white, 1.0, 1.0, 1.0);
|
||||
gimp_image_transform_rgb (image, drawable_type, &white, col);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -152,15 +152,8 @@ gimp_drawable_bucket_fill_full (GimpDrawable *drawable,
|
|||
if (fill_mode == GIMP_FG_BUCKET_FILL ||
|
||||
fill_mode == GIMP_BG_BUCKET_FILL)
|
||||
{
|
||||
guchar tmp_col[MAX_CHANNELS];
|
||||
|
||||
gimp_rgb_get_uchar (color,
|
||||
&tmp_col[RED],
|
||||
&tmp_col[GREEN],
|
||||
&tmp_col[BLUE]);
|
||||
|
||||
gimp_image_transform_color (image, gimp_drawable_type (drawable), col,
|
||||
GIMP_RGB, tmp_col);
|
||||
gimp_image_transform_rgb (image, gimp_drawable_type (drawable),
|
||||
color, col);
|
||||
col[gimp_drawable_bytes_with_alpha (drawable) - 1] = OPAQUE_OPACITY;
|
||||
}
|
||||
else if (fill_mode == GIMP_PATTERN_BUCKET_FILL)
|
||||
|
|
|
@ -367,16 +367,10 @@ gimp_drawable_stroke_scan_convert (GimpDrawable *drawable,
|
|||
{
|
||||
case GIMP_FILL_STYLE_SOLID:
|
||||
{
|
||||
guchar tmp_col[MAX_CHANNELS] = { 0, };
|
||||
guchar col[MAX_CHANNELS] = { 0, };
|
||||
|
||||
gimp_rgb_get_uchar (&context->foreground,
|
||||
&tmp_col[RED],
|
||||
&tmp_col[GREEN],
|
||||
&tmp_col[BLUE]);
|
||||
|
||||
gimp_image_transform_color (image, gimp_drawable_type (drawable), col,
|
||||
GIMP_RGB, tmp_col);
|
||||
gimp_image_get_foreground (image, context,
|
||||
gimp_drawable_type (drawable), col);
|
||||
col[bytes - 1] = OPAQUE_OPACITY;
|
||||
|
||||
color_region_mask (&basePR, &maskPR, col);
|
||||
|
|
|
@ -2533,46 +2533,6 @@ gimp_image_inc_instance_count (GimpImage *image)
|
|||
|
||||
/* color transforms / utilities */
|
||||
|
||||
void
|
||||
gimp_image_get_foreground (const GimpImage *image,
|
||||
GimpContext *context,
|
||||
GimpImageType dest_type,
|
||||
guchar *fg)
|
||||
{
|
||||
GimpRGB color;
|
||||
guchar pfg[3];
|
||||
|
||||
g_return_if_fail (GIMP_IS_IMAGE (image));
|
||||
g_return_if_fail (GIMP_IS_CONTEXT (context));
|
||||
g_return_if_fail (fg != NULL);
|
||||
|
||||
gimp_context_get_foreground (context, &color);
|
||||
|
||||
gimp_rgb_get_uchar (&color, &pfg[0], &pfg[1], &pfg[2]);
|
||||
|
||||
gimp_image_transform_color (image, dest_type, fg, GIMP_RGB, pfg);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_get_background (const GimpImage *image,
|
||||
GimpContext *context,
|
||||
GimpImageType dest_type,
|
||||
guchar *bg)
|
||||
{
|
||||
GimpRGB color;
|
||||
guchar pbg[3];
|
||||
|
||||
g_return_if_fail (GIMP_IS_IMAGE (image));
|
||||
g_return_if_fail (GIMP_IS_CONTEXT (context));
|
||||
g_return_if_fail (bg != NULL);
|
||||
|
||||
gimp_context_get_background (context, &color);
|
||||
|
||||
gimp_rgb_get_uchar (&color, &pbg[0], &pbg[1], &pbg[2]);
|
||||
|
||||
gimp_image_transform_color (image, dest_type, bg, GIMP_RGB, pbg);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_get_color (const GimpImage *src_image,
|
||||
GimpImageType src_type,
|
||||
|
@ -2627,6 +2587,40 @@ gimp_image_get_color (const GimpImage *src_image,
|
|||
*rgba = OPAQUE_OPACITY;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_get_foreground (const GimpImage *image,
|
||||
GimpContext *context,
|
||||
GimpImageType dest_type,
|
||||
guchar *fg)
|
||||
{
|
||||
GimpRGB color;
|
||||
|
||||
g_return_if_fail (GIMP_IS_IMAGE (image));
|
||||
g_return_if_fail (GIMP_IS_CONTEXT (context));
|
||||
g_return_if_fail (fg != NULL);
|
||||
|
||||
gimp_context_get_foreground (context, &color);
|
||||
|
||||
gimp_image_transform_rgb (image, dest_type, &color, fg);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_get_background (const GimpImage *image,
|
||||
GimpContext *context,
|
||||
GimpImageType dest_type,
|
||||
guchar *bg)
|
||||
{
|
||||
GimpRGB color;
|
||||
|
||||
g_return_if_fail (GIMP_IS_IMAGE (image));
|
||||
g_return_if_fail (GIMP_IS_CONTEXT (context));
|
||||
g_return_if_fail (bg != NULL);
|
||||
|
||||
gimp_context_get_background (context, &color);
|
||||
|
||||
gimp_image_transform_rgb (image, dest_type, &color, bg);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_transform_rgb (const GimpImage *dest_image,
|
||||
GimpImageType dest_type,
|
||||
|
|
|
@ -323,6 +323,11 @@ void gimp_image_inc_instance_count (GimpImage *image);
|
|||
|
||||
/* color transforms / utilities */
|
||||
|
||||
void gimp_image_get_color (const GimpImage *src_image,
|
||||
GimpImageType src_type,
|
||||
const guchar *src,
|
||||
guchar *rgba);
|
||||
|
||||
void gimp_image_get_foreground (const GimpImage *image,
|
||||
GimpContext *context,
|
||||
GimpImageType dest_type,
|
||||
|
@ -331,10 +336,6 @@ void gimp_image_get_background (const GimpImage *image,
|
|||
GimpContext *context,
|
||||
GimpImageType dest_type,
|
||||
guchar *bg);
|
||||
void gimp_image_get_color (const GimpImage *src_image,
|
||||
GimpImageType src_type,
|
||||
const guchar *src,
|
||||
guchar *rgba);
|
||||
void gimp_image_transform_rgb (const GimpImage *dest_image,
|
||||
GimpImageType dest_type,
|
||||
const GimpRGB *rgb,
|
||||
|
|
|
@ -119,11 +119,14 @@ _gimp_paintbrush_motion (GimpPaintCore *paint_core,
|
|||
GimpImage *image;
|
||||
GimpRGB gradient_color;
|
||||
TempBuf *area;
|
||||
guchar col[MAX_CHANNELS];
|
||||
GimpPaintApplicationMode paint_appl_mode;
|
||||
gdouble fade_point;
|
||||
gdouble grad_point;
|
||||
gdouble force;
|
||||
guchar pixel[MAX_CHANNELS] = { OPAQUE_OPACITY,
|
||||
OPAQUE_OPACITY,
|
||||
OPAQUE_OPACITY,
|
||||
OPAQUE_OPACITY };
|
||||
|
||||
image = gimp_item_get_image (GIMP_ITEM (drawable));
|
||||
|
||||
|
@ -155,26 +158,17 @@ _gimp_paintbrush_motion (GimpPaintCore *paint_core,
|
|||
paint_options,
|
||||
fade_point);
|
||||
|
||||
/* optionally take the color from the current gradient */
|
||||
if (gimp_paint_options_get_gradient_color (paint_options, image,
|
||||
grad_point,
|
||||
paint_core->pixel_dist,
|
||||
&gradient_color))
|
||||
{
|
||||
guchar pixel[MAX_CHANNELS] = { OPAQUE_OPACITY,
|
||||
OPAQUE_OPACITY,
|
||||
OPAQUE_OPACITY,
|
||||
OPAQUE_OPACITY };
|
||||
/* optionally take the color from the current gradient */
|
||||
|
||||
opacity *= gradient_color.a;
|
||||
|
||||
gimp_rgb_get_uchar (&gradient_color,
|
||||
&col[RED],
|
||||
&col[GREEN],
|
||||
&col[BLUE]);
|
||||
|
||||
gimp_image_transform_color (image, gimp_drawable_type (drawable), pixel,
|
||||
GIMP_RGB, col);
|
||||
gimp_image_transform_rgb (image, gimp_drawable_type (drawable),
|
||||
&gradient_color, pixel);
|
||||
|
||||
color_pixels (temp_buf_get_data (area), pixel,
|
||||
area->width * area->height,
|
||||
|
@ -182,9 +176,12 @@ _gimp_paintbrush_motion (GimpPaintCore *paint_core,
|
|||
|
||||
paint_appl_mode = GIMP_PAINT_INCREMENTAL;
|
||||
}
|
||||
/* otherwise check if the brush has a pixmap and use that to color the area */
|
||||
else if (brush_core->brush && brush_core->brush->pixmap)
|
||||
{
|
||||
/* otherwise check if the brush has a pixmap and use that to
|
||||
* color the area
|
||||
*/
|
||||
|
||||
gimp_brush_core_color_area_with_pixmap (brush_core, drawable,
|
||||
coords,
|
||||
area,
|
||||
|
@ -192,15 +189,14 @@ _gimp_paintbrush_motion (GimpPaintCore *paint_core,
|
|||
|
||||
paint_appl_mode = GIMP_PAINT_INCREMENTAL;
|
||||
}
|
||||
/* otherwise fill the area with the foreground color */
|
||||
else
|
||||
{
|
||||
/* otherwise fill the area with the foreground color */
|
||||
|
||||
gimp_image_get_foreground (image, context, gimp_drawable_type (drawable),
|
||||
col);
|
||||
pixel);
|
||||
|
||||
col[area->bytes - 1] = OPAQUE_OPACITY;
|
||||
|
||||
color_pixels (temp_buf_get_data (area), col,
|
||||
color_pixels (temp_buf_get_data (area), pixel,
|
||||
area->width * area->height,
|
||||
area->bytes);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue