Commit 5439fe5b authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

app/tools/airbrush.c app/tools/by_color_select.c include

2001-01-24  Sven Neumann  <sven@gimp.org>

	* app/tools/airbrush.c
	* app/tools/by_color_select.c
	* app/tools/color_picker.c: include gimpcolor/gimpcolor.h

	* libgimpcolor/gimprgb.c: optimized compositing functions.

	* plug-ins/Lighting/lighting_preview.c
	* plug-ins/MapObject/mapobject_preview.c: use gimp_rgb_composite
	functions instead of doing the blending manually

	* plug-ins/MapObject/map_object_shade.c: fixed a rendering bug when
	transparent_background == FALSE
parent 113e1cc9
2001-01-24 Sven Neumann <sven@gimp.org>
* app/tools/airbrush.c
* app/tools/by_color_select.c
* app/tools/color_picker.c: include gimpcolor/gimpcolor.h
* libgimpcolor/gimprgb.c: optimized compositing functions.
* plug-ins/Lighting/lighting_preview.c
* plug-ins/MapObject/mapobject_preview.c: use gimp_rgb_composite
functions instead of doing the blending manually
* plug-ins/MapObject/map_object_shade.c: fixed a rendering bug when
transparent_background == FALSE
2001-01-24 Michael Natterer <mitch@gimp.org>
* Makefile.am
......
......@@ -20,6 +20,8 @@
#include <gtk/gtk.h>
#include "libgimpcolor/gimpcolor.h"
#include "apptypes.h"
#include "appenv.h"
......
......@@ -20,6 +20,8 @@
#include <gtk/gtk.h>
#include "libgimpcolor/gimpcolor.h"
#include "apptypes.h"
#include "appenv.h"
......
......@@ -21,6 +21,8 @@
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include "libgimpcolor/gimpcolor.h"
#include "apptypes.h"
#include "appenv.h"
......
......@@ -20,9 +20,9 @@
#include <gtk/gtk.h>
#include "apptypes.h"
#include "libgimpcolor/gimpcolor.h"
#include "libgimp/gimpcolorarea.h"
#include "apptypes.h"
#include "appenv.h"
#include "color_picker.h"
......@@ -38,6 +38,8 @@
#include "tools.h"
#include "tool_options.h"
#include "libgimp/gimpcolorarea.h"
#include "libgimp/gimpintl.h"
......
......@@ -20,6 +20,8 @@
#include <gtk/gtk.h>
#include "libgimpcolor/gimpcolor.h"
#include "apptypes.h"
#include "appenv.h"
......
......@@ -21,6 +21,8 @@
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include "libgimpcolor/gimpcolor.h"
#include "apptypes.h"
#include "appenv.h"
......
......@@ -205,20 +205,30 @@ gimp_rgb_composite (GimpRGB *color1,
case GIMP_RGB_COMPOSITE_NORMAL:
/* put color2 on top of color1 */
factor = color1->a * (1.0 - color2->a);
color1->r = color1->r * factor + color2->r * color2->a;
color1->g = color1->g * factor + color2->g * color2->a;
color1->b = color1->b * factor + color2->b * color2->a;
color1->a = factor + color2->a;
if (color2->a == 1.0)
{
*color1 = *color2;
}
else
{
factor = color1->a * (1.0 - color2->a);
color1->r = color1->r * factor + color2->r * color2->a;
color1->g = color1->g * factor + color2->g * color2->a;
color1->b = color1->b * factor + color2->b * color2->a;
color1->a = factor + color2->a;
}
break;
case GIMP_RGB_COMPOSITE_BEHIND:
/* put color2 below color1 */
factor = color2->a * (1.0 - color1->a);
color1->r = color2->r * factor + color1->r * color1->a;
color1->g = color2->g * factor + color1->g * color1->a;
color1->b = color2->b * factor + color1->b * color1->a;
color1->a = factor + color1->a;
if (color1->a < 1.0)
{
factor = color2->a * (1.0 - color1->a);
color1->r = color2->r * factor + color1->r * color1->a;
color1->g = color2->g * factor + color1->g * color1->a;
color1->b = color2->b * factor + color1->b * color1->a;
color1->a = factor + color1->a;
}
break;
}
}
......
......@@ -39,7 +39,8 @@ compute_preview (gint startx,
gint xcnt, ycnt, f1, f2;
gdouble imagex, imagey;
gint32 index = 0;
GimpRGB color, darkcheck, lightcheck, temp;
GimpRGB color;
GimpRGB lightcheck, darkcheck;
GimpVector3 pos;
get_ray_func ray_func;
......@@ -80,9 +81,10 @@ compute_preview (gint startx,
init_compute ();
precompute_init (width, height);
gimp_rgb_set (&lightcheck, 0.75, 0.75, 0.75);
gimp_rgb_set (&darkcheck, 0.50, 0.50, 0.50);
gimp_rgb_set (&color, 0.3, 0.7, 1.0);
gimp_rgba_set (&lightcheck,
GIMP_CHECK_LIGHT, GIMP_CHECK_LIGHT, GIMP_CHECK_LIGHT, 1.0);
gimp_rgba_set (&darkcheck,
GIMP_CHECK_DARK, GIMP_CHECK_DARK, GIMP_CHECK_DARK, 1.0);
if (mapvals.bump_mapped == TRUE && mapvals.bumpmap_id != -1)
{
......@@ -141,36 +143,26 @@ compute_preview (gint startx,
if (f1)
{
if (color.a == 0.0)
{
color=lightcheck;
}
color = lightcheck;
else
{
gimp_rgb_multiply (&color, color.a);
temp = lightcheck;
gimp_rgb_multiply (&temp, 1.0 - color.a);
gimp_rgb_add (&color, &temp);
}
gimp_rgb_composite (&color, &lightcheck,
GIMP_RGB_COMPOSITE_BEHIND);
}
else
{
if (color.a == 0.0)
{
color = darkcheck;
}
color = darkcheck;
else
{
gimp_rgb_multiply (&color, color.a);
temp = darkcheck;
gimp_rgb_multiply (&temp, 1.0 - color.a);
gimp_rgb_add (&color, &temp);
}
gimp_rgb_composite (&color, &darkcheck,
GIMP_RGB_COMPOSITE_BEHIND);
}
}
preview_rgb_data[index++] = (guchar) (255.0 * color.r);
preview_rgb_data[index++] = (guchar) (255.0 * color.g);
preview_rgb_data[index++] = (guchar) (255.0 * color.b);
gimp_rgb_get_uchar (&color,
preview_rgb_data + index,
preview_rgb_data + index + 1,
preview_rgb_data + index + 2);
index += 3;
imagex++;
}
else
......
......@@ -167,7 +167,6 @@ compute_preview (gint x,
GimpVector3 p1, p2;
GimpRGB color;
GimpRGB lightcheck, darkcheck;
GimpRGB temp;
gint xcnt, ycnt, f1, f2;
glong index = 0;
......@@ -201,8 +200,10 @@ compute_preview (gint x,
gimp_rgb_set_alpha (&background, 1.0);
}
gimp_rgb_set (&lightcheck, 0.75, 0.75, 0.75);
gimp_rgb_set (&darkcheck, 0.50, 0.50, 0.50);
gimp_rgba_set (&lightcheck,
GIMP_CHECK_LIGHT, GIMP_CHECK_LIGHT, GIMP_CHECK_LIGHT, 1.0);
gimp_rgba_set (&darkcheck,
GIMP_CHECK_DARK, GIMP_CHECK_DARK, GIMP_CHECK_DARK, 1.0);
gimp_vector3_set (&p2, -1.0, -1.0, 0.0);
for (ycnt = 0; ycnt < ph; ycnt++)
......@@ -224,36 +225,26 @@ compute_preview (gint x,
if (f1)
{
if (color.a == 0.0)
{
color = lightcheck;
}
color = lightcheck;
else
{
gimp_rgb_multiply (&color, color.a);
temp = lightcheck;
gimp_rgb_multiply (&temp, 1.0 - color.a);
gimp_rgb_add (&color, &temp);
}
}
gimp_rgb_composite (&color, &lightcheck,
GIMP_RGB_COMPOSITE_BEHIND);
}
else
{
if (color.a == 0.0)
{
color = darkcheck;
}
color = darkcheck;
else
{
gimp_rgb_multiply (&color, color.a);
temp = darkcheck;
gimp_rgb_multiply (&temp, 1.0 - color.a);
gimp_rgb_add (&color, &temp);
}
gimp_rgb_composite (&color, &darkcheck,
GIMP_RGB_COMPOSITE_BEHIND);
}
}
preview_rgb_data[index++] = (guchar) (color.r * 255.0);
preview_rgb_data[index++] = (guchar) (color.g * 255.0);
preview_rgb_data[index++] = (guchar) (color.b * 255.0);
gimp_rgb_get_uchar (&color,
preview_rgb_data + index,
preview_rgb_data + index + 1,
preview_rgb_data + index + 2);
index += 3;
}
}
......
......@@ -219,8 +219,11 @@ get_ray_color_plane (GimpVector3 *pos)
}
}
if (color.a == 0.0)
color = background;
if (mapvals.transparent_background == FALSE && color.a < 1.0)
{
gimp_rgb_composite (&color, &background,
GIMP_RGB_COMPOSITE_BEHIND);
}
return color;
}
......@@ -391,11 +394,6 @@ get_ray_color_sphere (GimpVector3 *pos)
gimp_rgb_clamp (&color2);
if (mapvals.transparent_background == FALSE && color2.a < 1.0)
{
gimp_rgb_composite (&color2, &background, GIMP_RGB_COMPOSITE_BEHIND);
}
/* Compute a mix of the first and second colors */
/* ============================================ */
......@@ -404,7 +402,7 @@ get_ray_color_sphere (GimpVector3 *pos)
}
else if (color.a != 0.0 &&
inside == TRUE &&
mapvals.lightsource.type!=NO_LIGHT)
mapvals.lightsource.type != NO_LIGHT)
{
/* Compute shading at this point */
/* ============================= */
......@@ -421,8 +419,11 @@ get_ray_color_sphere (GimpVector3 *pos)
}
}
if (color.a == 0.0)
color = background;
if (mapvals.transparent_background == FALSE && color.a < 1.0)
{
gimp_rgb_composite (&color, &background,
GIMP_RGB_COMPOSITE_BEHIND);
}
return color;
}
......
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