gimp/app/display/gimpdisplayshell-render.c

915 lines
20 KiB
C
Raw Normal View History

1997-11-25 06:05:25 +08:00
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1997-11-25 06:05:25 +08:00
*/
#include "config.h"
1997-11-25 06:05:25 +08:00
#include <stdlib.h>
#include <string.h>
#include <gtk/gtk.h>
#include "display-types.h"
new directory app/base/ 2001-05-15 Michael Natterer <mitch@gimp.org> * configure.in: new directory app/base/ * app/Makefile.am * app/boundary.[ch] * app/brush_scale.[ch] * app/gimpchecks.h * app/gimplut.[ch] * app/pixel_processor.[ch] * app/pixel_region.[ch] * app/pixel_surround.[ch] * app/temp_buf.[ch] * app/tile.[ch] * app/tile_cache.[ch] * app/tile_manager.[ch] * app/tile_manager_pvt.h * app/tile_pvt.h * app/tile_swap.[ch]: moved to base/ * app/base/Makefile.am * app/base/base-types.h * app/base/*: new directory for the sub-object pixel maniplation and storage stuff. Does not include Gtk+ or anything outside base/. Did some cleanup in all files. * app/appenums.h * app/apptypes.h * app/core/gimpimage.h: removed types which are now in base/base-types.h. * app/base/base-config.[ch] * app/gimprc.[ch]: put the config variables for base/ to their own file so base/ doesn not have to include gimprc.h (does not yet work, i.e. the variables are un-configurable right now) * app/main.c: set a log handler for "Gimp-Base". * app/paint-funcs/Makefile.am * app/paint-funcs/paint-funcs.[ch]: removed the color hash which maps RGB to color indices because it's a totally standalone system which has nothing to do with the paint-funcs and introduced a GimpImage dependency. paint-funcs/ should be considered on the same sub-object (glib-only) level as base/, only in a different directory. * app/core/Makefile.am * app/core/gimpimage-colorhash.[ch]: put the color hash here. * app/gimage.c: don't invalidate the color hash here... * app/core/gimpimage.c: ... but in the colormap_changed() default inplementation. Initialize the hash in class_init(). * tools/pdbgen/Makefile.am: scan app/base/base-types.h for enums. * tools/pdbgen/enums.pl: regenerated. * app/[lots] * app/core/[of] * app/gui/[files] * app/pdb/[all] * app/tools/[over] * app/widgets/[the] * tools/pdbgen/pdb/[place]: changed #includes accordingly. And use base_config->value instead of the stuff from gimprc.h.
2001-05-15 19:25:25 +08:00
#include "base/tile-manager.h"
#include "base/tile.h"
#include "core/gimpimage.h"
#include "core/gimpimage-projection.h"
#include "gimpdisplay.h"
2001-11-01 05:20:09 +08:00
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-filter.h"
app/display/Makefile.am app/display/gimpdisplay-callbacks.[ch] 2001-11-01 Michael Natterer <mitch@gimp.org> * app/display/Makefile.am * app/display/gimpdisplay-callbacks.[ch] * app/display/gimpdisplay-render.[ch] * app/display/gimpdisplay-scale.[ch] * app/display/gimpdisplay-scroll.[ch]: removed and added as gimpdisplayshell-foo.[ch] because they are all methods of the shell. * app/display/gimpdisplay.[ch] * app/display/gimpdisplayshell.[ch]: moved the "offset" and "size" variables from GimpDisplay to GimpDisplayShell. GimpDisplay should know nothing about screen coordinates. The gdisplay_[un]transform_foo() methods are still part of GimpDisplay but will be moved to GimpDisplayShell as soon as the tools' vitrual functions speak in image coordinates instead of GdkEvents. * app/display/gimpdisplayshell-callbacks.[ch]: prefixed all functions with gimp_display_shell_*. Moved some stuff to a "realize" callback File still has to be renamed. * app/display/gimpdisplay-foreach.[ch]: removed gdisplays_shrink_wrap(). * app/gui/menus.c * app/gui/view-commands.[ch] * app/display/gimpdisplayshell-scale.[ch]: implemented "Zoom to Fit Window" function (#57670). * app/nav_window.c * app/display/gimpdisplay-handlers.c * app/display/gimpdisplayshell-render.[ch] * app/display/gimpdisplayshell-scale.[ch] * app/display/gimpdisplayshell-scroll.[ch] * app/gui/colormap-dialog.c * app/gui/gui.c * app/gui/preferences-dialog.c * app/tools/gimpmagnifytool.c * app/tools/gimpmovetool.c * app/widgets/gimppreview.c: changed according to variable and filename changes. * app/tools/tool_manager.c: tool_manager_select_tool(): send the active tool a "HALT" command before selecting the new one. Fixes stale tool dialogs which were there because some other hack was removed (This is IMHO the right place to shut down the active tool). * app/tools/gimpcroptool.c: don't shrink wrap after cropping but let gimprc.allow_resize_windows decide. * app/tools/gimpselectiontool.c: gimage_mask_value() takes image, not screen coordinates. A good example of how braindead it is to pass GdkEvents to tools :-) Fixes incorrect cursor and oper update of the selection tools. * app/tools/gimptransformtool.c * app/undo.c: removed (#if 0 for now) some strange code which did manual exposing of GimpDisplayShell areas. This was definitely a hack and should not be there given the image emits correct "update" signals.
2001-11-02 17:31:21 +08:00
#include "gimpdisplayshell-render.h"
1997-11-25 06:05:25 +08:00
#include "gimprc.h"
typedef struct _RenderInfo RenderInfo;
typedef void (* RenderFunc) (RenderInfo *info);
1997-11-25 06:05:25 +08:00
struct _RenderInfo
{
GimpDisplayShell *shell;
TileManager *src_tiles;
guint *alpha;
guchar *scale;
guchar *src;
guchar *dest;
gint x, y;
gint w, h;
gfloat scalex;
gfloat scaley;
gint src_x, src_y;
gint src_bpp;
gint dest_bpp;
gint dest_bpl;
gint dest_width;
gint byte_order;
1997-11-25 06:05:25 +08:00
};
/* accelerate transparency of image scaling */
guchar *render_check_buf = NULL;
guchar *render_empty_buf = NULL;
guchar *render_temp_buf = NULL;
guchar *render_blend_dark_check = NULL;
guchar *render_blend_light_check = NULL;
static guchar *tile_buf = NULL;
static guint check_mod = 0;
static guint check_shift = 0;
static guint tile_shift = 0;
1997-11-25 06:05:25 +08:00
static guchar check_combos[6][2] =
{
{ 204, 255 },
{ 102, 153 },
{ 0, 51 },
1997-11-25 06:05:25 +08:00
{ 255, 255 },
{ 127, 127 },
{ 0, 0 }
1997-11-25 06:05:25 +08:00
};
void
render_setup (GimpCheckType check_type,
GimpCheckSize check_size)
1997-11-25 06:05:25 +08:00
{
gint i, j;
app/core/Makefile.am new file that holds enums that are registered with 2001-12-08 Sven Neumann <sven@gimp.org> * app/core/Makefile.am * app/core/core-enums.h: new file that holds enums that are registered with the type system and is used to generate core-enums.c. * app/core/core-types.h: include core-enums.h * app/base/base-types.h: namespace cleanup. Prefix all enumeration types with Gimp and their values with GIMP. Moved GimpLayerModeEffects enum ... * app/base/base-enums.h: ... here. * app/image_map.c * app/base/temp-buf.c * app/core/gimpcontext.[ch] * app/core/gimpdrawable-transform.c * app/core/gimpdrawable.c * app/core/gimpedit.c * app/core/gimpimage-mask.c * app/core/gimpimage-merge.c * app/core/gimpimage-new.c * app/core/gimpimage-projection.c * app/core/gimpimage.[ch] * app/core/gimplayer.[ch] * app/display/gimpdisplayshell-dnd.c * app/display/gimpdisplayshell-render.c * app/gui/brush-select.c * app/gui/layers-commands.c * app/gui/preferences-dialog.c * app/gui/toolbox.c * app/paint-funcs/paint-funcs.[ch] * app/tools/gimpconvolvetool.c * app/tools/gimperasertool.c * app/tools/gimpiscissorstool.c * app/tools/gimppainttool.[ch] * app/tools/gimptexttool.c * app/tools/paint_options.c * app/widgets/gimplayerlistview.c * app/widgets/gimpwidgets-constructors.[ch] * app/xcf/xcf-load.c * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/layer.pdb * tools/pdbgen/pdb/tools.pdb: changed accordingly. * libgimpbase/gimpbasetypes.h: no need to chop GIMP prefix off the enums any longer. * app/pdb/brush_select_cmds.c * app/pdb/brushes_cmds.c * app/pdb/color_cmds.c * app/pdb/layer_cmds.c * app/pdb/message_cmds.c * app/pdb/procedural_db_cmds.c * app/pdb/tools_cmds.c * libgimp/gimpenums.h * plug-ins/script-fu/script-fu-constants.c * tools/pdbgen/enums.pl: regenerated. * app/gimprc.c: removed code to parse for "plug_in" keyword which was left over from some very early gimp days. * app/plug-in/plug-in.[ch]: removed now unused function plug_in_add().
2001-12-09 07:12:59 +08:00
if (check_type < GIMP_LIGHT_CHECKS || check_type > GIMP_BLACK_ONLY)
g_error ("invalid check_type argument to render_setup: %d", check_type);
app/core/Makefile.am new file that holds enums that are registered with 2001-12-08 Sven Neumann <sven@gimp.org> * app/core/Makefile.am * app/core/core-enums.h: new file that holds enums that are registered with the type system and is used to generate core-enums.c. * app/core/core-types.h: include core-enums.h * app/base/base-types.h: namespace cleanup. Prefix all enumeration types with Gimp and their values with GIMP. Moved GimpLayerModeEffects enum ... * app/base/base-enums.h: ... here. * app/image_map.c * app/base/temp-buf.c * app/core/gimpcontext.[ch] * app/core/gimpdrawable-transform.c * app/core/gimpdrawable.c * app/core/gimpedit.c * app/core/gimpimage-mask.c * app/core/gimpimage-merge.c * app/core/gimpimage-new.c * app/core/gimpimage-projection.c * app/core/gimpimage.[ch] * app/core/gimplayer.[ch] * app/display/gimpdisplayshell-dnd.c * app/display/gimpdisplayshell-render.c * app/gui/brush-select.c * app/gui/layers-commands.c * app/gui/preferences-dialog.c * app/gui/toolbox.c * app/paint-funcs/paint-funcs.[ch] * app/tools/gimpconvolvetool.c * app/tools/gimperasertool.c * app/tools/gimpiscissorstool.c * app/tools/gimppainttool.[ch] * app/tools/gimptexttool.c * app/tools/paint_options.c * app/widgets/gimplayerlistview.c * app/widgets/gimpwidgets-constructors.[ch] * app/xcf/xcf-load.c * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/layer.pdb * tools/pdbgen/pdb/tools.pdb: changed accordingly. * libgimpbase/gimpbasetypes.h: no need to chop GIMP prefix off the enums any longer. * app/pdb/brush_select_cmds.c * app/pdb/brushes_cmds.c * app/pdb/color_cmds.c * app/pdb/layer_cmds.c * app/pdb/message_cmds.c * app/pdb/procedural_db_cmds.c * app/pdb/tools_cmds.c * libgimp/gimpenums.h * plug-ins/script-fu/script-fu-constants.c * tools/pdbgen/enums.pl: regenerated. * app/gimprc.c: removed code to parse for "plug_in" keyword which was left over from some very early gimp days. * app/plug-in/plug-in.[ch]: removed now unused function plug_in_add().
2001-12-09 07:12:59 +08:00
if (check_size < GIMP_SMALL_CHECKS || check_size > GIMP_LARGE_CHECKS)
g_error ("invalid check_size argument to render_setup: %d", check_size);
1997-11-25 06:05:25 +08:00
/* based on the tile size, determine the tile shift amount
* (assume here that tile_height and tile_width are equal)
*/
2000-10-26 07:14:11 +08:00
tile_shift = 0;
while ((1 << tile_shift) < TILE_WIDTH)
tile_shift++;
1997-11-25 06:05:25 +08:00
/* allocate a buffer for arranging information from a row of tiles */
if (! tile_buf)
tile_buf = g_new (guchar, GIMP_DISPLAY_SHELL_RENDER_BUF_WIDTH * MAX_CHANNELS);
1997-11-25 06:05:25 +08:00
if (! render_blend_dark_check)
render_blend_dark_check = g_new (guchar, 65536);
if (! render_blend_light_check)
render_blend_light_check = g_new (guchar, 65536);
1997-11-25 06:05:25 +08:00
for (i = 0; i < 256; i++)
for (j = 0; j < 256; j++)
{
render_blend_dark_check [(i << 8) + j] = (guchar)
1997-11-25 06:05:25 +08:00
((j * i + check_combos[check_type][0] * (255 - i)) / 255);
render_blend_light_check [(i << 8) + j] = (guchar)
1997-11-25 06:05:25 +08:00
((j * i + check_combos[check_type][1] * (255 - i)) / 255);
}
switch (check_size)
{
app/core/Makefile.am new file that holds enums that are registered with 2001-12-08 Sven Neumann <sven@gimp.org> * app/core/Makefile.am * app/core/core-enums.h: new file that holds enums that are registered with the type system and is used to generate core-enums.c. * app/core/core-types.h: include core-enums.h * app/base/base-types.h: namespace cleanup. Prefix all enumeration types with Gimp and their values with GIMP. Moved GimpLayerModeEffects enum ... * app/base/base-enums.h: ... here. * app/image_map.c * app/base/temp-buf.c * app/core/gimpcontext.[ch] * app/core/gimpdrawable-transform.c * app/core/gimpdrawable.c * app/core/gimpedit.c * app/core/gimpimage-mask.c * app/core/gimpimage-merge.c * app/core/gimpimage-new.c * app/core/gimpimage-projection.c * app/core/gimpimage.[ch] * app/core/gimplayer.[ch] * app/display/gimpdisplayshell-dnd.c * app/display/gimpdisplayshell-render.c * app/gui/brush-select.c * app/gui/layers-commands.c * app/gui/preferences-dialog.c * app/gui/toolbox.c * app/paint-funcs/paint-funcs.[ch] * app/tools/gimpconvolvetool.c * app/tools/gimperasertool.c * app/tools/gimpiscissorstool.c * app/tools/gimppainttool.[ch] * app/tools/gimptexttool.c * app/tools/paint_options.c * app/widgets/gimplayerlistview.c * app/widgets/gimpwidgets-constructors.[ch] * app/xcf/xcf-load.c * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/layer.pdb * tools/pdbgen/pdb/tools.pdb: changed accordingly. * libgimpbase/gimpbasetypes.h: no need to chop GIMP prefix off the enums any longer. * app/pdb/brush_select_cmds.c * app/pdb/brushes_cmds.c * app/pdb/color_cmds.c * app/pdb/layer_cmds.c * app/pdb/message_cmds.c * app/pdb/procedural_db_cmds.c * app/pdb/tools_cmds.c * libgimp/gimpenums.h * plug-ins/script-fu/script-fu-constants.c * tools/pdbgen/enums.pl: regenerated. * app/gimprc.c: removed code to parse for "plug_in" keyword which was left over from some very early gimp days. * app/plug-in/plug-in.[ch]: removed now unused function plug_in_add().
2001-12-09 07:12:59 +08:00
case GIMP_SMALL_CHECKS:
check_mod = 0x3;
1997-11-25 06:05:25 +08:00
check_shift = 2;
break;
app/core/Makefile.am new file that holds enums that are registered with 2001-12-08 Sven Neumann <sven@gimp.org> * app/core/Makefile.am * app/core/core-enums.h: new file that holds enums that are registered with the type system and is used to generate core-enums.c. * app/core/core-types.h: include core-enums.h * app/base/base-types.h: namespace cleanup. Prefix all enumeration types with Gimp and their values with GIMP. Moved GimpLayerModeEffects enum ... * app/base/base-enums.h: ... here. * app/image_map.c * app/base/temp-buf.c * app/core/gimpcontext.[ch] * app/core/gimpdrawable-transform.c * app/core/gimpdrawable.c * app/core/gimpedit.c * app/core/gimpimage-mask.c * app/core/gimpimage-merge.c * app/core/gimpimage-new.c * app/core/gimpimage-projection.c * app/core/gimpimage.[ch] * app/core/gimplayer.[ch] * app/display/gimpdisplayshell-dnd.c * app/display/gimpdisplayshell-render.c * app/gui/brush-select.c * app/gui/layers-commands.c * app/gui/preferences-dialog.c * app/gui/toolbox.c * app/paint-funcs/paint-funcs.[ch] * app/tools/gimpconvolvetool.c * app/tools/gimperasertool.c * app/tools/gimpiscissorstool.c * app/tools/gimppainttool.[ch] * app/tools/gimptexttool.c * app/tools/paint_options.c * app/widgets/gimplayerlistview.c * app/widgets/gimpwidgets-constructors.[ch] * app/xcf/xcf-load.c * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/layer.pdb * tools/pdbgen/pdb/tools.pdb: changed accordingly. * libgimpbase/gimpbasetypes.h: no need to chop GIMP prefix off the enums any longer. * app/pdb/brush_select_cmds.c * app/pdb/brushes_cmds.c * app/pdb/color_cmds.c * app/pdb/layer_cmds.c * app/pdb/message_cmds.c * app/pdb/procedural_db_cmds.c * app/pdb/tools_cmds.c * libgimp/gimpenums.h * plug-ins/script-fu/script-fu-constants.c * tools/pdbgen/enums.pl: regenerated. * app/gimprc.c: removed code to parse for "plug_in" keyword which was left over from some very early gimp days. * app/plug-in/plug-in.[ch]: removed now unused function plug_in_add().
2001-12-09 07:12:59 +08:00
case GIMP_MEDIUM_CHECKS:
check_mod = 0x7;
1997-11-25 06:05:25 +08:00
check_shift = 3;
break;
app/core/Makefile.am new file that holds enums that are registered with 2001-12-08 Sven Neumann <sven@gimp.org> * app/core/Makefile.am * app/core/core-enums.h: new file that holds enums that are registered with the type system and is used to generate core-enums.c. * app/core/core-types.h: include core-enums.h * app/base/base-types.h: namespace cleanup. Prefix all enumeration types with Gimp and their values with GIMP. Moved GimpLayerModeEffects enum ... * app/base/base-enums.h: ... here. * app/image_map.c * app/base/temp-buf.c * app/core/gimpcontext.[ch] * app/core/gimpdrawable-transform.c * app/core/gimpdrawable.c * app/core/gimpedit.c * app/core/gimpimage-mask.c * app/core/gimpimage-merge.c * app/core/gimpimage-new.c * app/core/gimpimage-projection.c * app/core/gimpimage.[ch] * app/core/gimplayer.[ch] * app/display/gimpdisplayshell-dnd.c * app/display/gimpdisplayshell-render.c * app/gui/brush-select.c * app/gui/layers-commands.c * app/gui/preferences-dialog.c * app/gui/toolbox.c * app/paint-funcs/paint-funcs.[ch] * app/tools/gimpconvolvetool.c * app/tools/gimperasertool.c * app/tools/gimpiscissorstool.c * app/tools/gimppainttool.[ch] * app/tools/gimptexttool.c * app/tools/paint_options.c * app/widgets/gimplayerlistview.c * app/widgets/gimpwidgets-constructors.[ch] * app/xcf/xcf-load.c * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/layer.pdb * tools/pdbgen/pdb/tools.pdb: changed accordingly. * libgimpbase/gimpbasetypes.h: no need to chop GIMP prefix off the enums any longer. * app/pdb/brush_select_cmds.c * app/pdb/brushes_cmds.c * app/pdb/color_cmds.c * app/pdb/layer_cmds.c * app/pdb/message_cmds.c * app/pdb/procedural_db_cmds.c * app/pdb/tools_cmds.c * libgimp/gimpenums.h * plug-ins/script-fu/script-fu-constants.c * tools/pdbgen/enums.pl: regenerated. * app/gimprc.c: removed code to parse for "plug_in" keyword which was left over from some very early gimp days. * app/plug-in/plug-in.[ch]: removed now unused function plug_in_add().
2001-12-09 07:12:59 +08:00
case GIMP_LARGE_CHECKS:
check_mod = 0xf;
1997-11-25 06:05:25 +08:00
check_shift = 4;
break;
}
g_free (render_check_buf);
g_free (render_empty_buf);
g_free (render_temp_buf);
#ifdef __GNUC__
#warning #define MAX_PREVIEW_SIZE 1024 /* GIMP_PREVIEW_MAX_SIZE (EEK) */
#endif
#define MAX_PREVIEW_SIZE 1024 /* GIMP_PREVIEW_MAX_SIZE (EEK) */
1997-11-25 06:05:25 +08:00
/* calculate check buffer for previews */
if (TRUE /* preview_size */)
1997-11-25 06:05:25 +08:00
{
render_check_buf = g_new (guchar, (MAX_PREVIEW_SIZE + 4) * 3);
for (i = 0; i < (MAX_PREVIEW_SIZE + 4); i++)
1997-11-25 06:05:25 +08:00
{
if (i & 0x4)
{
render_check_buf[i * 3 + 0] = render_blend_dark_check[0];
render_check_buf[i * 3 + 1] = render_blend_dark_check[0];
render_check_buf[i * 3 + 2] = render_blend_dark_check[0];
1997-11-25 06:05:25 +08:00
}
else
{
render_check_buf[i * 3 + 0] = render_blend_light_check[0];
render_check_buf[i * 3 + 1] = render_blend_light_check[0];
render_check_buf[i * 3 + 2] = render_blend_light_check[0];
1997-11-25 06:05:25 +08:00
}
}
render_empty_buf = g_new0 (guchar, (MAX_PREVIEW_SIZE + 4) * 3);
render_temp_buf = g_new (guchar, (MAX_PREVIEW_SIZE + 4) * 3);
1997-11-25 06:05:25 +08:00
}
else
{
render_check_buf = NULL;
render_empty_buf = NULL;
render_temp_buf = NULL;
1997-11-25 06:05:25 +08:00
}
}
void
render_free (void)
{
g_free (tile_buf);
g_free (render_check_buf);
1997-11-25 06:05:25 +08:00
}
1997-11-25 06:05:25 +08:00
/* Render Image functions */
static void render_image_rgb (RenderInfo *info);
static void render_image_rgb_a (RenderInfo *info);
static void render_image_gray (RenderInfo *info);
static void render_image_gray_a (RenderInfo *info);
static void render_image_indexed (RenderInfo *info);
static void render_image_indexed_a (RenderInfo *info);
static void render_image_init_info (RenderInfo *info,
GimpDisplayShell *shell,
gint x,
gint y,
gint w,
gint h);
static guint * render_image_init_alpha (gint mult);
static guchar * render_image_accelerate_scaling (gint width,
gint start,
gfloat scalex);
static guchar * render_image_tile_fault (RenderInfo *info);
1997-11-25 06:05:25 +08:00
static RenderFunc render_funcs[6] =
1997-11-25 06:05:25 +08:00
{
render_image_rgb,
render_image_rgb_a,
render_image_gray,
render_image_gray_a,
render_image_indexed,
render_image_indexed_a,
1997-11-25 06:05:25 +08:00
};
/*****************************************************************/
/* This function is the core of the display--it offsets and */
/* scales the image according to the current parameters in the */
/* gdisp object. It handles color, grayscale, 8, 15, 16, 24, */
/* & 32 bit output depths. */
/*****************************************************************/
void
gimp_display_shell_render (GimpDisplayShell *shell,
gint x,
gint y,
gint w,
gint h)
1997-11-25 06:05:25 +08:00
{
RenderInfo info;
gint image_type;
GList *list;
render_image_init_info (&info, shell, x, y, w, h);
1997-11-25 06:05:25 +08:00
image_type = gimp_image_projection_type (shell->gdisp->gimage);
1997-11-25 06:05:25 +08:00
if ((image_type < 0) || (image_type > 5))
{
g_message ("unknown gimage projection type: %d",
gimp_image_projection_type (shell->gdisp->gimage));
1997-11-25 06:05:25 +08:00
return;
}
if ((info.dest_bpp < 1) || (info.dest_bpp > 4))
{
g_message ("unsupported destination bytes per pixel: %d", info.dest_bpp);
1997-11-25 06:05:25 +08:00
return;
}
/* Currently, only RGBA and GRAYA projection types are used - the rest
* are in case of future need. -- austin, 28th Nov 1998.
*/
if (image_type != GIMP_RGBA_IMAGE && image_type != GIMP_GRAYA_IMAGE)
g_warning ("using untested projection type %d", image_type);
(* render_funcs[image_type]) (&info);
/* apply filters to the rendered projection */
for (list = shell->filters; list; list = g_list_next (list))
{
ColorDisplayNode *node;
node = (ColorDisplayNode *) list->data;
node->cd_convert (node->cd_ID,
shell->render_buf,
w, h,
3,
3 * GIMP_DISPLAY_SHELL_RENDER_BUF_WIDTH);
}
/* put it to the screen */
gdk_draw_rgb_image_dithalign (shell->canvas->window,
shell->render_gc,
x + shell->disp_xoffset,
y + shell->disp_yoffset,
w, h,
GDK_RGB_DITHER_MAX,
shell->render_buf,
3 * GIMP_DISPLAY_SHELL_RENDER_BUF_WIDTH,
shell->offset_x,
shell->offset_y);
1997-11-25 06:05:25 +08:00
}
/*************************/
/* 8 Bit functions */
/*************************/
static void
render_image_indexed (RenderInfo *info)
1997-11-25 06:05:25 +08:00
{
guchar *src;
guchar *dest;
guchar *cmap;
gulong val;
gint byte_order;
gint y, ye;
gint x, xe;
gint initial;
gfloat error;
gfloat step;
1997-11-25 06:05:25 +08:00
cmap = gimp_image_get_colormap (info->shell->gdisp->gimage);
1997-11-25 06:05:25 +08:00
y = info->y;
1997-11-25 06:05:25 +08:00
ye = info->y + info->h;
xe = info->x + info->w;
step = 1.0 / info->scaley;
error = y * step;
error -= ((gint) error) - step;
1997-11-25 06:05:25 +08:00
initial = TRUE;
byte_order = info->byte_order;
info->src = render_image_tile_fault (info);
for (; y < ye; y++)
{
if (!initial && (error < 1.0))
{
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
}
1997-11-25 06:05:25 +08:00
else
{
src = info->src;
dest = info->dest;
g_return_if_fail (src != NULL);
for (x = info->x; x < xe; x++)
{
val = src[INDEXED_PIX] * 3;
src += 1;
dest[0] = cmap[val+0];
dest[1] = cmap[val+1];
dest[2] = cmap[val+2];
dest += 3;
}
1997-11-25 06:05:25 +08:00
}
info->dest += info->dest_bpl;
initial = FALSE;
if (error >= 1.0)
1997-11-25 06:05:25 +08:00
{
info->src_y += (int)error;
error -= (int)error;
1997-11-25 06:05:25 +08:00
info->src = render_image_tile_fault (info);
initial = TRUE;
1997-11-25 06:05:25 +08:00
}
error += step;
1997-11-25 06:05:25 +08:00
}
}
static void
render_image_indexed_a (RenderInfo *info)
1997-11-25 06:05:25 +08:00
{
guchar *src;
guchar *dest;
guint *alpha;
guchar *cmap;
gulong r, g, b;
gulong val;
guint a;
gint dark_light;
gint byte_order;
gint y, ye;
gint x, xe;
gint initial;
gfloat error;
gfloat step;
1997-11-25 06:05:25 +08:00
cmap = gimp_image_get_colormap (info->shell->gdisp->gimage);
alpha = info->alpha;
1997-11-25 06:05:25 +08:00
y = info->y;
1997-11-25 06:05:25 +08:00
ye = info->y + info->h;
xe = info->x + info->w;
step = 1.0 / info->scaley;
error = y * step;
error -= ((gint) error) - step;
1997-11-25 06:05:25 +08:00
initial = TRUE;
byte_order = info->byte_order;
info->src = render_image_tile_fault (info);
for (; y < ye; y++)
{
if (!initial && (error < 1.0) && (y & check_mod))
{
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
}
1997-11-25 06:05:25 +08:00
else
{
src = info->src;
dest = info->dest;
dark_light = (y >> check_shift) + (info->x >> check_shift);
g_return_if_fail (src != NULL);
1997-11-25 06:05:25 +08:00
for (x = info->x; x < xe; x++)
{
a = alpha[src[ALPHA_I_PIX]];
val = src[INDEXED_PIX] * 3;
src += 2;
if (dark_light & 0x1)
{
r = render_blend_dark_check[(a | cmap[val + 0])];
g = render_blend_dark_check[(a | cmap[val + 1])];
b = render_blend_dark_check[(a | cmap[val + 2])];
}
else
{
r = render_blend_light_check[(a | cmap[val + 0])];
g = render_blend_light_check[(a | cmap[val + 1])];
b = render_blend_light_check[(a | cmap[val + 2])];
}
dest[0] = r;
dest[1] = g;
dest[2] = b;
1997-11-25 06:05:25 +08:00
dest += 3;
if (((x + 1) & check_mod) == 0)
dark_light += 1;
1997-11-25 06:05:25 +08:00
}
}
info->dest += info->dest_bpl;
initial = FALSE;
if (error >= 1.0)
1997-11-25 06:05:25 +08:00
{
info->src_y += (int)error;
error -= (int)error;
1997-11-25 06:05:25 +08:00
info->src = render_image_tile_fault (info);
initial = TRUE;
1997-11-25 06:05:25 +08:00
}
error += step;
1997-11-25 06:05:25 +08:00
}
}
static void
render_image_gray (RenderInfo *info)
1997-11-25 06:05:25 +08:00
{
guchar *src;
guchar *dest;
gulong val;
gint byte_order;
gint y, ye;
gint x, xe;
gint initial;
gfloat error;
gfloat step;
y = info->y;
1997-11-25 06:05:25 +08:00
ye = info->y + info->h;
xe = info->x + info->w;
step = 1.0 / info->scaley;
error = y * step;
error -= ((gint) error) - step;
1997-11-25 06:05:25 +08:00
initial = TRUE;
byte_order = info->byte_order;
info->src = render_image_tile_fault (info);
for (; y < ye; y++)
{
if (!initial && (error < 1.0))
{
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
}
1997-11-25 06:05:25 +08:00
else
{
src = info->src;
dest = info->dest;
g_return_if_fail (src != NULL);
for (x = info->x; x < xe; x++)
{
val = src[GRAY_PIX];
src += 1;
1997-11-25 06:05:25 +08:00
dest[0] = val;
dest[1] = val;
dest[2] = val;
dest += 3;
}
1997-11-25 06:05:25 +08:00
}
info->dest += info->dest_bpl;
initial = FALSE;
if (error >= 1.0)
1997-11-25 06:05:25 +08:00
{
info->src_y += (int)error;
error -= (int)error;
1997-11-25 06:05:25 +08:00
info->src = render_image_tile_fault (info);
initial = TRUE;
1997-11-25 06:05:25 +08:00
}
error += step;
1997-11-25 06:05:25 +08:00
}
}
static void
render_image_gray_a (RenderInfo *info)
1997-11-25 06:05:25 +08:00
{
guchar *src;
guchar *dest;
guint *alpha;
gulong val;
guint a;
gint dark_light;
gint byte_order;
gint y, ye;
gint x, xe;
gint initial;
gfloat error;
gfloat step;
1997-11-25 06:05:25 +08:00
alpha = info->alpha;
y = info->y;
1997-11-25 06:05:25 +08:00
ye = info->y + info->h;
xe = info->x + info->w;
step = 1.0 / info->scaley;
error = y * step;
error -= ((gint) error) - step;
1997-11-25 06:05:25 +08:00
initial = TRUE;
byte_order = info->byte_order;
info->src = render_image_tile_fault (info);
for (; y < ye; y++)
{
if (!initial && (error < 1.0) && (y & check_mod))
{
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
}
1997-11-25 06:05:25 +08:00
else
{
src = info->src;
dest = info->dest;
dark_light = (y >> check_shift) + (info->x >> check_shift);
g_return_if_fail (src != NULL);
for (x = info->x; x < xe; x++)
{
a = alpha[src[ALPHA_G_PIX]];
if (dark_light & 0x1)
val = render_blend_dark_check[(a | src[GRAY_PIX])];
else
val = render_blend_light_check[(a | src[GRAY_PIX])];
src += 2;
dest[0] = val;
dest[1] = val;
dest[2] = val;
dest += 3;
if (((x + 1) & check_mod) == 0)
dark_light += 1;
}
1997-11-25 06:05:25 +08:00
}
info->dest += info->dest_bpl;
initial = FALSE;
if (error >= 1.0)
1997-11-25 06:05:25 +08:00
{
info->src_y += (int)error;
error -= (int)error;
1997-11-25 06:05:25 +08:00
info->src = render_image_tile_fault (info);
initial = TRUE;
1997-11-25 06:05:25 +08:00
}
error += step;
1997-11-25 06:05:25 +08:00
}
}
static void
render_image_rgb (RenderInfo *info)
1997-11-25 06:05:25 +08:00
{
guchar *src;
guchar *dest;
gint byte_order;
gint y, ye;
gint x, xe;
gint initial;
gfloat error;
gfloat step;
y = info->y;
2000-10-26 07:14:11 +08:00
ye = info->y + info->h;
xe = info->x + info->w;
step = 1.0 / info->scaley;
error = y * step;
error -= (gint) error - step;
1997-11-25 06:05:25 +08:00
initial = TRUE;
2000-10-26 07:14:11 +08:00
byte_order = info->byte_order;
1997-11-25 06:05:25 +08:00
info->src = render_image_tile_fault (info);
for (; y < ye; y++)
{
if (!initial && (error < 1.0))
{
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
}
1997-11-25 06:05:25 +08:00
else
{
src = info->src;
dest = info->dest;
g_return_if_fail (src != NULL);
/* replace this with memcpy, or better yet, avoid it altogether? */
for (x = info->x; x < xe; x++)
{
dest[0] = src[0];
dest[1] = src[1];
dest[2] = src[2];
src += 3;
dest += 3;
}
1997-11-25 06:05:25 +08:00
}
info->dest += info->dest_bpl;
initial = FALSE;
if (error >= 1.0)
1997-11-25 06:05:25 +08:00
{
info->src_y += (int)error;
error -= (int)error;
1997-11-25 06:05:25 +08:00
info->src = render_image_tile_fault (info);
initial = TRUE;
1997-11-25 06:05:25 +08:00
}
error += step;
1997-11-25 06:05:25 +08:00
}
}
static void
render_image_rgb_a (RenderInfo *info)
1997-11-25 06:05:25 +08:00
{
guchar *src;
guchar *dest;
guint *alpha;
gulong r, g, b;
guint a;
gint dark_light;
gint byte_order;
gint y, ye;
gint x, xe;
gint initial;
gfloat error;
gfloat step;
1997-11-25 06:05:25 +08:00
alpha = info->alpha;
y = info->y;
2000-10-26 07:14:11 +08:00
ye = info->y + info->h;
xe = info->x + info->w;
step = 1.0 / info->scaley;
error = y * step;
error -= ((gint) error) - step;
1997-11-25 06:05:25 +08:00
initial = TRUE;
byte_order = info->byte_order;
info->src = render_image_tile_fault (info);
for (; y < ye; y++)
{
if (!initial && (error < 1.0) && (y & check_mod))
{
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
}
1997-11-25 06:05:25 +08:00
else
{
src = info->src;
dest = info->dest;
dark_light = (y >> check_shift) + (info->x >> check_shift);
g_return_if_fail (src != NULL);
add sample_colorize and curve_bend defs * plug-ins/common/plugin-defs.pl: add sample_colorize and curve_bend defs * libgimp/color_selector.h: minor consistency cleanup * libgimp/gimpchainbutton.[ch]: use new style gtk object helper macros * libgimp/gimpfileselection.c * libgimp/gimpmatrix.h: minor cleanup * libgimp/gimpintl.h: resync with gnome-i18n.h * libgimp/color_display.h * app/gimp.sym * app/gdisplay_color.[ch] * app/app_procs.c * app/gdisplay.h * app/image_render.c: color display transformation code. Still unfinished, so it's not activated yet. * app/buildmenu.h: remove unused defines (PULLDOWN, POPUP, OPTION) * app/colormaps.[ch] * app/image_render.c: remove vestigal dithering stuff * app/convolve.h * app/gimpdrawable.h * app/gimpimage.h * app/lut_funcs.h * app/paint_funcs.h * app/plug_in.h: enum nick changes from Marc * app/channel_ops.c * app/crop.c * app/gdisplay.c * app/gimpimage.[ch] * app/move.c: s/([A-Z]+)_GUIDE/ORIENTATION_$1/ * app/flip_tool.[ch] * app/shear_tool.[ch]: use ORIENTATION_* constants instead of our own * app/disp_callbacks.c: remove HORIZONTAL and VERTICAL #defines * app/general.h: enumified TOKEN_* symbols * app/lc_dialog.c * app/paint_funcs.c: remove unused variables * tools/pdbgen/lib.pl: autogen gimpenums.h (unfinished) * tools/pdbgen/stddefs.pdb: new std_orientation_enum, remove layer_mode shortcut since we've skipped it in app/ * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/gimage.pdb * tools/pdbgen/pdb/guides.pdb * tools/pdbgen/pdb/layer.pdb * tools/pdbgen/pdb/tools.pdb: reflect above enum changes, whitespace cleanups * tools/pdbgen/enums.pl * app/brush_select_cmds.c * app/brushes_cmds.c * app/color_cmds.c * app/drawable_cmds.c * app/gimage_cmds.c * app/layer_cmds.c * app/procedural_db_cmds.c * app/tools_cmds.c: reflect pdb and enum nick changes above -Yosh
1999-07-29 07:00:08 +08:00
for (x = info->x; x < xe; x++)
{
a = alpha[src[ALPHA_PIX]];
if (dark_light & 0x1)
{
r = render_blend_dark_check[(a | src[RED_PIX])];
g = render_blend_dark_check[(a | src[GREEN_PIX])];
b = render_blend_dark_check[(a | src[BLUE_PIX])];
add sample_colorize and curve_bend defs * plug-ins/common/plugin-defs.pl: add sample_colorize and curve_bend defs * libgimp/color_selector.h: minor consistency cleanup * libgimp/gimpchainbutton.[ch]: use new style gtk object helper macros * libgimp/gimpfileselection.c * libgimp/gimpmatrix.h: minor cleanup * libgimp/gimpintl.h: resync with gnome-i18n.h * libgimp/color_display.h * app/gimp.sym * app/gdisplay_color.[ch] * app/app_procs.c * app/gdisplay.h * app/image_render.c: color display transformation code. Still unfinished, so it's not activated yet. * app/buildmenu.h: remove unused defines (PULLDOWN, POPUP, OPTION) * app/colormaps.[ch] * app/image_render.c: remove vestigal dithering stuff * app/convolve.h * app/gimpdrawable.h * app/gimpimage.h * app/lut_funcs.h * app/paint_funcs.h * app/plug_in.h: enum nick changes from Marc * app/channel_ops.c * app/crop.c * app/gdisplay.c * app/gimpimage.[ch] * app/move.c: s/([A-Z]+)_GUIDE/ORIENTATION_$1/ * app/flip_tool.[ch] * app/shear_tool.[ch]: use ORIENTATION_* constants instead of our own * app/disp_callbacks.c: remove HORIZONTAL and VERTICAL #defines * app/general.h: enumified TOKEN_* symbols * app/lc_dialog.c * app/paint_funcs.c: remove unused variables * tools/pdbgen/lib.pl: autogen gimpenums.h (unfinished) * tools/pdbgen/stddefs.pdb: new std_orientation_enum, remove layer_mode shortcut since we've skipped it in app/ * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/gimage.pdb * tools/pdbgen/pdb/guides.pdb * tools/pdbgen/pdb/layer.pdb * tools/pdbgen/pdb/tools.pdb: reflect above enum changes, whitespace cleanups * tools/pdbgen/enums.pl * app/brush_select_cmds.c * app/brushes_cmds.c * app/color_cmds.c * app/drawable_cmds.c * app/gimage_cmds.c * app/layer_cmds.c * app/procedural_db_cmds.c * app/tools_cmds.c: reflect pdb and enum nick changes above -Yosh
1999-07-29 07:00:08 +08:00
}
else
{
r = render_blend_light_check[(a | src[RED_PIX])];
g = render_blend_light_check[(a | src[GREEN_PIX])];
b = render_blend_light_check[(a | src[BLUE_PIX])];
add sample_colorize and curve_bend defs * plug-ins/common/plugin-defs.pl: add sample_colorize and curve_bend defs * libgimp/color_selector.h: minor consistency cleanup * libgimp/gimpchainbutton.[ch]: use new style gtk object helper macros * libgimp/gimpfileselection.c * libgimp/gimpmatrix.h: minor cleanup * libgimp/gimpintl.h: resync with gnome-i18n.h * libgimp/color_display.h * app/gimp.sym * app/gdisplay_color.[ch] * app/app_procs.c * app/gdisplay.h * app/image_render.c: color display transformation code. Still unfinished, so it's not activated yet. * app/buildmenu.h: remove unused defines (PULLDOWN, POPUP, OPTION) * app/colormaps.[ch] * app/image_render.c: remove vestigal dithering stuff * app/convolve.h * app/gimpdrawable.h * app/gimpimage.h * app/lut_funcs.h * app/paint_funcs.h * app/plug_in.h: enum nick changes from Marc * app/channel_ops.c * app/crop.c * app/gdisplay.c * app/gimpimage.[ch] * app/move.c: s/([A-Z]+)_GUIDE/ORIENTATION_$1/ * app/flip_tool.[ch] * app/shear_tool.[ch]: use ORIENTATION_* constants instead of our own * app/disp_callbacks.c: remove HORIZONTAL and VERTICAL #defines * app/general.h: enumified TOKEN_* symbols * app/lc_dialog.c * app/paint_funcs.c: remove unused variables * tools/pdbgen/lib.pl: autogen gimpenums.h (unfinished) * tools/pdbgen/stddefs.pdb: new std_orientation_enum, remove layer_mode shortcut since we've skipped it in app/ * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/gimage.pdb * tools/pdbgen/pdb/guides.pdb * tools/pdbgen/pdb/layer.pdb * tools/pdbgen/pdb/tools.pdb: reflect above enum changes, whitespace cleanups * tools/pdbgen/enums.pl * app/brush_select_cmds.c * app/brushes_cmds.c * app/color_cmds.c * app/drawable_cmds.c * app/gimage_cmds.c * app/layer_cmds.c * app/procedural_db_cmds.c * app/tools_cmds.c: reflect pdb and enum nick changes above -Yosh
1999-07-29 07:00:08 +08:00
}
1997-11-25 06:05:25 +08:00
add sample_colorize and curve_bend defs * plug-ins/common/plugin-defs.pl: add sample_colorize and curve_bend defs * libgimp/color_selector.h: minor consistency cleanup * libgimp/gimpchainbutton.[ch]: use new style gtk object helper macros * libgimp/gimpfileselection.c * libgimp/gimpmatrix.h: minor cleanup * libgimp/gimpintl.h: resync with gnome-i18n.h * libgimp/color_display.h * app/gimp.sym * app/gdisplay_color.[ch] * app/app_procs.c * app/gdisplay.h * app/image_render.c: color display transformation code. Still unfinished, so it's not activated yet. * app/buildmenu.h: remove unused defines (PULLDOWN, POPUP, OPTION) * app/colormaps.[ch] * app/image_render.c: remove vestigal dithering stuff * app/convolve.h * app/gimpdrawable.h * app/gimpimage.h * app/lut_funcs.h * app/paint_funcs.h * app/plug_in.h: enum nick changes from Marc * app/channel_ops.c * app/crop.c * app/gdisplay.c * app/gimpimage.[ch] * app/move.c: s/([A-Z]+)_GUIDE/ORIENTATION_$1/ * app/flip_tool.[ch] * app/shear_tool.[ch]: use ORIENTATION_* constants instead of our own * app/disp_callbacks.c: remove HORIZONTAL and VERTICAL #defines * app/general.h: enumified TOKEN_* symbols * app/lc_dialog.c * app/paint_funcs.c: remove unused variables * tools/pdbgen/lib.pl: autogen gimpenums.h (unfinished) * tools/pdbgen/stddefs.pdb: new std_orientation_enum, remove layer_mode shortcut since we've skipped it in app/ * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/gimage.pdb * tools/pdbgen/pdb/guides.pdb * tools/pdbgen/pdb/layer.pdb * tools/pdbgen/pdb/tools.pdb: reflect above enum changes, whitespace cleanups * tools/pdbgen/enums.pl * app/brush_select_cmds.c * app/brushes_cmds.c * app/color_cmds.c * app/drawable_cmds.c * app/gimage_cmds.c * app/layer_cmds.c * app/procedural_db_cmds.c * app/tools_cmds.c: reflect pdb and enum nick changes above -Yosh
1999-07-29 07:00:08 +08:00
src += 4;
1997-11-25 06:05:25 +08:00
add sample_colorize and curve_bend defs * plug-ins/common/plugin-defs.pl: add sample_colorize and curve_bend defs * libgimp/color_selector.h: minor consistency cleanup * libgimp/gimpchainbutton.[ch]: use new style gtk object helper macros * libgimp/gimpfileselection.c * libgimp/gimpmatrix.h: minor cleanup * libgimp/gimpintl.h: resync with gnome-i18n.h * libgimp/color_display.h * app/gimp.sym * app/gdisplay_color.[ch] * app/app_procs.c * app/gdisplay.h * app/image_render.c: color display transformation code. Still unfinished, so it's not activated yet. * app/buildmenu.h: remove unused defines (PULLDOWN, POPUP, OPTION) * app/colormaps.[ch] * app/image_render.c: remove vestigal dithering stuff * app/convolve.h * app/gimpdrawable.h * app/gimpimage.h * app/lut_funcs.h * app/paint_funcs.h * app/plug_in.h: enum nick changes from Marc * app/channel_ops.c * app/crop.c * app/gdisplay.c * app/gimpimage.[ch] * app/move.c: s/([A-Z]+)_GUIDE/ORIENTATION_$1/ * app/flip_tool.[ch] * app/shear_tool.[ch]: use ORIENTATION_* constants instead of our own * app/disp_callbacks.c: remove HORIZONTAL and VERTICAL #defines * app/general.h: enumified TOKEN_* symbols * app/lc_dialog.c * app/paint_funcs.c: remove unused variables * tools/pdbgen/lib.pl: autogen gimpenums.h (unfinished) * tools/pdbgen/stddefs.pdb: new std_orientation_enum, remove layer_mode shortcut since we've skipped it in app/ * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/gimage.pdb * tools/pdbgen/pdb/guides.pdb * tools/pdbgen/pdb/layer.pdb * tools/pdbgen/pdb/tools.pdb: reflect above enum changes, whitespace cleanups * tools/pdbgen/enums.pl * app/brush_select_cmds.c * app/brushes_cmds.c * app/color_cmds.c * app/drawable_cmds.c * app/gimage_cmds.c * app/layer_cmds.c * app/procedural_db_cmds.c * app/tools_cmds.c: reflect pdb and enum nick changes above -Yosh
1999-07-29 07:00:08 +08:00
dest[0] = r;
dest[1] = g;
dest[2] = b;
dest += 3;
1997-11-25 06:05:25 +08:00
add sample_colorize and curve_bend defs * plug-ins/common/plugin-defs.pl: add sample_colorize and curve_bend defs * libgimp/color_selector.h: minor consistency cleanup * libgimp/gimpchainbutton.[ch]: use new style gtk object helper macros * libgimp/gimpfileselection.c * libgimp/gimpmatrix.h: minor cleanup * libgimp/gimpintl.h: resync with gnome-i18n.h * libgimp/color_display.h * app/gimp.sym * app/gdisplay_color.[ch] * app/app_procs.c * app/gdisplay.h * app/image_render.c: color display transformation code. Still unfinished, so it's not activated yet. * app/buildmenu.h: remove unused defines (PULLDOWN, POPUP, OPTION) * app/colormaps.[ch] * app/image_render.c: remove vestigal dithering stuff * app/convolve.h * app/gimpdrawable.h * app/gimpimage.h * app/lut_funcs.h * app/paint_funcs.h * app/plug_in.h: enum nick changes from Marc * app/channel_ops.c * app/crop.c * app/gdisplay.c * app/gimpimage.[ch] * app/move.c: s/([A-Z]+)_GUIDE/ORIENTATION_$1/ * app/flip_tool.[ch] * app/shear_tool.[ch]: use ORIENTATION_* constants instead of our own * app/disp_callbacks.c: remove HORIZONTAL and VERTICAL #defines * app/general.h: enumified TOKEN_* symbols * app/lc_dialog.c * app/paint_funcs.c: remove unused variables * tools/pdbgen/lib.pl: autogen gimpenums.h (unfinished) * tools/pdbgen/stddefs.pdb: new std_orientation_enum, remove layer_mode shortcut since we've skipped it in app/ * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/gimage.pdb * tools/pdbgen/pdb/guides.pdb * tools/pdbgen/pdb/layer.pdb * tools/pdbgen/pdb/tools.pdb: reflect above enum changes, whitespace cleanups * tools/pdbgen/enums.pl * app/brush_select_cmds.c * app/brushes_cmds.c * app/color_cmds.c * app/drawable_cmds.c * app/gimage_cmds.c * app/layer_cmds.c * app/procedural_db_cmds.c * app/tools_cmds.c: reflect pdb and enum nick changes above -Yosh
1999-07-29 07:00:08 +08:00
if (((x + 1) & check_mod) == 0)
dark_light += 1;
}
1997-11-25 06:05:25 +08:00
}
info->dest += info->dest_bpl;
initial = FALSE;
if (error >= 1.0)
1997-11-25 06:05:25 +08:00
{
info->src_y += (int)error;
error -= (int)error;
1997-11-25 06:05:25 +08:00
info->src = render_image_tile_fault (info);
initial = TRUE;
1997-11-25 06:05:25 +08:00
}
error += step;
1997-11-25 06:05:25 +08:00
}
}
static void
render_image_init_info (RenderInfo *info,
GimpDisplayShell *shell,
gint x,
gint y,
gint w,
gint h)
1997-11-25 06:05:25 +08:00
{
info->shell = shell;
info->src_tiles = gimp_image_projection (shell->gdisp->gimage);
info->x = x + shell->offset_x;
info->y = y + shell->offset_y;
info->w = w;
info->h = h;
removed gdisp->scale, gdisp->dot_for_dot, the scaling marcos and the 2002-06-27 Michael Natterer <mitch@gimp.org> * app/display/gimpdisplay.[ch]: removed gdisp->scale, gdisp->dot_for_dot, the scaling marcos and the gdisplay_[un]transform[_f]() functions. * app/display/gimpdisplayshell.[ch]: added them here. Named the transform functions gimp_display_shell_[un]transform_xy[_f](). Made the gimp_display_shell_[un]transform_coords() functions copy all values of the GimpCoords struct, not just x and y. * app/display/gimpstatusbar.[ch]: keep a pointer to GimpDisplayShell, not GimpDisplay. * app/display/gimpdisplayshell-callbacks.c * app/display/gimpdisplayshell-render.c * app/display/gimpdisplayshell-scale.c * app/display/gimpdisplayshell-scroll.c * app/display/gimpdisplayshell-selection.c * app/display/gimpnavigationview.c * app/gui/image-commands.c * app/gui/info-window.c * app/gui/select-commands.c * app/gui/view-commands.c * app/tools/gimpbezierselecttool.c * app/tools/gimpcroptool.c * app/tools/gimpdrawtool.c * app/tools/gimpeditselectiontool.c * app/tools/gimpmagnifytool.c * app/tools/gimpmeasuretool.c * app/tools/gimpmovetool.c * app/tools/gimppainttool.c * app/tools/gimppathtool.c * app/tools/gimprotatetool.c * app/tools/gimpscaletool.c * app/tools/gimpvectortool.c: changed accordingly. * app/gui/layers-commands.c: if(gimage->selection_mask) is always TRUE, use if(!gimp_image_mask_is_empty(gimage)) instead. * app/tools/gimpfuzzyselecttool.[ch]: moved global variables to the object struct.
2002-06-27 06:16:59 +08:00
info->scalex = SCALEFACTOR_X (shell);
info->scaley = SCALEFACTOR_Y (shell);
info->src_x = UNSCALEX (shell, info->x);
info->src_y = UNSCALEY (shell, info->y);
info->src_bpp = gimp_image_projection_bytes (shell->gdisp->gimage);
info->dest = shell->render_buf;
info->dest_bpp = 3;
info->dest_bpl = info->dest_bpp * GIMP_DISPLAY_SHELL_RENDER_BUF_WIDTH;
1997-11-25 06:05:25 +08:00
info->dest_width = info->w * info->dest_bpp;
info->byte_order = GDK_MSB_FIRST;
info->scale = render_image_accelerate_scaling (w, info->x, info->scalex);
info->alpha = NULL;
1997-11-25 06:05:25 +08:00
if (GIMP_IMAGE_TYPE_HAS_ALPHA (gimp_image_projection_type (shell->gdisp->gimage)))
1997-11-25 06:05:25 +08:00
{
info->alpha =
render_image_init_alpha (gimp_image_projection_opacity (shell->gdisp->gimage) * 255.999);
1997-11-25 06:05:25 +08:00
}
}
static guint*
render_image_init_alpha (gint mult)
1997-11-25 06:05:25 +08:00
{
static guint *alpha_mult = NULL;
static gint alpha_val = -1;
gint i;
1997-11-25 06:05:25 +08:00
if (alpha_val != mult)
{
if (!alpha_mult)
alpha_mult = g_new (guint, 256);
1997-11-25 06:05:25 +08:00
alpha_val = mult;
for (i = 0; i < 256; i++)
alpha_mult[i] = ((mult * i) / 255) << 8;
}
return alpha_mult;
}
static guchar *
render_image_accelerate_scaling (gint width,
gint start,
gfloat scalex)
1997-11-25 06:05:25 +08:00
{
static guchar *scale = NULL;
gfloat error;
gfloat step;
gint i;
1997-11-25 06:05:25 +08:00
if (! scale)
scale = g_new (guchar, GIMP_DISPLAY_SHELL_RENDER_BUF_WIDTH + 1);
1997-11-25 06:05:25 +08:00
step = 1.0 / scalex;
1997-11-25 06:05:25 +08:00
error = start * step;
error -= ((gint) error) - step;
for (i = 0; i <= width; i++)
{
scale[i] = ((gint) error);
error += step - (gint) error;
}
1997-11-25 06:05:25 +08:00
return scale;
}
static guchar *
1997-11-25 06:05:25 +08:00
render_image_tile_fault (RenderInfo *info)
{
Tile *tile;
1997-11-25 06:05:25 +08:00
guchar *data;
guchar *dest;
guchar *scale;
gint width;
gint tilex;
gint tiley;
gint srctilex, srctiley;
gint step;
gint bpp = info->src_bpp;
gint x, b;
1997-11-25 06:05:25 +08:00
tilex = info->src_x / TILE_WIDTH;
tiley = info->src_y / TILE_HEIGHT;
tile = tile_manager_get_tile (info->src_tiles,
srctilex=info->src_x, srctiley=info->src_y,
TRUE, FALSE);
1997-11-25 06:05:25 +08:00
if (!tile)
return NULL;
1998-08-12 01:35:34 +08:00
data = tile_data_pointer (tile,
info->src_x % TILE_WIDTH,
info->src_y % TILE_HEIGHT);
1997-11-25 06:05:25 +08:00
scale = info->scale;
dest = tile_buf;
1997-11-25 06:05:25 +08:00
x = info->src_x;
1997-11-25 06:05:25 +08:00
width = info->w;
while (width--)
{
for (b = 0; b < bpp; b++)
1997-11-25 06:05:25 +08:00
*dest++ = data[b];
step = *scale++;
if (step != 0)
1997-11-25 06:05:25 +08:00
{
x += step;
data += step * bpp;
1997-11-25 06:05:25 +08:00
2000-10-26 07:14:11 +08:00
if ((x >> tile_shift) != tilex)
1997-11-25 06:05:25 +08:00
{
tile_release (tile, FALSE);
1997-11-25 06:05:25 +08:00
tilex += 1;
tile = tile_manager_get_tile (info->src_tiles, srctilex=x,
srctiley=info->src_y, TRUE, FALSE);
2000-10-26 07:14:11 +08:00
if (!tile)
return tile_buf;
1998-08-12 01:35:34 +08:00
data = tile_data_pointer (tile,
x % TILE_WIDTH,
info->src_y % TILE_HEIGHT);
1997-11-25 06:05:25 +08:00
}
}
}
tile_release (tile, FALSE);
1997-11-25 06:05:25 +08:00
return tile_buf;
}