gimp/app/base/temp-buf.c

541 lines
12 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"
#include <string.h>
removed from CVS, they are generated. 2001-12-07 Sven Neumann <sven@gimp.org> * app/core/gimpmarshal.[ch]: removed from CVS, they are generated. * app/base/Makefile.am * app/base/base-enums.h: new file defining enums that are to be registered. Used to build app/base/base-enums.c. * app/base/base-types.h: include base-enums.h. * tools/pdbgen/Makefile.am * tools/pdbgen/enumcode.pl * tools/pdbgen/enums.pl: parse the new base-enums.h file and modified the perl voodoo so it doesn't prefix enums with GIMP_ that are already properly namespaced. * app/core/core-types.h: don't need to chop GIMP from enum. * app/pdb/color_cmds.c * app/pdb/tools_cmds.c * libgimp/gimpenums.h * plug-ins/script-fu/script-fu-constants.c: regenerated. * app/config/gimpconfig-deserialize.[ch] * app/config/gimpconfig-serialize.[ch] * app/config/gimpconfig.[ch]: made GimpConfig an interface including a reasonable default implementation that works on object properties. * app/config/Makefile.am * app/config/gimpbaseconfig.[ch]: new GimpBaseConfig using the GimpConfig interface. Yet only used for testing from app/main.c. * app/main.c: test the new GimpBaseConfig object. * app/gimprc.c * app/base/base-config.h * app/base/*.c * app/core/gimpdatafiles.c * app/core/gimpdrawable-transform.c * app/core/gimppreviewcache.c * app/gui/preferences-dialog.c * app/paint-funcs/paint-funcs.c * app/xcf/xcf-seek.c: need to include glib-object.h since base-config contains registered enums now. Follow name change of InterpolationType to GimpInterpolationType.
2001-12-08 00:10:53 +08:00
#include <glib-object.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 "libgimpbase/gimpbase.h"
#include "libgimpcolor/gimpcolor.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-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 "pixel-region.h"
#include "temp-buf.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 "paint-funcs/paint-funcs.h"
static guchar * temp_buf_allocate (guint size);
static void temp_buf_to_color (TempBuf *src_buf,
TempBuf *dest_buf);
static void temp_buf_to_gray (TempBuf *src_buf,
TempBuf *dest_buf);
1997-11-25 06:05:25 +08:00
/* Memory management */
Michael Natterer <mitch@gimp.org> 2001-12-03 Sven Neumann <sven@gimp.org> Michael Natterer <mitch@gimp.org> * app/paint-funcs/paint-funcs-mmx.h: removed redefiniton of HAS_ALPHA macro. * app/core/gimp.c: reverted Daniel's change; it doesn't make the code simpler, only more error-prone. * app/gui/info-dialog.h * app/gui/resize-dialog.h * app/core/gimp.h * app/core/gimpbrushgenerated.h * app/core/gimpbrushpipe.h * app/core/gimpchannel.[ch] * app/core/gimpcontainer.h * app/core/gimpcoreconfig.h * app/core/gimpdata.h * app/core/gimpdatafactory.[ch] * app/core/gimpdrawable-blend.c * app/core/gimpdrawable.[ch] * app/core/gimpimage.h * app/core/gimpimagefile.h * app/core/gimplayer.h * app/core/gimplayermask.h * app/core/gimpmoduleinfo.h * app/core/gimppalette.h * app/core/gimpundo.h * app/widgets/gimpbrushfactoryview.h * app/widgets/gimpconstrainedhwrapbox.h * app/widgets/gimpcontainermenu.h * app/widgets/gimpcontainerview.h * app/widgets/gimpdialogfactory.h * app/widgets/gimpimagedock.h * app/widgets/gimplistitem.h * app/widgets/gimpmenuitem.h * app/widgets/gimpnavigationpreview.h * app/widgets/gimppreview.h * app/gimprc.h * app/pathP.h * app/tools/gimpbezierselecttool.h * app/tools/gimpcolorbalancetool.h * app/tools/gimpcurvestool.h * app/tools/gimpdodgeburntool.c * app/tools/gimpfreeselecttool.h * app/tools/gimphuesaturationtool.h * app/tools/gimpinktool-blob.h * app/tools/gimpinktool.h * app/tools/gimpiscissorstool.h * app/tools/gimpmagnifytool.h * app/tools/gimpmeasuretool.h * app/tools/gimppainttool.h * app/tools/gimppathtool.h * app/tools/gimprectselecttool.h * app/tools/gimpthresholdtool.h * app/tools/gimptool.h * app/tools/gimptransformtool.h * app/base/base-config.h * app/base/gimplut.[ch] * app/base/pixel-region.h * app/base/pixel-surround.[ch] * app/base/temp-buf.[ch] * app/base/tile-manager-private.h * app/base/tile-manager.[ch] * app/base/tile-private.h * app/base/tile.[ch] * app/display/gimpdisplay.h * app/display/gimpdisplayshell-selection.h * app/display/gimpdisplayshell.h * app/gui/brush-select.h * app/gui/gradient-editor.h * app/gui/gradient-select.h: reverted most of Daniel's changes. There's no reason to use unsigned integers here and in lots of places it is even wrong. Then it's way too early to convert gbooleans into bitfields. This change may make sense in a few places but can happen later when the API has settled and the code is more stable. * app/gimprc.c: reverted Daniel's change. This is a GCC-ism and this code is about to die soon anyway.
2001-12-03 21:44:59 +08:00
static guchar *
temp_buf_allocate (guint size)
1997-11-25 06:05:25 +08:00
{
return g_new (guchar, size);
1997-11-25 06:05:25 +08:00
}
/* The conversion routines */
static void
temp_buf_to_color (TempBuf *src_buf,
1999-07-20 03:46:05 +08:00
TempBuf *dest_buf)
1997-11-25 06:05:25 +08:00
{
guchar *src;
guchar *dest;
glong num_pixels;
1997-11-25 06:05:25 +08:00
src = temp_buf_data (src_buf);
1997-11-25 06:05:25 +08:00
dest = temp_buf_data (dest_buf);
num_pixels = src_buf->width * src_buf->height;
1997-11-25 06:05:25 +08:00
switch (dest_buf->bytes)
1997-11-25 06:05:25 +08:00
{
case 3:
g_return_if_fail (src_buf->bytes == 1);
while (num_pixels--)
{
guchar tmpch;
*dest++ = tmpch = *src++;
*dest++ = tmpch;
*dest++ = tmpch;
}
break;
case 4:
g_return_if_fail (src_buf->bytes == 2);
while (num_pixels--)
{
guchar tmpch;
*dest++ = tmpch = *src++;
*dest++ = tmpch;
*dest++ = tmpch;
*dest++ = *src++; /* alpha channel */
}
break;
default:
g_return_if_reached ();
break;
1997-11-25 06:05:25 +08:00
}
}
static void
temp_buf_to_gray (TempBuf *src_buf,
1999-07-20 03:46:05 +08:00
TempBuf *dest_buf)
1997-11-25 06:05:25 +08:00
{
guchar *src;
guchar *dest;
glong num_pixels;
gfloat pix;
1997-11-25 06:05:25 +08:00
src = temp_buf_data (src_buf);
1997-11-25 06:05:25 +08:00
dest = temp_buf_data (dest_buf);
num_pixels = src_buf->width * src_buf->height;
1997-11-25 06:05:25 +08:00
switch (dest_buf->bytes)
1997-11-25 06:05:25 +08:00
{
case 1:
g_return_if_fail (src_buf->bytes == 3);
while (num_pixels--)
{
pix = GIMP_RGB_LUMINANCE (src[0], src[1], src[2]) + 0.5;
*dest++ = (guchar) pix;
src += 3;
}
break;
case 2:
g_return_if_fail (src_buf->bytes == 4);
while (num_pixels--)
{
pix = GIMP_RGB_LUMINANCE (src[0], src[1], src[2]) + 0.5;
*dest++ = (guchar) pix;
*dest++ = src[3]; /* alpha channel */
src += 4;
}
break;
default:
g_return_if_reached ();
break;
1997-11-25 06:05:25 +08:00
}
}
TempBuf *
Michael Natterer <mitch@gimp.org> 2001-12-03 Sven Neumann <sven@gimp.org> Michael Natterer <mitch@gimp.org> * app/paint-funcs/paint-funcs-mmx.h: removed redefiniton of HAS_ALPHA macro. * app/core/gimp.c: reverted Daniel's change; it doesn't make the code simpler, only more error-prone. * app/gui/info-dialog.h * app/gui/resize-dialog.h * app/core/gimp.h * app/core/gimpbrushgenerated.h * app/core/gimpbrushpipe.h * app/core/gimpchannel.[ch] * app/core/gimpcontainer.h * app/core/gimpcoreconfig.h * app/core/gimpdata.h * app/core/gimpdatafactory.[ch] * app/core/gimpdrawable-blend.c * app/core/gimpdrawable.[ch] * app/core/gimpimage.h * app/core/gimpimagefile.h * app/core/gimplayer.h * app/core/gimplayermask.h * app/core/gimpmoduleinfo.h * app/core/gimppalette.h * app/core/gimpundo.h * app/widgets/gimpbrushfactoryview.h * app/widgets/gimpconstrainedhwrapbox.h * app/widgets/gimpcontainermenu.h * app/widgets/gimpcontainerview.h * app/widgets/gimpdialogfactory.h * app/widgets/gimpimagedock.h * app/widgets/gimplistitem.h * app/widgets/gimpmenuitem.h * app/widgets/gimpnavigationpreview.h * app/widgets/gimppreview.h * app/gimprc.h * app/pathP.h * app/tools/gimpbezierselecttool.h * app/tools/gimpcolorbalancetool.h * app/tools/gimpcurvestool.h * app/tools/gimpdodgeburntool.c * app/tools/gimpfreeselecttool.h * app/tools/gimphuesaturationtool.h * app/tools/gimpinktool-blob.h * app/tools/gimpinktool.h * app/tools/gimpiscissorstool.h * app/tools/gimpmagnifytool.h * app/tools/gimpmeasuretool.h * app/tools/gimppainttool.h * app/tools/gimppathtool.h * app/tools/gimprectselecttool.h * app/tools/gimpthresholdtool.h * app/tools/gimptool.h * app/tools/gimptransformtool.h * app/base/base-config.h * app/base/gimplut.[ch] * app/base/pixel-region.h * app/base/pixel-surround.[ch] * app/base/temp-buf.[ch] * app/base/tile-manager-private.h * app/base/tile-manager.[ch] * app/base/tile-private.h * app/base/tile.[ch] * app/display/gimpdisplay.h * app/display/gimpdisplayshell-selection.h * app/display/gimpdisplayshell.h * app/gui/brush-select.h * app/gui/gradient-editor.h * app/gui/gradient-select.h: reverted most of Daniel's changes. There's no reason to use unsigned integers here and in lots of places it is even wrong. Then it's way too early to convert gbooleans into bitfields. This change may make sense in a few places but can happen later when the API has settled and the code is more stable. * app/gimprc.c: reverted Daniel's change. This is a GCC-ism and this code is about to die soon anyway.
2001-12-03 21:44:59 +08:00
temp_buf_new (gint width,
gint height,
gint bytes,
gint x,
gint y,
guchar *col)
1997-11-25 06:05:25 +08:00
{
Michael Natterer <mitch@gimp.org> 2001-12-03 Sven Neumann <sven@gimp.org> Michael Natterer <mitch@gimp.org> * app/paint-funcs/paint-funcs-mmx.h: removed redefiniton of HAS_ALPHA macro. * app/core/gimp.c: reverted Daniel's change; it doesn't make the code simpler, only more error-prone. * app/gui/info-dialog.h * app/gui/resize-dialog.h * app/core/gimp.h * app/core/gimpbrushgenerated.h * app/core/gimpbrushpipe.h * app/core/gimpchannel.[ch] * app/core/gimpcontainer.h * app/core/gimpcoreconfig.h * app/core/gimpdata.h * app/core/gimpdatafactory.[ch] * app/core/gimpdrawable-blend.c * app/core/gimpdrawable.[ch] * app/core/gimpimage.h * app/core/gimpimagefile.h * app/core/gimplayer.h * app/core/gimplayermask.h * app/core/gimpmoduleinfo.h * app/core/gimppalette.h * app/core/gimpundo.h * app/widgets/gimpbrushfactoryview.h * app/widgets/gimpconstrainedhwrapbox.h * app/widgets/gimpcontainermenu.h * app/widgets/gimpcontainerview.h * app/widgets/gimpdialogfactory.h * app/widgets/gimpimagedock.h * app/widgets/gimplistitem.h * app/widgets/gimpmenuitem.h * app/widgets/gimpnavigationpreview.h * app/widgets/gimppreview.h * app/gimprc.h * app/pathP.h * app/tools/gimpbezierselecttool.h * app/tools/gimpcolorbalancetool.h * app/tools/gimpcurvestool.h * app/tools/gimpdodgeburntool.c * app/tools/gimpfreeselecttool.h * app/tools/gimphuesaturationtool.h * app/tools/gimpinktool-blob.h * app/tools/gimpinktool.h * app/tools/gimpiscissorstool.h * app/tools/gimpmagnifytool.h * app/tools/gimpmeasuretool.h * app/tools/gimppainttool.h * app/tools/gimppathtool.h * app/tools/gimprectselecttool.h * app/tools/gimpthresholdtool.h * app/tools/gimptool.h * app/tools/gimptransformtool.h * app/base/base-config.h * app/base/gimplut.[ch] * app/base/pixel-region.h * app/base/pixel-surround.[ch] * app/base/temp-buf.[ch] * app/base/tile-manager-private.h * app/base/tile-manager.[ch] * app/base/tile-private.h * app/base/tile.[ch] * app/display/gimpdisplay.h * app/display/gimpdisplayshell-selection.h * app/display/gimpdisplayshell.h * app/gui/brush-select.h * app/gui/gradient-editor.h * app/gui/gradient-select.h: reverted most of Daniel's changes. There's no reason to use unsigned integers here and in lots of places it is even wrong. Then it's way too early to convert gbooleans into bitfields. This change may make sense in a few places but can happen later when the API has settled and the code is more stable. * app/gimprc.c: reverted Daniel's change. This is a GCC-ism and this code is about to die soon anyway.
2001-12-03 21:44:59 +08:00
glong i;
guchar *data;
TempBuf *temp;
1997-11-25 06:05:25 +08:00
Michael Natterer <mitch@gimp.org> 2001-12-03 Sven Neumann <sven@gimp.org> Michael Natterer <mitch@gimp.org> * app/paint-funcs/paint-funcs-mmx.h: removed redefiniton of HAS_ALPHA macro. * app/core/gimp.c: reverted Daniel's change; it doesn't make the code simpler, only more error-prone. * app/gui/info-dialog.h * app/gui/resize-dialog.h * app/core/gimp.h * app/core/gimpbrushgenerated.h * app/core/gimpbrushpipe.h * app/core/gimpchannel.[ch] * app/core/gimpcontainer.h * app/core/gimpcoreconfig.h * app/core/gimpdata.h * app/core/gimpdatafactory.[ch] * app/core/gimpdrawable-blend.c * app/core/gimpdrawable.[ch] * app/core/gimpimage.h * app/core/gimpimagefile.h * app/core/gimplayer.h * app/core/gimplayermask.h * app/core/gimpmoduleinfo.h * app/core/gimppalette.h * app/core/gimpundo.h * app/widgets/gimpbrushfactoryview.h * app/widgets/gimpconstrainedhwrapbox.h * app/widgets/gimpcontainermenu.h * app/widgets/gimpcontainerview.h * app/widgets/gimpdialogfactory.h * app/widgets/gimpimagedock.h * app/widgets/gimplistitem.h * app/widgets/gimpmenuitem.h * app/widgets/gimpnavigationpreview.h * app/widgets/gimppreview.h * app/gimprc.h * app/pathP.h * app/tools/gimpbezierselecttool.h * app/tools/gimpcolorbalancetool.h * app/tools/gimpcurvestool.h * app/tools/gimpdodgeburntool.c * app/tools/gimpfreeselecttool.h * app/tools/gimphuesaturationtool.h * app/tools/gimpinktool-blob.h * app/tools/gimpinktool.h * app/tools/gimpiscissorstool.h * app/tools/gimpmagnifytool.h * app/tools/gimpmeasuretool.h * app/tools/gimppainttool.h * app/tools/gimppathtool.h * app/tools/gimprectselecttool.h * app/tools/gimpthresholdtool.h * app/tools/gimptool.h * app/tools/gimptransformtool.h * app/base/base-config.h * app/base/gimplut.[ch] * app/base/pixel-region.h * app/base/pixel-surround.[ch] * app/base/temp-buf.[ch] * app/base/tile-manager-private.h * app/base/tile-manager.[ch] * app/base/tile-private.h * app/base/tile.[ch] * app/display/gimpdisplay.h * app/display/gimpdisplayshell-selection.h * app/display/gimpdisplayshell.h * app/gui/brush-select.h * app/gui/gradient-editor.h * app/gui/gradient-select.h: reverted most of Daniel's changes. There's no reason to use unsigned integers here and in lots of places it is even wrong. Then it's way too early to convert gbooleans into bitfields. This change may make sense in a few places but can happen later when the API has settled and the code is more stable. * app/gimprc.c: reverted Daniel's change. This is a GCC-ism and this code is about to die soon anyway.
2001-12-03 21:44:59 +08:00
g_return_val_if_fail (width > 0 && height > 0, NULL);
g_return_val_if_fail (bytes > 0, NULL);
temp = g_new (TempBuf, 1);
1997-11-25 06:05:25 +08:00
temp->width = width;
temp->height = height;
temp->bytes = bytes;
temp->x = x;
temp->y = y;
1997-11-25 06:05:25 +08:00
Michael Natterer <mitch@gimp.org> 2001-12-03 Sven Neumann <sven@gimp.org> Michael Natterer <mitch@gimp.org> * app/paint-funcs/paint-funcs-mmx.h: removed redefiniton of HAS_ALPHA macro. * app/core/gimp.c: reverted Daniel's change; it doesn't make the code simpler, only more error-prone. * app/gui/info-dialog.h * app/gui/resize-dialog.h * app/core/gimp.h * app/core/gimpbrushgenerated.h * app/core/gimpbrushpipe.h * app/core/gimpchannel.[ch] * app/core/gimpcontainer.h * app/core/gimpcoreconfig.h * app/core/gimpdata.h * app/core/gimpdatafactory.[ch] * app/core/gimpdrawable-blend.c * app/core/gimpdrawable.[ch] * app/core/gimpimage.h * app/core/gimpimagefile.h * app/core/gimplayer.h * app/core/gimplayermask.h * app/core/gimpmoduleinfo.h * app/core/gimppalette.h * app/core/gimpundo.h * app/widgets/gimpbrushfactoryview.h * app/widgets/gimpconstrainedhwrapbox.h * app/widgets/gimpcontainermenu.h * app/widgets/gimpcontainerview.h * app/widgets/gimpdialogfactory.h * app/widgets/gimpimagedock.h * app/widgets/gimplistitem.h * app/widgets/gimpmenuitem.h * app/widgets/gimpnavigationpreview.h * app/widgets/gimppreview.h * app/gimprc.h * app/pathP.h * app/tools/gimpbezierselecttool.h * app/tools/gimpcolorbalancetool.h * app/tools/gimpcurvestool.h * app/tools/gimpdodgeburntool.c * app/tools/gimpfreeselecttool.h * app/tools/gimphuesaturationtool.h * app/tools/gimpinktool-blob.h * app/tools/gimpinktool.h * app/tools/gimpiscissorstool.h * app/tools/gimpmagnifytool.h * app/tools/gimpmeasuretool.h * app/tools/gimppainttool.h * app/tools/gimppathtool.h * app/tools/gimprectselecttool.h * app/tools/gimpthresholdtool.h * app/tools/gimptool.h * app/tools/gimptransformtool.h * app/base/base-config.h * app/base/gimplut.[ch] * app/base/pixel-region.h * app/base/pixel-surround.[ch] * app/base/temp-buf.[ch] * app/base/tile-manager-private.h * app/base/tile-manager.[ch] * app/base/tile-private.h * app/base/tile.[ch] * app/display/gimpdisplay.h * app/display/gimpdisplayshell-selection.h * app/display/gimpdisplayshell.h * app/gui/brush-select.h * app/gui/gradient-editor.h * app/gui/gradient-select.h: reverted most of Daniel's changes. There's no reason to use unsigned integers here and in lots of places it is even wrong. Then it's way too early to convert gbooleans into bitfields. This change may make sense in a few places but can happen later when the API has settled and the code is more stable. * app/gimprc.c: reverted Daniel's change. This is a GCC-ism and this code is about to die soon anyway.
2001-12-03 21:44:59 +08:00
temp->data = data = temp_buf_allocate (width * height * bytes);
1997-11-25 06:05:25 +08:00
/* initialize the data */
if (col)
{
/* First check if we can save a lot of work */
for (i = 1; i < bytes; i++)
{
if (col[0] != col[i])
break;
}
if (i == bytes)
{
memset (data, *col, width * height * bytes);
}
else /* No, we cannot */
{
guchar *dptr = data;
/* Fill the first row */
for (i = width - 1; i >= 0; --i)
{
guchar *init = col;
gint j = bytes;
while (j--)
*dptr++ = *init++;
}
/* Now copy from it (we set bytes to bytes-per-row now) */
bytes *= width;
while (--height)
{
memcpy (dptr, data, bytes);
dptr += bytes;
}
}
1997-11-25 06:05:25 +08:00
}
return temp;
}
/* This function simply renders a checkerboard with the given
parameters into a newly allocated RGB tempbuf */
TempBuf *
temp_buf_new_check (gint width,
gint height,
GimpCheckType check_type,
GimpCheckSize check_size)
{
TempBuf *newbuf;
guchar *data;
guchar check_shift = 0;
guchar check_mod = 0;
guchar check_light = 0;
guchar check_dark = 0;
gint x, y;
g_return_val_if_fail (width > 0 && height > 0, NULL);
switch (check_size)
{
case GIMP_CHECK_SIZE_SMALL_CHECKS:
check_mod = 0x3;
check_shift = 2;
break;
case GIMP_CHECK_SIZE_MEDIUM_CHECKS:
check_mod = 0x7;
check_shift = 3;
break;
case GIMP_CHECK_SIZE_LARGE_CHECKS:
check_mod = 0xf;
check_shift = 4;
break;
}
gimp_checks_get_shades (check_type, &check_light, &check_dark);
newbuf = temp_buf_new (width, height, 3, 0, 0, NULL);
data = temp_buf_data (newbuf);
use the passed Gimp pointer instead of using "the_gimp". 2001-12-03 Michael Natterer <mitch@gimp.org> * app/devices.c: use the passed Gimp pointer instead of using "the_gimp". * app/base/temp-buf.c: indentation. * app/gui/preferences-dialog.c: prefs_toggle_callback(): fixed segfault when trying to find the prefs_dlg widget from a menu item callback (Fixes #65757). * app/gui/offset-dialog.[ch]: fixed public prototype, include the header in the .c file. * app/gui/menus.c: some menu cleanup: moved all functions which operate on the active layer/drawable to <Image>/Layer. Renamed "Layers" to "Layer". * app/display/gimpdisplayshell.c: changed menu update function accordingly. * app/gui/image-commands.[ch] * app/gui/layers-commands.[ch]: moved stuff from image-commands.* to layers-commads.*- * app/tools/gimpblendtool.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpcurvestool.c * app/tools/gimphistogramtool.c * app/tools/gimphuesaturationtool.c * app/tools/gimplevelstool.c * app/tools/gimpposterizetool.c * app/tools/gimpthresholdtool.c * app/tools/paint_options.c * app/tools/transform_options.c * plug-ins/common/align_layers.c * plug-ins/common/autocrop.c * plug-ins/common/autostretch_hsv.c * plug-ins/common/c_astretch.c * plug-ins/common/color_enhance.c * plug-ins/common/guillotine.c * plug-ins/common/normalize.c * plug-ins/common/rotate.c * plug-ins/common/threshold_alpha.c * plug-ins/common/zealouscrop.c * plug-ins/rcm/rcm.c * plug-ins/fp/fp.c: register under <Image>/Layer, some cosmetic fixes.
2001-12-04 01:59:48 +08:00
for (y = 0; y < height; y++)
{
guchar check_dark = y >> check_shift;
guchar color = (check_dark & 0x1) ? check_light : check_dark;
for (x = 0; x < width; x++)
{
*data++ = color;
*data++ = color;
*data++ = color;
if (((x + 1) & check_mod) == 0)
{
check_dark += 1;
color = (check_dark & 0x1) ? check_light : check_dark;
}
}
}
use the passed Gimp pointer instead of using "the_gimp". 2001-12-03 Michael Natterer <mitch@gimp.org> * app/devices.c: use the passed Gimp pointer instead of using "the_gimp". * app/base/temp-buf.c: indentation. * app/gui/preferences-dialog.c: prefs_toggle_callback(): fixed segfault when trying to find the prefs_dlg widget from a menu item callback (Fixes #65757). * app/gui/offset-dialog.[ch]: fixed public prototype, include the header in the .c file. * app/gui/menus.c: some menu cleanup: moved all functions which operate on the active layer/drawable to <Image>/Layer. Renamed "Layers" to "Layer". * app/display/gimpdisplayshell.c: changed menu update function accordingly. * app/gui/image-commands.[ch] * app/gui/layers-commands.[ch]: moved stuff from image-commands.* to layers-commads.*- * app/tools/gimpblendtool.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpcurvestool.c * app/tools/gimphistogramtool.c * app/tools/gimphuesaturationtool.c * app/tools/gimplevelstool.c * app/tools/gimpposterizetool.c * app/tools/gimpthresholdtool.c * app/tools/paint_options.c * app/tools/transform_options.c * plug-ins/common/align_layers.c * plug-ins/common/autocrop.c * plug-ins/common/autostretch_hsv.c * plug-ins/common/c_astretch.c * plug-ins/common/color_enhance.c * plug-ins/common/guillotine.c * plug-ins/common/normalize.c * plug-ins/common/rotate.c * plug-ins/common/threshold_alpha.c * plug-ins/common/zealouscrop.c * plug-ins/rcm/rcm.c * plug-ins/fp/fp.c: register under <Image>/Layer, some cosmetic fixes.
2001-12-04 01:59:48 +08:00
return newbuf;
}
1997-11-25 06:05:25 +08:00
TempBuf *
temp_buf_copy (TempBuf *src,
1999-07-20 03:46:05 +08:00
TempBuf *dest)
1997-11-25 06:05:25 +08:00
{
glong length;
1997-11-25 06:05:25 +08:00
g_return_val_if_fail (src != NULL, NULL);
g_return_val_if_fail (! dest || (dest->width == src->width &&
dest->height == src->height), NULL);
if (! dest)
{
dest = temp_buf_new (src->width, src->height, src->bytes, 0, 0, NULL);
}
1997-11-25 06:05:25 +08:00
if (src->bytes != dest->bytes)
{
if (src->bytes == 4 && dest->bytes == 2) /* RGBA -> GRAYA */
temp_buf_to_gray (src, dest);
else if (src->bytes == 3 && dest->bytes == 1) /* RGB -> GRAY */
temp_buf_to_gray (src, dest);
else if (src->bytes == 2 && dest->bytes == 4) /* GRAYA -> RGBA */
temp_buf_to_color (src, dest);
else if (src->bytes == 1 && dest->bytes == 3) /* GRAY -> RGB */
temp_buf_to_color (src, dest);
else
g_warning ("temp_buf_copy(): unimplemented color conversion");
}
1997-11-25 06:05:25 +08:00
else
{
/* make the copy */
length = src->width * src->height * src->bytes;
memcpy (temp_buf_data (dest), temp_buf_data (src), length);
1997-11-25 06:05:25 +08:00
}
return dest;
1997-11-25 06:05:25 +08:00
}
TempBuf *
temp_buf_resize (TempBuf *buf,
Michael Natterer <mitch@gimp.org> 2001-12-03 Sven Neumann <sven@gimp.org> Michael Natterer <mitch@gimp.org> * app/paint-funcs/paint-funcs-mmx.h: removed redefiniton of HAS_ALPHA macro. * app/core/gimp.c: reverted Daniel's change; it doesn't make the code simpler, only more error-prone. * app/gui/info-dialog.h * app/gui/resize-dialog.h * app/core/gimp.h * app/core/gimpbrushgenerated.h * app/core/gimpbrushpipe.h * app/core/gimpchannel.[ch] * app/core/gimpcontainer.h * app/core/gimpcoreconfig.h * app/core/gimpdata.h * app/core/gimpdatafactory.[ch] * app/core/gimpdrawable-blend.c * app/core/gimpdrawable.[ch] * app/core/gimpimage.h * app/core/gimpimagefile.h * app/core/gimplayer.h * app/core/gimplayermask.h * app/core/gimpmoduleinfo.h * app/core/gimppalette.h * app/core/gimpundo.h * app/widgets/gimpbrushfactoryview.h * app/widgets/gimpconstrainedhwrapbox.h * app/widgets/gimpcontainermenu.h * app/widgets/gimpcontainerview.h * app/widgets/gimpdialogfactory.h * app/widgets/gimpimagedock.h * app/widgets/gimplistitem.h * app/widgets/gimpmenuitem.h * app/widgets/gimpnavigationpreview.h * app/widgets/gimppreview.h * app/gimprc.h * app/pathP.h * app/tools/gimpbezierselecttool.h * app/tools/gimpcolorbalancetool.h * app/tools/gimpcurvestool.h * app/tools/gimpdodgeburntool.c * app/tools/gimpfreeselecttool.h * app/tools/gimphuesaturationtool.h * app/tools/gimpinktool-blob.h * app/tools/gimpinktool.h * app/tools/gimpiscissorstool.h * app/tools/gimpmagnifytool.h * app/tools/gimpmeasuretool.h * app/tools/gimppainttool.h * app/tools/gimppathtool.h * app/tools/gimprectselecttool.h * app/tools/gimpthresholdtool.h * app/tools/gimptool.h * app/tools/gimptransformtool.h * app/base/base-config.h * app/base/gimplut.[ch] * app/base/pixel-region.h * app/base/pixel-surround.[ch] * app/base/temp-buf.[ch] * app/base/tile-manager-private.h * app/base/tile-manager.[ch] * app/base/tile-private.h * app/base/tile.[ch] * app/display/gimpdisplay.h * app/display/gimpdisplayshell-selection.h * app/display/gimpdisplayshell.h * app/gui/brush-select.h * app/gui/gradient-editor.h * app/gui/gradient-select.h: reverted most of Daniel's changes. There's no reason to use unsigned integers here and in lots of places it is even wrong. Then it's way too early to convert gbooleans into bitfields. This change may make sense in a few places but can happen later when the API has settled and the code is more stable. * app/gimprc.c: reverted Daniel's change. This is a GCC-ism and this code is about to die soon anyway.
2001-12-03 21:44:59 +08:00
gint bytes,
gint x,
gint y,
Michael Natterer <mitch@gimp.org> 2001-12-03 Sven Neumann <sven@gimp.org> Michael Natterer <mitch@gimp.org> * app/paint-funcs/paint-funcs-mmx.h: removed redefiniton of HAS_ALPHA macro. * app/core/gimp.c: reverted Daniel's change; it doesn't make the code simpler, only more error-prone. * app/gui/info-dialog.h * app/gui/resize-dialog.h * app/core/gimp.h * app/core/gimpbrushgenerated.h * app/core/gimpbrushpipe.h * app/core/gimpchannel.[ch] * app/core/gimpcontainer.h * app/core/gimpcoreconfig.h * app/core/gimpdata.h * app/core/gimpdatafactory.[ch] * app/core/gimpdrawable-blend.c * app/core/gimpdrawable.[ch] * app/core/gimpimage.h * app/core/gimpimagefile.h * app/core/gimplayer.h * app/core/gimplayermask.h * app/core/gimpmoduleinfo.h * app/core/gimppalette.h * app/core/gimpundo.h * app/widgets/gimpbrushfactoryview.h * app/widgets/gimpconstrainedhwrapbox.h * app/widgets/gimpcontainermenu.h * app/widgets/gimpcontainerview.h * app/widgets/gimpdialogfactory.h * app/widgets/gimpimagedock.h * app/widgets/gimplistitem.h * app/widgets/gimpmenuitem.h * app/widgets/gimpnavigationpreview.h * app/widgets/gimppreview.h * app/gimprc.h * app/pathP.h * app/tools/gimpbezierselecttool.h * app/tools/gimpcolorbalancetool.h * app/tools/gimpcurvestool.h * app/tools/gimpdodgeburntool.c * app/tools/gimpfreeselecttool.h * app/tools/gimphuesaturationtool.h * app/tools/gimpinktool-blob.h * app/tools/gimpinktool.h * app/tools/gimpiscissorstool.h * app/tools/gimpmagnifytool.h * app/tools/gimpmeasuretool.h * app/tools/gimppainttool.h * app/tools/gimppathtool.h * app/tools/gimprectselecttool.h * app/tools/gimpthresholdtool.h * app/tools/gimptool.h * app/tools/gimptransformtool.h * app/base/base-config.h * app/base/gimplut.[ch] * app/base/pixel-region.h * app/base/pixel-surround.[ch] * app/base/temp-buf.[ch] * app/base/tile-manager-private.h * app/base/tile-manager.[ch] * app/base/tile-private.h * app/base/tile.[ch] * app/display/gimpdisplay.h * app/display/gimpdisplayshell-selection.h * app/display/gimpdisplayshell.h * app/gui/brush-select.h * app/gui/gradient-editor.h * app/gui/gradient-select.h: reverted most of Daniel's changes. There's no reason to use unsigned integers here and in lots of places it is even wrong. Then it's way too early to convert gbooleans into bitfields. This change may make sense in a few places but can happen later when the API has settled and the code is more stable. * app/gimprc.c: reverted Daniel's change. This is a GCC-ism and this code is about to die soon anyway.
2001-12-03 21:44:59 +08:00
gint width,
gint height)
1997-11-25 06:05:25 +08:00
{
Michael Natterer <mitch@gimp.org> 2001-12-03 Sven Neumann <sven@gimp.org> Michael Natterer <mitch@gimp.org> * app/paint-funcs/paint-funcs-mmx.h: removed redefiniton of HAS_ALPHA macro. * app/core/gimp.c: reverted Daniel's change; it doesn't make the code simpler, only more error-prone. * app/gui/info-dialog.h * app/gui/resize-dialog.h * app/core/gimp.h * app/core/gimpbrushgenerated.h * app/core/gimpbrushpipe.h * app/core/gimpchannel.[ch] * app/core/gimpcontainer.h * app/core/gimpcoreconfig.h * app/core/gimpdata.h * app/core/gimpdatafactory.[ch] * app/core/gimpdrawable-blend.c * app/core/gimpdrawable.[ch] * app/core/gimpimage.h * app/core/gimpimagefile.h * app/core/gimplayer.h * app/core/gimplayermask.h * app/core/gimpmoduleinfo.h * app/core/gimppalette.h * app/core/gimpundo.h * app/widgets/gimpbrushfactoryview.h * app/widgets/gimpconstrainedhwrapbox.h * app/widgets/gimpcontainermenu.h * app/widgets/gimpcontainerview.h * app/widgets/gimpdialogfactory.h * app/widgets/gimpimagedock.h * app/widgets/gimplistitem.h * app/widgets/gimpmenuitem.h * app/widgets/gimpnavigationpreview.h * app/widgets/gimppreview.h * app/gimprc.h * app/pathP.h * app/tools/gimpbezierselecttool.h * app/tools/gimpcolorbalancetool.h * app/tools/gimpcurvestool.h * app/tools/gimpdodgeburntool.c * app/tools/gimpfreeselecttool.h * app/tools/gimphuesaturationtool.h * app/tools/gimpinktool-blob.h * app/tools/gimpinktool.h * app/tools/gimpiscissorstool.h * app/tools/gimpmagnifytool.h * app/tools/gimpmeasuretool.h * app/tools/gimppainttool.h * app/tools/gimppathtool.h * app/tools/gimprectselecttool.h * app/tools/gimpthresholdtool.h * app/tools/gimptool.h * app/tools/gimptransformtool.h * app/base/base-config.h * app/base/gimplut.[ch] * app/base/pixel-region.h * app/base/pixel-surround.[ch] * app/base/temp-buf.[ch] * app/base/tile-manager-private.h * app/base/tile-manager.[ch] * app/base/tile-private.h * app/base/tile.[ch] * app/display/gimpdisplay.h * app/display/gimpdisplayshell-selection.h * app/display/gimpdisplayshell.h * app/gui/brush-select.h * app/gui/gradient-editor.h * app/gui/gradient-select.h: reverted most of Daniel's changes. There's no reason to use unsigned integers here and in lots of places it is even wrong. Then it's way too early to convert gbooleans into bitfields. This change may make sense in a few places but can happen later when the API has settled and the code is more stable. * app/gimprc.c: reverted Daniel's change. This is a GCC-ism and this code is about to die soon anyway.
2001-12-03 21:44:59 +08:00
gint size;
Convert ugly comments into named structure fields. Much cleaner and less 2001-12-02 Daniel Egger <degger@fhm.edu> * app/gimprc.c: Convert ugly comments into named structure fields. Much cleaner and less errorprone though may cause troubles on older compilers and then needs to be reverted. Please report! * app/base/base-types.h: Add FIXME reminder. * app/base/gimplut.c: Use CLAMP macro instead of if-cascade. * app/base/temp-buf.c: Remove duplicated calculations and simplify checks. * app/base/tile-manager.c: - (tile_manager_get_tile_num): Return success and take an additional pointer for the tilenumber. - Simplify logic in the rest of the file as a result. - Remove rotten debugging cruft. * app/core/gimpbrushgenerated.c: Fix two stylistic nits. * app/app_procs.c: Include <stdlib.h> for exit () prototype. * app/core/gimpdrawable-blend.c: Include <stdlib.h> for abs () prototype. * app/display/gimpdisplay.c: Include <string.h> for memcpy () prototype. * app/core/gimpimage-convert.c: (HIST_RGB): First parameter is not const. Fixes a gcc warning for a wrong return value. * libgimpwidgets/gimpunitmenu.c * app/core/gimpunit.c: Add suggested (by gcc 3.1 cvs) parentheses to group correct logic tests together. * app/paint-funcs/paint-funcs-generic.h: Fix my HAS_ALPHA macro to avoid gcc 3.1 cvs warning. * app/gimprc.h * pathP.h * base-config.h * app/base/boundary.h * app/base/gimplut.[ch] * app/base/pixel-region.h * app/base/pixel-surround.[ch] * app/base/temp-buf.[ch] * app/base/tile-manager-private.h * app/base/tile-manager.c * app/base/tile-private.h * app/base/tile.[ch] * app/core/gimp.h * app/core/gimpbrushgenerated.h * app/core/gimpbrushpipe.h * app/core/gimpchannel.[ch] * app/core/gimpcontainer.h * app/core/gimpcoreconfig.h * app/core/gimpdata.h * app/core/gimpdatafactory.[ch] * app/core/gimpdrawable-blend.c * app/core/gimpdrawable.[ch] * app/core/gimpimage.h * app/core/gimpimagefile.h * app/core/gimplayer.h * app/core/gimplayermask.h * app/core/gimpmoduleinfo.h * app/core/gimppalette.h * app/core/gimpundo.h * app/display/gimpdisplay.h * app/display/gimpdisplayshell-selection.h * app/display/gimpdisplayshell.h * app/gui/brush-select.h * app/gui/gradient-editor.h * app/gui/gradient-select.h * app/gui/info-dialog.h * app/gui/resize-dialog.h * app/tools/gimpbezierselecttool.h * app/tools/gimpcolorbalancetool.h * app/tools/gimpcolorpickertool.h * app/tools/gimpcurvestool.h * app/tools/gimpdodgeburntool.c * app/tools/gimpfreeselecttool.h * app/tools/gimpfuzzyselecttool.h * app/tools/gimphuesaturationtool.h * app/tools/gimpinktool-blob.h * app/tools/gimpinktool.h * app/tools/gimpiscissorstool.h * app/tools/gimpmagnifytool.h * app/tools/gimpmeasuretool.h * app/tools/gimppainttool.h * app/tools/gimppathtool.h * app/tools/gimprectselecttool.h * app/tools/gimpthresholdtool.h * app/tools/gimptool.h * app/tools/gimptransformtool.h * app/tools/path_toolP.h * app/widgets/gimpbrushfactoryview.h * app/widgets/gimpconstrainedhwrapbox.h * app/widgets/gimpcontainermenu.h * app/widgets/gimpcontainerview.h * app/widgets/gimpdialogfactory.h * app/widgets/gimpimagedock.h * app/widgets/gimplistitem.h * app/widgets/gimpmenuitem.h * app/widgets/gimpnavigationpreview.h * app/widgets/gimppreview.h: Unsignify lots of variables and parameters and use bitfields in structs where possible. First part of a huge cleanup all over the code...
2001-12-02 22:59:30 +08:00
Michael Natterer <mitch@gimp.org> 2001-12-03 Sven Neumann <sven@gimp.org> Michael Natterer <mitch@gimp.org> * app/paint-funcs/paint-funcs-mmx.h: removed redefiniton of HAS_ALPHA macro. * app/core/gimp.c: reverted Daniel's change; it doesn't make the code simpler, only more error-prone. * app/gui/info-dialog.h * app/gui/resize-dialog.h * app/core/gimp.h * app/core/gimpbrushgenerated.h * app/core/gimpbrushpipe.h * app/core/gimpchannel.[ch] * app/core/gimpcontainer.h * app/core/gimpcoreconfig.h * app/core/gimpdata.h * app/core/gimpdatafactory.[ch] * app/core/gimpdrawable-blend.c * app/core/gimpdrawable.[ch] * app/core/gimpimage.h * app/core/gimpimagefile.h * app/core/gimplayer.h * app/core/gimplayermask.h * app/core/gimpmoduleinfo.h * app/core/gimppalette.h * app/core/gimpundo.h * app/widgets/gimpbrushfactoryview.h * app/widgets/gimpconstrainedhwrapbox.h * app/widgets/gimpcontainermenu.h * app/widgets/gimpcontainerview.h * app/widgets/gimpdialogfactory.h * app/widgets/gimpimagedock.h * app/widgets/gimplistitem.h * app/widgets/gimpmenuitem.h * app/widgets/gimpnavigationpreview.h * app/widgets/gimppreview.h * app/gimprc.h * app/pathP.h * app/tools/gimpbezierselecttool.h * app/tools/gimpcolorbalancetool.h * app/tools/gimpcurvestool.h * app/tools/gimpdodgeburntool.c * app/tools/gimpfreeselecttool.h * app/tools/gimphuesaturationtool.h * app/tools/gimpinktool-blob.h * app/tools/gimpinktool.h * app/tools/gimpiscissorstool.h * app/tools/gimpmagnifytool.h * app/tools/gimpmeasuretool.h * app/tools/gimppainttool.h * app/tools/gimppathtool.h * app/tools/gimprectselecttool.h * app/tools/gimpthresholdtool.h * app/tools/gimptool.h * app/tools/gimptransformtool.h * app/base/base-config.h * app/base/gimplut.[ch] * app/base/pixel-region.h * app/base/pixel-surround.[ch] * app/base/temp-buf.[ch] * app/base/tile-manager-private.h * app/base/tile-manager.[ch] * app/base/tile-private.h * app/base/tile.[ch] * app/display/gimpdisplay.h * app/display/gimpdisplayshell-selection.h * app/display/gimpdisplayshell.h * app/gui/brush-select.h * app/gui/gradient-editor.h * app/gui/gradient-select.h: reverted most of Daniel's changes. There's no reason to use unsigned integers here and in lots of places it is even wrong. Then it's way too early to convert gbooleans into bitfields. This change may make sense in a few places but can happen later when the API has settled and the code is more stable. * app/gimprc.c: reverted Daniel's change. This is a GCC-ism and this code is about to die soon anyway.
2001-12-03 21:44:59 +08:00
g_return_val_if_fail (width > 0 && height > 0, NULL);
/* calculate the requested size */
size = width * height * bytes;
1997-11-25 06:05:25 +08:00
/* First, configure the canvas buffer */
if (!buf)
{
buf = temp_buf_new (width, height, bytes, x, y, NULL);
}
1997-11-25 06:05:25 +08:00
else
{
if (size != (buf->width * buf->height * buf->bytes))
use the passed Gimp pointer instead of using "the_gimp". 2001-12-03 Michael Natterer <mitch@gimp.org> * app/devices.c: use the passed Gimp pointer instead of using "the_gimp". * app/base/temp-buf.c: indentation. * app/gui/preferences-dialog.c: prefs_toggle_callback(): fixed segfault when trying to find the prefs_dlg widget from a menu item callback (Fixes #65757). * app/gui/offset-dialog.[ch]: fixed public prototype, include the header in the .c file. * app/gui/menus.c: some menu cleanup: moved all functions which operate on the active layer/drawable to <Image>/Layer. Renamed "Layers" to "Layer". * app/display/gimpdisplayshell.c: changed menu update function accordingly. * app/gui/image-commands.[ch] * app/gui/layers-commands.[ch]: moved stuff from image-commands.* to layers-commads.*- * app/tools/gimpblendtool.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpcurvestool.c * app/tools/gimphistogramtool.c * app/tools/gimphuesaturationtool.c * app/tools/gimplevelstool.c * app/tools/gimpposterizetool.c * app/tools/gimpthresholdtool.c * app/tools/paint_options.c * app/tools/transform_options.c * plug-ins/common/align_layers.c * plug-ins/common/autocrop.c * plug-ins/common/autostretch_hsv.c * plug-ins/common/c_astretch.c * plug-ins/common/color_enhance.c * plug-ins/common/guillotine.c * plug-ins/common/normalize.c * plug-ins/common/rotate.c * plug-ins/common/threshold_alpha.c * plug-ins/common/zealouscrop.c * plug-ins/rcm/rcm.c * plug-ins/fp/fp.c: register under <Image>/Layer, some cosmetic fixes.
2001-12-04 01:59:48 +08:00
{
buf->data = g_renew (guchar, buf->data, size);
use the passed Gimp pointer instead of using "the_gimp". 2001-12-03 Michael Natterer <mitch@gimp.org> * app/devices.c: use the passed Gimp pointer instead of using "the_gimp". * app/base/temp-buf.c: indentation. * app/gui/preferences-dialog.c: prefs_toggle_callback(): fixed segfault when trying to find the prefs_dlg widget from a menu item callback (Fixes #65757). * app/gui/offset-dialog.[ch]: fixed public prototype, include the header in the .c file. * app/gui/menus.c: some menu cleanup: moved all functions which operate on the active layer/drawable to <Image>/Layer. Renamed "Layers" to "Layer". * app/display/gimpdisplayshell.c: changed menu update function accordingly. * app/gui/image-commands.[ch] * app/gui/layers-commands.[ch]: moved stuff from image-commands.* to layers-commads.*- * app/tools/gimpblendtool.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpcurvestool.c * app/tools/gimphistogramtool.c * app/tools/gimphuesaturationtool.c * app/tools/gimplevelstool.c * app/tools/gimpposterizetool.c * app/tools/gimpthresholdtool.c * app/tools/paint_options.c * app/tools/transform_options.c * plug-ins/common/align_layers.c * plug-ins/common/autocrop.c * plug-ins/common/autostretch_hsv.c * plug-ins/common/c_astretch.c * plug-ins/common/color_enhance.c * plug-ins/common/guillotine.c * plug-ins/common/normalize.c * plug-ins/common/rotate.c * plug-ins/common/threshold_alpha.c * plug-ins/common/zealouscrop.c * plug-ins/rcm/rcm.c * plug-ins/fp/fp.c: register under <Image>/Layer, some cosmetic fixes.
2001-12-04 01:59:48 +08:00
}
1997-11-25 06:05:25 +08:00
/* Make sure the temp buf fields are valid */
buf->x = x;
buf->y = y;
buf->width = width;
buf->height = height;
buf->bytes = bytes;
1997-11-25 06:05:25 +08:00
}
return buf;
}
TempBuf *
temp_buf_scale (TempBuf *src,
gint new_width,
Michael Natterer <mitch@gimp.org> 2001-12-03 Sven Neumann <sven@gimp.org> Michael Natterer <mitch@gimp.org> * app/paint-funcs/paint-funcs-mmx.h: removed redefiniton of HAS_ALPHA macro. * app/core/gimp.c: reverted Daniel's change; it doesn't make the code simpler, only more error-prone. * app/gui/info-dialog.h * app/gui/resize-dialog.h * app/core/gimp.h * app/core/gimpbrushgenerated.h * app/core/gimpbrushpipe.h * app/core/gimpchannel.[ch] * app/core/gimpcontainer.h * app/core/gimpcoreconfig.h * app/core/gimpdata.h * app/core/gimpdatafactory.[ch] * app/core/gimpdrawable-blend.c * app/core/gimpdrawable.[ch] * app/core/gimpimage.h * app/core/gimpimagefile.h * app/core/gimplayer.h * app/core/gimplayermask.h * app/core/gimpmoduleinfo.h * app/core/gimppalette.h * app/core/gimpundo.h * app/widgets/gimpbrushfactoryview.h * app/widgets/gimpconstrainedhwrapbox.h * app/widgets/gimpcontainermenu.h * app/widgets/gimpcontainerview.h * app/widgets/gimpdialogfactory.h * app/widgets/gimpimagedock.h * app/widgets/gimplistitem.h * app/widgets/gimpmenuitem.h * app/widgets/gimpnavigationpreview.h * app/widgets/gimppreview.h * app/gimprc.h * app/pathP.h * app/tools/gimpbezierselecttool.h * app/tools/gimpcolorbalancetool.h * app/tools/gimpcurvestool.h * app/tools/gimpdodgeburntool.c * app/tools/gimpfreeselecttool.h * app/tools/gimphuesaturationtool.h * app/tools/gimpinktool-blob.h * app/tools/gimpinktool.h * app/tools/gimpiscissorstool.h * app/tools/gimpmagnifytool.h * app/tools/gimpmeasuretool.h * app/tools/gimppainttool.h * app/tools/gimppathtool.h * app/tools/gimprectselecttool.h * app/tools/gimpthresholdtool.h * app/tools/gimptool.h * app/tools/gimptransformtool.h * app/base/base-config.h * app/base/gimplut.[ch] * app/base/pixel-region.h * app/base/pixel-surround.[ch] * app/base/temp-buf.[ch] * app/base/tile-manager-private.h * app/base/tile-manager.[ch] * app/base/tile-private.h * app/base/tile.[ch] * app/display/gimpdisplay.h * app/display/gimpdisplayshell-selection.h * app/display/gimpdisplayshell.h * app/gui/brush-select.h * app/gui/gradient-editor.h * app/gui/gradient-select.h: reverted most of Daniel's changes. There's no reason to use unsigned integers here and in lots of places it is even wrong. Then it's way too early to convert gbooleans into bitfields. This change may make sense in a few places but can happen later when the API has settled and the code is more stable. * app/gimprc.c: reverted Daniel's change. This is a GCC-ism and this code is about to die soon anyway.
2001-12-03 21:44:59 +08:00
gint new_height)
{
Michael Natterer <mitch@gimp.org> 2001-12-03 Sven Neumann <sven@gimp.org> Michael Natterer <mitch@gimp.org> * app/paint-funcs/paint-funcs-mmx.h: removed redefiniton of HAS_ALPHA macro. * app/core/gimp.c: reverted Daniel's change; it doesn't make the code simpler, only more error-prone. * app/gui/info-dialog.h * app/gui/resize-dialog.h * app/core/gimp.h * app/core/gimpbrushgenerated.h * app/core/gimpbrushpipe.h * app/core/gimpchannel.[ch] * app/core/gimpcontainer.h * app/core/gimpcoreconfig.h * app/core/gimpdata.h * app/core/gimpdatafactory.[ch] * app/core/gimpdrawable-blend.c * app/core/gimpdrawable.[ch] * app/core/gimpimage.h * app/core/gimpimagefile.h * app/core/gimplayer.h * app/core/gimplayermask.h * app/core/gimpmoduleinfo.h * app/core/gimppalette.h * app/core/gimpundo.h * app/widgets/gimpbrushfactoryview.h * app/widgets/gimpconstrainedhwrapbox.h * app/widgets/gimpcontainermenu.h * app/widgets/gimpcontainerview.h * app/widgets/gimpdialogfactory.h * app/widgets/gimpimagedock.h * app/widgets/gimplistitem.h * app/widgets/gimpmenuitem.h * app/widgets/gimpnavigationpreview.h * app/widgets/gimppreview.h * app/gimprc.h * app/pathP.h * app/tools/gimpbezierselecttool.h * app/tools/gimpcolorbalancetool.h * app/tools/gimpcurvestool.h * app/tools/gimpdodgeburntool.c * app/tools/gimpfreeselecttool.h * app/tools/gimphuesaturationtool.h * app/tools/gimpinktool-blob.h * app/tools/gimpinktool.h * app/tools/gimpiscissorstool.h * app/tools/gimpmagnifytool.h * app/tools/gimpmeasuretool.h * app/tools/gimppainttool.h * app/tools/gimppathtool.h * app/tools/gimprectselecttool.h * app/tools/gimpthresholdtool.h * app/tools/gimptool.h * app/tools/gimptransformtool.h * app/base/base-config.h * app/base/gimplut.[ch] * app/base/pixel-region.h * app/base/pixel-surround.[ch] * app/base/temp-buf.[ch] * app/base/tile-manager-private.h * app/base/tile-manager.[ch] * app/base/tile-private.h * app/base/tile.[ch] * app/display/gimpdisplay.h * app/display/gimpdisplayshell-selection.h * app/display/gimpdisplayshell.h * app/gui/brush-select.h * app/gui/gradient-editor.h * app/gui/gradient-select.h: reverted most of Daniel's changes. There's no reason to use unsigned integers here and in lots of places it is even wrong. Then it's way too early to convert gbooleans into bitfields. This change may make sense in a few places but can happen later when the API has settled and the code is more stable. * app/gimprc.c: reverted Daniel's change. This is a GCC-ism and this code is about to die soon anyway.
2001-12-03 21:44:59 +08:00
gint loop1;
gint loop2;
gdouble x_ratio;
gdouble y_ratio;
guchar *src_data;
guchar *dest_data;
TempBuf *dest;
g_return_val_if_fail (src != NULL, NULL);
g_return_val_if_fail (new_width > 0 && new_height > 0, NULL);
dest = temp_buf_new (new_width,
new_height,
src->bytes,
0, 0, NULL);
src_data = temp_buf_data (src);
dest_data = temp_buf_data (dest);
x_ratio = (gdouble) src->width / (gdouble) new_width;
y_ratio = (gdouble) src->height / (gdouble) new_height;
for (loop1 = 0 ; loop1 < new_height ; loop1++)
{
for (loop2 = 0 ; loop2 < new_width ; loop2++)
{
gint i;
guchar *src_pixel;
guchar *dest_pixel;
src_pixel = src_data +
(gint) (loop2 * x_ratio) * src->bytes +
(gint) (loop1 * y_ratio) * src->bytes * src->width;
dest_pixel = dest_data +
(loop2 + loop1 * new_width) * src->bytes;
for (i = 0 ; i < src->bytes; i++)
*dest_pixel++ = *src_pixel++;
}
}
return dest;
}
1997-11-25 06:05:25 +08:00
TempBuf *
temp_buf_copy_area (TempBuf *src,
TempBuf *dest,
gint x,
gint y,
Michael Natterer <mitch@gimp.org> 2001-12-03 Sven Neumann <sven@gimp.org> Michael Natterer <mitch@gimp.org> * app/paint-funcs/paint-funcs-mmx.h: removed redefiniton of HAS_ALPHA macro. * app/core/gimp.c: reverted Daniel's change; it doesn't make the code simpler, only more error-prone. * app/gui/info-dialog.h * app/gui/resize-dialog.h * app/core/gimp.h * app/core/gimpbrushgenerated.h * app/core/gimpbrushpipe.h * app/core/gimpchannel.[ch] * app/core/gimpcontainer.h * app/core/gimpcoreconfig.h * app/core/gimpdata.h * app/core/gimpdatafactory.[ch] * app/core/gimpdrawable-blend.c * app/core/gimpdrawable.[ch] * app/core/gimpimage.h * app/core/gimpimagefile.h * app/core/gimplayer.h * app/core/gimplayermask.h * app/core/gimpmoduleinfo.h * app/core/gimppalette.h * app/core/gimpundo.h * app/widgets/gimpbrushfactoryview.h * app/widgets/gimpconstrainedhwrapbox.h * app/widgets/gimpcontainermenu.h * app/widgets/gimpcontainerview.h * app/widgets/gimpdialogfactory.h * app/widgets/gimpimagedock.h * app/widgets/gimplistitem.h * app/widgets/gimpmenuitem.h * app/widgets/gimpnavigationpreview.h * app/widgets/gimppreview.h * app/gimprc.h * app/pathP.h * app/tools/gimpbezierselecttool.h * app/tools/gimpcolorbalancetool.h * app/tools/gimpcurvestool.h * app/tools/gimpdodgeburntool.c * app/tools/gimpfreeselecttool.h * app/tools/gimphuesaturationtool.h * app/tools/gimpinktool-blob.h * app/tools/gimpinktool.h * app/tools/gimpiscissorstool.h * app/tools/gimpmagnifytool.h * app/tools/gimpmeasuretool.h * app/tools/gimppainttool.h * app/tools/gimppathtool.h * app/tools/gimprectselecttool.h * app/tools/gimpthresholdtool.h * app/tools/gimptool.h * app/tools/gimptransformtool.h * app/base/base-config.h * app/base/gimplut.[ch] * app/base/pixel-region.h * app/base/pixel-surround.[ch] * app/base/temp-buf.[ch] * app/base/tile-manager-private.h * app/base/tile-manager.[ch] * app/base/tile-private.h * app/base/tile.[ch] * app/display/gimpdisplay.h * app/display/gimpdisplayshell-selection.h * app/display/gimpdisplayshell.h * app/gui/brush-select.h * app/gui/gradient-editor.h * app/gui/gradient-select.h: reverted most of Daniel's changes. There's no reason to use unsigned integers here and in lots of places it is even wrong. Then it's way too early to convert gbooleans into bitfields. This change may make sense in a few places but can happen later when the API has settled and the code is more stable. * app/gimprc.c: reverted Daniel's change. This is a GCC-ism and this code is about to die soon anyway.
2001-12-03 21:44:59 +08:00
gint width,
gint height,
gint dest_x,
gint dest_y)
1997-11-25 06:05:25 +08:00
{
TempBuf *new;
Fix a bunch of warnings from Sparse: 2004-11-13 Manish Singh <yosh@gimp.org> Fix a bunch of warnings from Sparse: * app/actions/dockable-commands.c * app/actions/layers-actions.c * app/actions/view-commands.c * app/base/pixel-surround.c * app/config/gimpconfig-utils.c * app/config/gimpscanner.c * app/core/gimpbrushgenerated.c * app/core/gimpcontainer.c * app/core/gimpimage.c * app/dialogs/palette-import-dialog.c * app/file/gimprecentlist.c * app/plug-in/plug-in-params.c * app/text/gimptext-compat.c * app/text/gimptext-parasite.c * app/vectors/gimpbezierstroke.c * app/vectors/gimpstroke.c * app/widgets/gimpcellrendereraccel.c * app/widgets/gimpselectiondata.c * app/xcf/xcf.c * libgimp/gimp.c * libgimpthumb/gimpthumb-utils.c * libgimpthumb/gimpthumbnail.c * modules/cdisplay_proof.c * plug-ins/Lighting/lighting_ui.c * plug-ins/common/csource.c * plug-ins/common/glasstile.c * plug-ins/common/nova.c * plug-ins/common/pcx.c * plug-ins/common/pnm.c * plug-ins/common/randomize.c * plug-ins/common/screenshot.c * plug-ins/common/sel_gauss.c * plug-ins/common/spheredesigner.c * plug-ins/common/wind.c * plug-ins/gfig/gfig-dialog.c * plug-ins/gfig/gfig-dobject.c * plug-ins/gimpressionist/gimpressionist.c * plug-ins/ifscompose/ifscompose.c * plug-ins/print/gimp_main_window.c * plug-ins/print/print.c: Cleanup integer vs. pointer confusion. * app/base/temp-buf.c * app/dialogs/about-dialog.c * plug-ins/common/bumpmap.c * plug-ins/common/jigsaw.c * plug-ins/gfig/gfig-dobject.c: Cosmetic cleanups. * app/config/gimpconfig-deserialize.c * app/config/gimpconfig-path.c * app/config/gimpconfigwriter.c * app/core/gimpgradient.c * app/tools/gimpdrawtool.c * plug-ins/common/nlfilt.c * plug-ins/common/unsharp.c * plug-ins/common/zealouscrop.c: Define inline functions before they are used. * app/core/gimpdrawable-blend.c: PixelRegion definition was changed some time ago, but the initialization here didn't change. Fix it. * app/plug-in/plug-in-rc.c (plug_in_extra_deserialize): No need to assign token twice in a row. * libgimpbase/gimpdatafiles.c (gimp_datafiles_read_directories): No need to initialize file_data, since the code fills out all the fields. * plug-ins/common/CML_explorer.c * plug-ins/common/vpropagate.c: Declare function pointers fully. * plug-ins/common/grid.c (pix_composite): G_INLINE_FUNC isn't needed, we assume we can use the "inline" keyword always. * plug-ins/common/psd_save.c * plug-ins/common/vinvert.c * plug-ins/gfig/gfig-arc.c * plug-ins/gfig/gfig-bezier.c * plug-ins/gfig/gfig-circle.c * plug-ins/gfig/gfig-dialog.c * plug-ins/gfig/gfig-dobject.c * plug-ins/gfig/gfig-ellipse.c * plug-ins/gfig/gfig-line.c * plug-ins/gfig/gfig-poly.c * plug-ins/gfig/gfig-spiral.c * plug-ins/gfig/gfig-star.c * plug-ins/gfig/gfig.c * plug-ins/gimpressionist/orientmap.c * plug-ins/gimpressionist/placement.c * plug-ins/gimpressionist/sizemap.c * plug-ins/imagemap/imap_grid.c * plug-ins/imagemap/imap_main.c * plug-ins/imagemap/imap_preferences.c * plug-ins/imagemap/imap_settings.c * plug-ins/maze/maze.c * plug-ins/sel2path/curve.c * plug-ins/sel2path/fit.c * plug-ins/sel2path/pxl-outline.c * plug-ins/sel2path/spline.c * plug-ins/xjt/xjt.c: Functions with no args should be declared with (void). * plug-ins/common/retinex.c (MSRCR): Initialize max_preview to quiet the compiler.
2004-11-14 10:50:33 +08:00
PixelRegion srcPR = { 0, };
PixelRegion destPR = { 0, };
guchar empty[MAX_CHANNELS] = { 0, 0, 0, 0 };
gint x1, y1, x2, y2;
1997-11-25 06:05:25 +08:00
Fix a bunch of warnings from Sparse: 2004-11-13 Manish Singh <yosh@gimp.org> Fix a bunch of warnings from Sparse: * app/actions/dockable-commands.c * app/actions/layers-actions.c * app/actions/view-commands.c * app/base/pixel-surround.c * app/config/gimpconfig-utils.c * app/config/gimpscanner.c * app/core/gimpbrushgenerated.c * app/core/gimpcontainer.c * app/core/gimpimage.c * app/dialogs/palette-import-dialog.c * app/file/gimprecentlist.c * app/plug-in/plug-in-params.c * app/text/gimptext-compat.c * app/text/gimptext-parasite.c * app/vectors/gimpbezierstroke.c * app/vectors/gimpstroke.c * app/widgets/gimpcellrendereraccel.c * app/widgets/gimpselectiondata.c * app/xcf/xcf.c * libgimp/gimp.c * libgimpthumb/gimpthumb-utils.c * libgimpthumb/gimpthumbnail.c * modules/cdisplay_proof.c * plug-ins/Lighting/lighting_ui.c * plug-ins/common/csource.c * plug-ins/common/glasstile.c * plug-ins/common/nova.c * plug-ins/common/pcx.c * plug-ins/common/pnm.c * plug-ins/common/randomize.c * plug-ins/common/screenshot.c * plug-ins/common/sel_gauss.c * plug-ins/common/spheredesigner.c * plug-ins/common/wind.c * plug-ins/gfig/gfig-dialog.c * plug-ins/gfig/gfig-dobject.c * plug-ins/gimpressionist/gimpressionist.c * plug-ins/ifscompose/ifscompose.c * plug-ins/print/gimp_main_window.c * plug-ins/print/print.c: Cleanup integer vs. pointer confusion. * app/base/temp-buf.c * app/dialogs/about-dialog.c * plug-ins/common/bumpmap.c * plug-ins/common/jigsaw.c * plug-ins/gfig/gfig-dobject.c: Cosmetic cleanups. * app/config/gimpconfig-deserialize.c * app/config/gimpconfig-path.c * app/config/gimpconfigwriter.c * app/core/gimpgradient.c * app/tools/gimpdrawtool.c * plug-ins/common/nlfilt.c * plug-ins/common/unsharp.c * plug-ins/common/zealouscrop.c: Define inline functions before they are used. * app/core/gimpdrawable-blend.c: PixelRegion definition was changed some time ago, but the initialization here didn't change. Fix it. * app/plug-in/plug-in-rc.c (plug_in_extra_deserialize): No need to assign token twice in a row. * libgimpbase/gimpdatafiles.c (gimp_datafiles_read_directories): No need to initialize file_data, since the code fills out all the fields. * plug-ins/common/CML_explorer.c * plug-ins/common/vpropagate.c: Declare function pointers fully. * plug-ins/common/grid.c (pix_composite): G_INLINE_FUNC isn't needed, we assume we can use the "inline" keyword always. * plug-ins/common/psd_save.c * plug-ins/common/vinvert.c * plug-ins/gfig/gfig-arc.c * plug-ins/gfig/gfig-bezier.c * plug-ins/gfig/gfig-circle.c * plug-ins/gfig/gfig-dialog.c * plug-ins/gfig/gfig-dobject.c * plug-ins/gfig/gfig-ellipse.c * plug-ins/gfig/gfig-line.c * plug-ins/gfig/gfig-poly.c * plug-ins/gfig/gfig-spiral.c * plug-ins/gfig/gfig-star.c * plug-ins/gfig/gfig.c * plug-ins/gimpressionist/orientmap.c * plug-ins/gimpressionist/placement.c * plug-ins/gimpressionist/sizemap.c * plug-ins/imagemap/imap_grid.c * plug-ins/imagemap/imap_main.c * plug-ins/imagemap/imap_preferences.c * plug-ins/imagemap/imap_settings.c * plug-ins/maze/maze.c * plug-ins/sel2path/curve.c * plug-ins/sel2path/fit.c * plug-ins/sel2path/pxl-outline.c * plug-ins/sel2path/spline.c * plug-ins/xjt/xjt.c: Functions with no args should be declared with (void). * plug-ins/common/retinex.c (MSRCR): Initialize max_preview to quiet the compiler.
2004-11-14 10:50:33 +08:00
g_return_val_if_fail (src != NULL, dest);
g_return_val_if_fail (!dest || dest->bytes == src->bytes, dest);
g_return_val_if_fail (width + dest_x > 0, dest);
g_return_val_if_fail (height + dest_y > 0, dest);
g_return_val_if_fail (!dest || dest->width >= width + dest_x, dest);
g_return_val_if_fail (!dest || dest->height >= height + dest_y, dest);
1997-11-25 06:05:25 +08:00
/* some bounds checking */
x1 = CLAMP (x, 0, src->width - 1);
y1 = CLAMP (y, 0, src->height - 1);
x2 = CLAMP (x + width - 1, 0, src->width - 1);
y2 = CLAMP (y + height - 1, 0, src->height - 1);
1997-11-25 06:05:25 +08:00
if (!(x2 - x1) || !(y2 - y1))
return dest;
width = x2 - x1 + 1;
height = y2 - y1 + 1;
1997-11-25 06:05:25 +08:00
if (! dest)
{
new = temp_buf_new (width + dest_x,
height + dest_y,
src->bytes,
0, 0,
empty);
}
1997-11-25 06:05:25 +08:00
else
{
new = dest;
}
/* Copy the region */
srcPR.bytes = src->bytes;
srcPR.w = width;
srcPR.h = height;
srcPR.rowstride = src->bytes * src->width;
srcPR.data = temp_buf_data (src) + (y1 * srcPR.rowstride +
x1 * srcPR.bytes);
destPR.bytes = dest->bytes;
destPR.rowstride = new->bytes * new->width;
destPR.data = temp_buf_data (new) + (dest_y * destPR.rowstride +
dest_x * destPR.bytes);
copy_region (&srcPR, &destPR);
1997-11-25 06:05:25 +08:00
return new;
}
void
1999-07-20 03:46:05 +08:00
temp_buf_free (TempBuf *temp_buf)
{
g_return_if_fail (temp_buf != NULL);
if (temp_buf->data)
1997-11-25 06:05:25 +08:00
g_free (temp_buf->data);
g_free (temp_buf);
}
guchar *
1999-07-20 03:46:05 +08:00
temp_buf_data (TempBuf *temp_buf)
1997-11-25 06:05:25 +08:00
{
return temp_buf->data;
}
guchar *
temp_buf_data_clear (TempBuf *temp_buf)
{
g_return_val_if_fail (temp_buf != NULL, NULL);
memset (temp_buf->data, 0,
temp_buf->height * temp_buf->width * temp_buf->bytes);
return temp_buf->data;
}
1997-11-25 06:05:25 +08:00
gsize
temp_buf_get_memsize (TempBuf *temp_buf)
{
gsize memsize = 0;
g_return_val_if_fail (temp_buf != NULL, 0);
memsize += (sizeof (TempBuf)
+ (gsize) temp_buf->bytes * temp_buf->width * temp_buf->height);
return memsize;
}
1997-11-25 06:05:25 +08:00
/******************************************************************
* Mask buffer functions *
******************************************************************/
MaskBuf *
mask_buf_new (gint width,
Michael Natterer <mitch@gimp.org> 2001-12-03 Sven Neumann <sven@gimp.org> Michael Natterer <mitch@gimp.org> * app/paint-funcs/paint-funcs-mmx.h: removed redefiniton of HAS_ALPHA macro. * app/core/gimp.c: reverted Daniel's change; it doesn't make the code simpler, only more error-prone. * app/gui/info-dialog.h * app/gui/resize-dialog.h * app/core/gimp.h * app/core/gimpbrushgenerated.h * app/core/gimpbrushpipe.h * app/core/gimpchannel.[ch] * app/core/gimpcontainer.h * app/core/gimpcoreconfig.h * app/core/gimpdata.h * app/core/gimpdatafactory.[ch] * app/core/gimpdrawable-blend.c * app/core/gimpdrawable.[ch] * app/core/gimpimage.h * app/core/gimpimagefile.h * app/core/gimplayer.h * app/core/gimplayermask.h * app/core/gimpmoduleinfo.h * app/core/gimppalette.h * app/core/gimpundo.h * app/widgets/gimpbrushfactoryview.h * app/widgets/gimpconstrainedhwrapbox.h * app/widgets/gimpcontainermenu.h * app/widgets/gimpcontainerview.h * app/widgets/gimpdialogfactory.h * app/widgets/gimpimagedock.h * app/widgets/gimplistitem.h * app/widgets/gimpmenuitem.h * app/widgets/gimpnavigationpreview.h * app/widgets/gimppreview.h * app/gimprc.h * app/pathP.h * app/tools/gimpbezierselecttool.h * app/tools/gimpcolorbalancetool.h * app/tools/gimpcurvestool.h * app/tools/gimpdodgeburntool.c * app/tools/gimpfreeselecttool.h * app/tools/gimphuesaturationtool.h * app/tools/gimpinktool-blob.h * app/tools/gimpinktool.h * app/tools/gimpiscissorstool.h * app/tools/gimpmagnifytool.h * app/tools/gimpmeasuretool.h * app/tools/gimppainttool.h * app/tools/gimppathtool.h * app/tools/gimprectselecttool.h * app/tools/gimpthresholdtool.h * app/tools/gimptool.h * app/tools/gimptransformtool.h * app/base/base-config.h * app/base/gimplut.[ch] * app/base/pixel-region.h * app/base/pixel-surround.[ch] * app/base/temp-buf.[ch] * app/base/tile-manager-private.h * app/base/tile-manager.[ch] * app/base/tile-private.h * app/base/tile.[ch] * app/display/gimpdisplay.h * app/display/gimpdisplayshell-selection.h * app/display/gimpdisplayshell.h * app/gui/brush-select.h * app/gui/gradient-editor.h * app/gui/gradient-select.h: reverted most of Daniel's changes. There's no reason to use unsigned integers here and in lots of places it is even wrong. Then it's way too early to convert gbooleans into bitfields. This change may make sense in a few places but can happen later when the API has settled and the code is more stable. * app/gimprc.c: reverted Daniel's change. This is a GCC-ism and this code is about to die soon anyway.
2001-12-03 21:44:59 +08:00
gint height)
1997-11-25 06:05:25 +08:00
{
static guchar empty = 0;
1997-11-25 06:05:25 +08:00
return temp_buf_new (width, height, 1, 0, 0, &empty);
1997-11-25 06:05:25 +08:00
}
void
1999-07-20 03:46:05 +08:00
mask_buf_free (MaskBuf *mask)
1997-11-25 06:05:25 +08:00
{
temp_buf_free ((TempBuf *) mask);
}
guchar *
1999-07-20 03:46:05 +08:00
mask_buf_data (MaskBuf *mask_buf)
1997-11-25 06:05:25 +08:00
{
return temp_buf_data ((TempBuf *) mask_buf);
1997-11-25 06:05:25 +08:00
}
guchar *
mask_buf_data_clear (MaskBuf *mask_buf)
{
return temp_buf_data_clear ((TempBuf *) mask_buf);
}