mirror of https://github.com/GNOME/gimp.git
libgimpbase/Makefile.am libgimpbase/gimpchecks.[ch] added
2004-09-03 Sven Neumann <sven@gimp.org> * libgimpbase/Makefile.am * libgimpbase/gimpchecks.[ch] added gimp_checks_get_shades(). * app/base/temp-buf.c * app/display/gimpdisplayshell-render.c * libgimpwidgets/gimppreviewarea.c: use the new function instead of replicating these numbers in three different places.
This commit is contained in:
parent
dfa47f2736
commit
4fbc8764b4
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
2004-09-03 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
|
* libgimpbase/Makefile.am
|
||||||
|
* libgimpbase/gimpchecks.[ch] added gimp_checks_get_shades().
|
||||||
|
|
||||||
|
* app/base/temp-buf.c
|
||||||
|
* app/display/gimpdisplayshell-render.c
|
||||||
|
* libgimpwidgets/gimppreviewarea.c: use the new function instead
|
||||||
|
of replicating these numbers in three different places.
|
||||||
|
|
||||||
2004-09-03 DindinX <david@dindinx.org>
|
2004-09-03 DindinX <david@dindinx.org>
|
||||||
|
|
||||||
* plug-ins/gimpressionist/*.c: made the code much more readable by
|
* plug-ins/gimpressionist/*.c: made the code much more readable by
|
||||||
|
|
|
@ -244,8 +244,8 @@ temp_buf_new_check (gint width,
|
||||||
guchar *data;
|
guchar *data;
|
||||||
guchar check_shift = 0;
|
guchar check_shift = 0;
|
||||||
guchar check_mod = 0;
|
guchar check_mod = 0;
|
||||||
guchar fg_color = 0;
|
guchar check_light = 0;
|
||||||
guchar bg_color = 0;
|
guchar check_dark = 0;
|
||||||
gint x, y;
|
gint x, y;
|
||||||
|
|
||||||
g_return_val_if_fail (width > 0 && height > 0, NULL);
|
g_return_val_if_fail (width > 0 && height > 0, NULL);
|
||||||
|
@ -266,40 +266,15 @@ temp_buf_new_check (gint width,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (check_type)
|
gimp_checks_get_shades (check_type, &check_light, &check_dark);
|
||||||
{
|
|
||||||
case GIMP_CHECK_TYPE_LIGHT_CHECKS:
|
|
||||||
fg_color = 204;
|
|
||||||
bg_color = 255;
|
|
||||||
break;
|
|
||||||
case GIMP_CHECK_TYPE_GRAY_CHECKS:
|
|
||||||
fg_color = 102;
|
|
||||||
bg_color = 153;
|
|
||||||
break;
|
|
||||||
case GIMP_CHECK_TYPE_DARK_CHECKS:
|
|
||||||
fg_color = 0;
|
|
||||||
bg_color = 51;
|
|
||||||
break;
|
|
||||||
case GIMP_CHECK_TYPE_WHITE_ONLY:
|
|
||||||
fg_color = 255;
|
|
||||||
bg_color = 255;
|
|
||||||
break;
|
|
||||||
case GIMP_CHECK_TYPE_GRAY_ONLY:
|
|
||||||
fg_color = 127;
|
|
||||||
bg_color = 127;
|
|
||||||
break;
|
|
||||||
case GIMP_CHECK_TYPE_BLACK_ONLY:
|
|
||||||
fg_color = 0;
|
|
||||||
bg_color = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
newbuf = temp_buf_new (width, height, 3, 0, 0, NULL);
|
newbuf = temp_buf_new (width, height, 3, 0, 0, NULL);
|
||||||
data = temp_buf_data (newbuf);
|
data = temp_buf_data (newbuf);
|
||||||
|
|
||||||
for (y = 0; y < height; y++)
|
for (y = 0; y < height; y++)
|
||||||
{
|
{
|
||||||
guchar dark = y >> check_shift;
|
guchar check_dark = y >> check_shift;
|
||||||
guchar color = (dark & 0x1) ? bg_color : fg_color;
|
guchar color = (check_dark & 0x1) ? check_light : check_dark;
|
||||||
|
|
||||||
for (x = 0; x < width; x++)
|
for (x = 0; x < width; x++)
|
||||||
{
|
{
|
||||||
|
@ -309,8 +284,8 @@ temp_buf_new_check (gint width,
|
||||||
|
|
||||||
if (((x + 1) & check_mod) == 0)
|
if (((x + 1) & check_mod) == 0)
|
||||||
{
|
{
|
||||||
dark += 1;
|
check_dark += 1;
|
||||||
color = (dark & 0x1) ? bg_color : fg_color;
|
color = (check_dark & 0x1) ? check_light : check_dark;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
#include "libgimpbase/gimpbase.h"
|
||||||
#include "libgimpwidgets/gimpwidgets.h"
|
#include "libgimpwidgets/gimpwidgets.h"
|
||||||
|
|
||||||
#include "display-types.h"
|
#include "display-types.h"
|
||||||
|
@ -88,16 +89,6 @@ static guint tile_shift = 0;
|
||||||
static guint check_mod = 0;
|
static guint check_mod = 0;
|
||||||
static guint check_shift = 0;
|
static guint check_shift = 0;
|
||||||
|
|
||||||
static const guchar check_combos[6][2] =
|
|
||||||
{
|
|
||||||
{ 204, 255 }, /* LIGHT_CHECKS */
|
|
||||||
{ 153, 102 }, /* GRAY_CHECKS */
|
|
||||||
{ 0, 51 }, /* DARK_CHECKS */
|
|
||||||
{ 255, 255 }, /* WHITE_ONLY */
|
|
||||||
{ 127, 127 }, /* GRAY_ONLY */
|
|
||||||
{ 0, 0 } /* BLACK_ONLY */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
render_init (Gimp *gimp)
|
render_init (Gimp *gimp)
|
||||||
|
@ -180,6 +171,7 @@ render_setup_notify (gpointer config,
|
||||||
{
|
{
|
||||||
GimpCheckType check_type;
|
GimpCheckType check_type;
|
||||||
GimpCheckSize check_size;
|
GimpCheckSize check_size;
|
||||||
|
guchar light, dark;
|
||||||
gint i, j;
|
gint i, j;
|
||||||
|
|
||||||
g_object_get (config,
|
g_object_get (config,
|
||||||
|
@ -206,16 +198,17 @@ render_setup_notify (gpointer config,
|
||||||
if (! render_blend_white)
|
if (! render_blend_white)
|
||||||
render_blend_white = g_new (guchar, 65536);
|
render_blend_white = g_new (guchar, 65536);
|
||||||
|
|
||||||
|
gimp_checks_get_shades (check_type, &light, &dark);
|
||||||
|
|
||||||
for (i = 0; i < 256; i++)
|
for (i = 0; i < 256; i++)
|
||||||
for (j = 0; j < 256; j++)
|
for (j = 0; j < 256; j++)
|
||||||
{
|
{
|
||||||
render_blend_dark_check [(i << 8) + j] = (guchar)
|
render_blend_dark_check [(i << 8) + j] =
|
||||||
((j * i + check_combos[check_type][0] * (255 - i)) / 255);
|
(guchar) ((j * i + dark * (255 - i)) / 255);
|
||||||
render_blend_light_check [(i << 8) + j] = (guchar)
|
render_blend_light_check [(i << 8) + j] =
|
||||||
((j * i + check_combos[check_type][1] * (255 - i)) / 255);
|
(guchar) ((j * i + light * (255 - i)) / 255);
|
||||||
|
render_blend_white [(i << 8) + j] =
|
||||||
render_blend_white [(i << 8) + j] = (guchar)
|
(guchar) ((j * i + 255 * (255 - i)) / 255);
|
||||||
((j * i + 255 * (255 - i)) / 255);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (check_size)
|
switch (check_size)
|
||||||
|
|
|
@ -1,3 +1,10 @@
|
||||||
|
2004-09-03 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
|
* libgimpbase/libgimpbase-docs.sgml
|
||||||
|
* libgimpbase/libgimpbase-sections.txt
|
||||||
|
* libgimpbase/tmpl/gimpchecks.sgml
|
||||||
|
* libgimpwidgets/tmpl/gimppreviewarea.sgml: updated.
|
||||||
|
|
||||||
2004-09-02 Sven Neumann <sven@gimp.org>
|
2004-09-02 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
* libgimpbase/libgimpbase-sections.txt
|
* libgimpbase/libgimpbase-sections.txt
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
<xi:include href="xml/gimpbasetypes.xml" />
|
<xi:include href="xml/gimpbasetypes.xml" />
|
||||||
<xi:include href="xml/gimpversion.xml" />
|
<xi:include href="xml/gimpversion.xml" />
|
||||||
<xi:include href="xml/gimplimits.xml" />
|
<xi:include href="xml/gimplimits.xml" />
|
||||||
|
<xi:include href="xml/gimpchecks.xml" />
|
||||||
<xi:include href="xml/gimpdatafiles.xml" />
|
<xi:include href="xml/gimpdatafiles.xml" />
|
||||||
<xi:include href="xml/gimpenv.xml" />
|
<xi:include href="xml/gimpenv.xml" />
|
||||||
<xi:include href="xml/gimpmemsize.xml" />
|
<xi:include href="xml/gimpmemsize.xml" />
|
||||||
|
|
|
@ -27,6 +27,11 @@ GIMP_TYPE_IMAGE_TYPE
|
||||||
gimp_image_type_get_type
|
gimp_image_type_get_type
|
||||||
</SECTION>
|
</SECTION>
|
||||||
|
|
||||||
|
<SECTION>
|
||||||
|
<FILE>gimpchecks</FILE>
|
||||||
|
gimp_checks_get_shades
|
||||||
|
</SECTION>
|
||||||
|
|
||||||
<SECTION>
|
<SECTION>
|
||||||
<FILE>gimpenv</FILE>
|
<FILE>gimpenv</FILE>
|
||||||
gimp_directory
|
gimp_directory
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
<!-- ##### SECTION Title ##### -->
|
||||||
|
gimpchecks
|
||||||
|
|
||||||
|
<!-- ##### SECTION Short_Description ##### -->
|
||||||
|
|
||||||
|
|
||||||
|
<!-- ##### SECTION Long_Description ##### -->
|
||||||
|
<para>
|
||||||
|
|
||||||
|
</para>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- ##### SECTION See_Also ##### -->
|
||||||
|
<para>
|
||||||
|
|
||||||
|
</para>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- ##### FUNCTION gimp_checks_get_shades ##### -->
|
||||||
|
<para>
|
||||||
|
|
||||||
|
</para>
|
||||||
|
|
||||||
|
@type:
|
||||||
|
@light:
|
||||||
|
@dark:
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,16 @@ GimpPreviewArea
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- ##### ARG GimpPreviewArea:check-size ##### -->
|
||||||
|
<para>
|
||||||
|
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<!-- ##### ARG GimpPreviewArea:check-type ##### -->
|
||||||
|
<para>
|
||||||
|
|
||||||
|
</para>
|
||||||
|
|
||||||
<!-- ##### FUNCTION gimp_preview_area_new ##### -->
|
<!-- ##### FUNCTION gimp_preview_area_new ##### -->
|
||||||
<para>
|
<para>
|
||||||
|
|
||||||
|
|
|
@ -76,6 +76,8 @@ libgimpbase_sources = \
|
||||||
\
|
\
|
||||||
gimpbase-private.c \
|
gimpbase-private.c \
|
||||||
gimpbase-private.h \
|
gimpbase-private.h \
|
||||||
|
gimpchecks.c \
|
||||||
|
gimpchecks.h \
|
||||||
gimpdatafiles.c \
|
gimpdatafiles.c \
|
||||||
gimpdatafiles.h \
|
gimpdatafiles.h \
|
||||||
gimpenv.c \
|
gimpenv.c \
|
||||||
|
@ -111,6 +113,7 @@ libgimpbaseinclude_HEADERS = \
|
||||||
gimplimits.h \
|
gimplimits.h \
|
||||||
gimpversion.h \
|
gimpversion.h \
|
||||||
\
|
\
|
||||||
|
gimpchecks.h \
|
||||||
gimpdatafiles.h \
|
gimpdatafiles.h \
|
||||||
gimpenv.h \
|
gimpenv.h \
|
||||||
gimpmemsize.h \
|
gimpmemsize.h \
|
||||||
|
|
|
@ -2,6 +2,7 @@ EXPORTS
|
||||||
_gp_params_destroy
|
_gp_params_destroy
|
||||||
gimp_any_to_utf8
|
gimp_any_to_utf8
|
||||||
gimp_base_init
|
gimp_base_init
|
||||||
|
gimp_checks_get_shades
|
||||||
gimp_check_size_get_type
|
gimp_check_size_get_type
|
||||||
gimp_check_type_get_type
|
gimp_check_type_get_type
|
||||||
gimp_data_directory
|
gimp_data_directory
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
#include <libgimpbase/gimpbasetypes.h>
|
#include <libgimpbase/gimpbasetypes.h>
|
||||||
|
|
||||||
|
#include <libgimpbase/gimpchecks.h>
|
||||||
#include <libgimpbase/gimpdatafiles.h>
|
#include <libgimpbase/gimpdatafiles.h>
|
||||||
#include <libgimpbase/gimpenv.h>
|
#include <libgimpbase/gimpenv.h>
|
||||||
#include <libgimpbase/gimplimits.h>
|
#include <libgimpbase/gimplimits.h>
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
/* LIBGIMP - The GIMP Library
|
||||||
|
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library 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
|
||||||
|
* Library General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __GIMP_CHECKS_H__
|
||||||
|
#define __GIMP_CHECKS_H__
|
||||||
|
|
||||||
|
|
||||||
|
void gimp_checks_get_shades (GimpCheckType type,
|
||||||
|
guchar *light,
|
||||||
|
guchar *dark);
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* __GIMP_CHECKS_H__ */
|
|
@ -262,26 +262,6 @@ gimp_preview_area_get_check_size (GimpPreviewArea *area)
|
||||||
return (1 << (2 + area->check_size));
|
return (1 << (2 + area->check_size));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
gimp_preview_area_get_check_colors (GimpPreviewArea *area,
|
|
||||||
guchar *light,
|
|
||||||
guchar *dark)
|
|
||||||
{
|
|
||||||
GimpCheckType type = CLAMP (area->check_type, 0, 5);
|
|
||||||
|
|
||||||
const guchar check_colors[6][2] =
|
|
||||||
{
|
|
||||||
{ 204, 255 }, /* LIGHT_CHECKS */
|
|
||||||
{ 153, 102 }, /* GRAY_CHECKS */
|
|
||||||
{ 0, 51 }, /* DARK_CHECKS */
|
|
||||||
{ 255, 255 }, /* WHITE_ONLY */
|
|
||||||
{ 127, 127 }, /* GRAY_ONLY */
|
|
||||||
{ 0, 0 } /* BLACK_ONLY */
|
|
||||||
};
|
|
||||||
|
|
||||||
*light = check_colors[type][0];
|
|
||||||
*dark = check_colors[type][1];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -391,8 +371,8 @@ gimp_preview_area_draw (GimpPreviewArea *area,
|
||||||
area->buf = g_new (guchar, area->rowstride * area->height);
|
area->buf = g_new (guchar, area->rowstride * area->height);
|
||||||
}
|
}
|
||||||
|
|
||||||
size = gimp_preview_area_get_check_size (area);
|
size = 1 << (2 + area->check_size);
|
||||||
gimp_preview_area_get_check_colors (area, &light, &dark);
|
gimp_checks_get_shades (area->check_type, &light, &dark);
|
||||||
|
|
||||||
#define CHECK_COLOR(area, row, col) \
|
#define CHECK_COLOR(area, row, col) \
|
||||||
(((((area)->offset_y + (row)) & size) ^ \
|
(((((area)->offset_y + (row)) & size) ^ \
|
||||||
|
|
Loading…
Reference in New Issue