1998-06-30 23:31:32 +08:00
|
|
|
|
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
|
1998-04-13 13:44:11 +08:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
1998-01-22 15:02:57 +08:00
|
|
|
|
1998-06-30 23:31:32 +08:00
|
|
|
#include "drawable.h"
|
1998-01-22 15:02:57 +08:00
|
|
|
#include "drawable_pvt.h"
|
1998-06-30 23:31:32 +08:00
|
|
|
#include "palette.h"
|
|
|
|
#include "gimpimageF.h"
|
|
|
|
#include "gdisplay.h"
|
1998-07-02 07:06:49 +08:00
|
|
|
#include "undo.h"
|
1998-01-22 15:02:57 +08:00
|
|
|
|
1998-12-16 08:37:09 +08:00
|
|
|
#include "libgimp/gimpintl.h"
|
|
|
|
|
1998-01-22 15:02:57 +08:00
|
|
|
int
|
|
|
|
drawable_ID (GimpDrawable *drawable)
|
|
|
|
{
|
1998-12-16 19:23:30 +08:00
|
|
|
if (drawable)
|
|
|
|
return drawable->ID;
|
|
|
|
else
|
|
|
|
g_warning("drawable_ID called on a NULL pointer");
|
|
|
|
return 0;
|
1998-01-22 15:02:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1998-06-30 23:31:32 +08:00
|
|
|
drawable_fill (GimpDrawable *drawable, int fill_type){
|
|
|
|
guchar r,g,b,a;
|
|
|
|
a=255;
|
|
|
|
switch(fill_type){
|
1998-07-29 03:26:36 +08:00
|
|
|
case FOREGROUND_FILL:
|
|
|
|
palette_get_foreground(&r, &g, &b);
|
|
|
|
break;
|
|
|
|
|
1998-06-30 23:31:32 +08:00
|
|
|
case BACKGROUND_FILL:
|
1998-07-29 03:26:36 +08:00
|
|
|
palette_get_background(&r, &g, &b);
|
|
|
|
break;
|
|
|
|
|
1998-06-30 23:31:32 +08:00
|
|
|
case WHITE_FILL:
|
1998-07-29 03:26:36 +08:00
|
|
|
r=g=b=255;
|
|
|
|
break;
|
|
|
|
|
1998-06-30 23:31:32 +08:00
|
|
|
case TRANSPARENT_FILL:
|
1998-07-29 03:26:36 +08:00
|
|
|
a=r=g=b=0;
|
|
|
|
break;
|
|
|
|
|
1998-06-30 23:31:32 +08:00
|
|
|
case NO_FILL:
|
1998-07-29 03:26:36 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
default:
|
1998-12-16 08:37:09 +08:00
|
|
|
g_warning (_("drawable_fill called with unknown fill type"));
|
1998-07-29 03:26:36 +08:00
|
|
|
a=r=g=b=0;
|
|
|
|
break;
|
1998-06-30 23:31:32 +08:00
|
|
|
}
|
|
|
|
gimp_drawable_fill(drawable,r,g,b,a);
|
1998-09-27 04:07:46 +08:00
|
|
|
|
1998-06-30 23:31:32 +08:00
|
|
|
drawable_update (drawable, 0, 0,
|
|
|
|
gimp_drawable_width (drawable),
|
|
|
|
gimp_drawable_height (drawable));
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1998-01-22 15:02:57 +08:00
|
|
|
drawable_update (GimpDrawable *drawable, int x, int y, int w, int h)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1998-06-30 23:31:32 +08:00
|
|
|
GimpImage *gimage;
|
1997-11-25 06:05:25 +08:00
|
|
|
int offset_x, offset_y;
|
|
|
|
|
1998-01-22 15:02:57 +08:00
|
|
|
if (! drawable)
|
1997-11-25 06:05:25 +08:00
|
|
|
return;
|
|
|
|
|
1998-06-30 23:31:32 +08:00
|
|
|
if (! (gimage = gimp_drawable_gimage (drawable)))
|
1998-01-22 15:02:57 +08:00
|
|
|
return;
|
|
|
|
|
1998-06-30 23:31:32 +08:00
|
|
|
gimp_drawable_offsets (drawable, &offset_x, &offset_y);
|
1997-11-25 06:05:25 +08:00
|
|
|
x += offset_x;
|
|
|
|
y += offset_y;
|
1998-06-29 08:24:44 +08:00
|
|
|
gdisplays_update_area (gimage, x, y, w, h);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* invalidate the preview */
|
1998-06-30 23:31:32 +08:00
|
|
|
gimp_drawable_invalidate_preview (drawable);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
1998-07-02 07:06:49 +08:00
|
|
|
|
|
|
|
void
|
|
|
|
drawable_apply_image (GimpDrawable *drawable,
|
|
|
|
int x1, int y1, int x2, int y2,
|
|
|
|
TileManager *tiles, int sparse)
|
|
|
|
{
|
|
|
|
if (drawable)
|
|
|
|
{
|
|
|
|
if (! tiles)
|
|
|
|
undo_push_image (drawable->gimage, drawable,
|
|
|
|
x1, y1, x2, y2);
|
|
|
|
else
|
|
|
|
undo_push_image_mod (drawable->gimage, drawable,
|
|
|
|
x1, y1, x2, y2, tiles, sparse);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|