Commit 48bf4fb7 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

don't scale the preview up if the buffer is too small.

2003-03-01  Michael Natterer  <mitch@gimp.org>

	* app/core/gimpbuffer.c: don't scale the preview up if the
	buffer is too small.

	* app/core/gimppattern.c: don't add a white border around the
	preview if the pattern is too small.

	* app/widgets/gimppreviewrenderer.[ch]: new object. A buffer
	that updates itself on GimpViewable changes and can render
	itself to any widget. Basically GimpPreview reduced to the
	render and draw code.

	* app/widgets/gimppreview.[ch]: removed all rendering and drawing
	code and keep a GimpPreviewRenderer instance. Connect to its
	"update" signal for queuing draws on the preview.

	* app/widgets/gimpcellrendererviewable.[ch]
	* app/widgets/gimpcontainertreeview.c: same here: removed
	rendering and drawing code and keep GimpPreviewRenderers in the
	list store.  Delays preview creation for GtkTreeViews until the
	buffer is really needed for drawing and adds idle preview updating
	on viewable changes.

	* app/widgets/gimppreview-utils.[ch]
	* app/widgets/gimpbrushpreview.[ch]
	* app/widgets/gimpbufferpreview.[ch]
	* app/widgets/gimpdrawablepreview.[ch]
	* app/widgets/gimpimagepreview.[ch]: removed...

	* app/widgets/gimppreviewrenderer-utils.[ch]
	* app/widgets/gimppreviewrendererbrush.[ch]
	* app/widgets/gimppreviewrendererdrawable.[ch]
	* app/widgets/gimppreviewrendererimage.[ch]: ...and converted to
	GimpPreviewRenderer subclasses.

	* app/display/gimpnavigationview.c
	* app/gui/palette-import-dialog.c
	* app/widgets/Makefile.am
	* app/widgets/widgets-enums.h
	* app/widgets/widgets-types.h
	* app/widgets/gimpchannellistview.c
	* app/widgets/gimpcomponentlistitem.c
	* app/widgets/gimpcontainergridview.c
	* app/widgets/gimpcontainermenuimpl.c
	* app/widgets/gimplayerlistitem.c
	* app/widgets/gimplistitem.c
	* app/widgets/gimpnavigationpreview.[ch]
	* app/widgets/gimpselectioneditor.c
	* app/widgets/gimpvectorslistview.c: changed accordingly.
parent 9525f64c
2003-03-01 Michael Natterer <mitch@gimp.org>
* app/core/gimpbuffer.c: don't scale the preview up if the
buffer is too small.
* app/core/gimppattern.c: don't add a white border around the
preview if the pattern is too small.
* app/widgets/gimppreviewrenderer.[ch]: new object. A buffer
that updates itself on GimpViewable changes and can render
itself to any widget. Basically GimpPreview reduced to the
render and draw code.
* app/widgets/gimppreview.[ch]: removed all rendering and drawing
code and keep a GimpPreviewRenderer instance. Connect to its
"update" signal for queuing draws on the preview.
* app/widgets/gimpcellrendererviewable.[ch]
* app/widgets/gimpcontainertreeview.c: same here: removed
rendering and drawing code and keep GimpPreviewRenderers in the
list store. Delays preview creation for GtkTreeViews until the
buffer is really needed for drawing and adds idle preview updating
on viewable changes.
* app/widgets/gimppreview-utils.[ch]
* app/widgets/gimpbrushpreview.[ch]
* app/widgets/gimpbufferpreview.[ch]
* app/widgets/gimpdrawablepreview.[ch]
* app/widgets/gimpimagepreview.[ch]: removed...
* app/widgets/gimppreviewrenderer-utils.[ch]
* app/widgets/gimppreviewrendererbrush.[ch]
* app/widgets/gimppreviewrendererdrawable.[ch]
* app/widgets/gimppreviewrendererimage.[ch]: ...and converted to
GimpPreviewRenderer subclasses.
* app/display/gimpnavigationview.c
* app/gui/palette-import-dialog.c
* app/widgets/Makefile.am
* app/widgets/widgets-enums.h
* app/widgets/widgets-types.h
* app/widgets/gimpchannellistview.c
* app/widgets/gimpcomponentlistitem.c
* app/widgets/gimpcontainergridview.c
* app/widgets/gimpcontainermenuimpl.c
* app/widgets/gimplayerlistitem.c
* app/widgets/gimplistitem.c
* app/widgets/gimpnavigationpreview.[ch]
* app/widgets/gimpselectioneditor.c
* app/widgets/gimpvectorslistview.c: changed accordingly.
2003-03-01 Michael Natterer <mitch@gimp.org>
* app/tools/gimpblendtool.c: removed useless includes.
......@@ -225,7 +225,6 @@ gimp_buffer_get_new_preview (GimpViewable *viewable,
PixelRegion srcPR;
PixelRegion destPR;
gint bytes;
gint subsample;
buffer = GIMP_BUFFER (viewable);
buffer_width = tile_manager_width (buffer->tiles);
......@@ -233,30 +232,48 @@ gimp_buffer_get_new_preview (GimpViewable *viewable,
bytes = tile_manager_bpp (buffer->tiles);
/* calculate 'acceptable' subsample */
subsample = 1;
while ((width * (subsample + 1) * 2 < buffer_width) &&
(height * (subsample + 1) * 2 < buffer_height))
subsample += 1;
pixel_region_init (&srcPR, buffer->tiles,
0, 0,
buffer_width,
buffer_height,
FALSE);
temp_buf = temp_buf_new (width, height, bytes, 0, 0, NULL);
if (buffer_height > height || buffer_width > width)
temp_buf = temp_buf_new (width, height, bytes, 0, 0, NULL);
else
temp_buf = temp_buf_new (buffer_width, buffer_height, bytes, 0, 0, NULL);
destPR.bytes = temp_buf->bytes;
destPR.x = 0;
destPR.y = 0;
destPR.w = width;
destPR.h = height;
destPR.rowstride = width * destPR.bytes;
destPR.w = temp_buf->width;
destPR.h = temp_buf->height;
destPR.rowstride = temp_buf->width * destPR.bytes;
destPR.data = temp_buf_data (temp_buf);
subsample_region (&srcPR, &destPR, subsample);
if (buffer_height > height || buffer_width > width)
{
gint subsample;
/* calculate 'acceptable' subsample */
subsample = 1;
while ((width * (subsample + 1) * 2 < buffer_width) &&
(height * (subsample + 1) * 2 < buffer_height))
subsample += 1;
subsample_region (&srcPR, &destPR, subsample);
}
else
{
copy_region (&srcPR, &destPR);
}
if (buffer_width < width)
temp_buf->x = (width - buffer_width) / 2;
if (buffer_height < height)
temp_buf->y = (height - buffer_height) / 2;
return temp_buf;
}
......
......@@ -198,28 +198,26 @@ gimp_pattern_get_new_preview (GimpViewable *viewable,
{
GimpPattern *pattern;
TempBuf *temp_buf;
guchar white[MAX_CHANNELS] = { 255, 255, 255, 255 };
gint copy_width;
gint copy_height;
gint x, y;
pattern = GIMP_PATTERN (viewable);
copy_width = MIN (width, pattern->mask->width);
copy_height = MIN (height, pattern->mask->height);
x = (copy_width == width) ? 0 : (width - copy_width) / 2;
y = (copy_height == height) ? 0 : (height - copy_height) / 2;
temp_buf = temp_buf_new (width, height,
temp_buf = temp_buf_new (copy_width, copy_height,
pattern->mask->bytes,
0, 0,
white);
0, 0, NULL);
temp_buf_copy_area (pattern->mask, temp_buf,
0, 0,
copy_width, copy_height,
x, y);
0, 0, copy_width, copy_height, 0, 0);
if (width > copy_width)
temp_buf->x = (width - copy_width) / 2;
if (height > copy_height)
temp_buf->y = (height - copy_height) / 2;
return temp_buf;
}
......
......@@ -198,28 +198,26 @@ gimp_pattern_get_new_preview (GimpViewable *viewable,
{
GimpPattern *pattern;
TempBuf *temp_buf;
guchar white[MAX_CHANNELS] = { 255, 255, 255, 255 };
gint copy_width;
gint copy_height;
gint x, y;
pattern = GIMP_PATTERN (viewable);
copy_width = MIN (width, pattern->mask->width);
copy_height = MIN (height, pattern->mask->height);
x = (copy_width == width) ? 0 : (width - copy_width) / 2;
y = (copy_height == height) ? 0 : (height - copy_height) / 2;
temp_buf = temp_buf_new (width, height,
temp_buf = temp_buf_new (copy_width, copy_height,
pattern->mask->bytes,
0, 0,
white);
0, 0, NULL);
temp_buf_copy_area (pattern->mask, temp_buf,
0, 0,
copy_width, copy_height,
x, y);
0, 0, copy_width, copy_height, 0, 0);
if (width > copy_width)
temp_buf->x = (width - copy_width) / 2;
if (height > copy_height)
temp_buf->y = (height - copy_height) / 2;
return temp_buf;
}
......
......@@ -40,6 +40,7 @@
#include "widgets/gimpcontainermenuimpl.h"
#include "widgets/gimpdnd.h"
#include "widgets/gimppreview.h"
#include "widgets/gimppreviewrenderer.h"
#include "widgets/gimpviewabledialog.h"
#include "gradient-select.h"
......@@ -351,7 +352,7 @@ palette_import_dialog_new (Gimp *gimp)
import_dialog->preview = gimp_preview_new_by_type (GIMP_TYPE_PALETTE,
64, 1,
TRUE);
GIMP_PREVIEW (import_dialog->preview)->size = -1;
GIMP_PREVIEW (import_dialog->preview)->renderer->size = -1;
gimp_preview_set_size_full (GIMP_PREVIEW (import_dialog->preview),
192, 192, 1);
gtk_container_add (GTK_CONTAINER (abox), import_dialog->preview);
......
......@@ -37,6 +37,7 @@
#include "core/gimpimage.h"
#include "widgets/gimpnavigationpreview.h"
#include "widgets/gimppreviewrenderer.h"
#include "gimpdisplay.h"
#include "gimpdisplayshell.h"
......@@ -322,10 +323,10 @@ gimp_navigation_view_popup (GimpDisplayShell *shell,
* Warping the pointer would be another solution ...
*/
x = CLAMP (x, 0, (gdk_screen_width () -
GIMP_PREVIEW (preview)->width -
GIMP_PREVIEW (preview)->renderer->width -
4 * widget->style->xthickness));
y = CLAMP (y, 0, (gdk_screen_height () -
GIMP_PREVIEW (preview)->height -
GIMP_PREVIEW (preview)->renderer->height -
4 * widget->style->ythickness));
gtk_window_move (GTK_WINDOW (shell->nav_popup), x, y);
......@@ -366,7 +367,7 @@ gimp_navigation_view_new_private (GimpDisplayShell *shell,
gimp_preview_set_size (preview,
config->nav_preview_size * 3,
preview->border_width);
preview->renderer->border_width);
}
else
{
......@@ -478,10 +479,10 @@ gimp_navigation_view_abox_resized (GtkWidget *widget,
if (! preview->viewable)
return;
if (preview->width > allocation->width ||
preview->height > allocation->height ||
(preview->width != allocation->width &&
preview->height != allocation->height))
if (preview->renderer->width > allocation->width ||
preview->renderer->height > allocation->height ||
(preview->renderer->width != allocation->width &&
preview->renderer->height != allocation->height))
{
GimpNavigationPreview *nav_preview;
GimpImage *gimage;
......@@ -498,7 +499,7 @@ gimp_navigation_view_abox_resized (GtkWidget *widget,
GIMP_PREVIEW_MAX_SIZE),
MIN (allocation->height,
GIMP_PREVIEW_MAX_SIZE),
preview->dot_for_dot,
preview->renderer->dot_for_dot,
gimage->xresolution,
gimage->yresolution,
&width,
......@@ -516,8 +517,8 @@ gimp_navigation_view_abox_resized (GtkWidget *widget,
height = height * allocation->height / height;
}
gimp_preview_set_size_full (preview,
width, height, preview->border_width);
gimp_preview_set_size_full (preview, width, height,
preview->renderer->border_width);
/* FIXME: the GimpNavigationPreview should handle this stuff itself */
......@@ -745,7 +746,8 @@ gimp_navigation_view_update_marker (GimpNavigationView *view)
xratio = SCALEFACTOR_X (view->shell);
yratio = SCALEFACTOR_Y (view->shell);
if (GIMP_PREVIEW (view->preview)->dot_for_dot != view->shell->dot_for_dot)
if (GIMP_PREVIEW (view->preview)->renderer->dot_for_dot !=
view->shell->dot_for_dot)
gimp_preview_set_dot_for_dot (GIMP_PREVIEW (view->preview),
view->shell->dot_for_dot);
......
......@@ -37,6 +37,7 @@
#include "core/gimpimage.h"
#include "widgets/gimpnavigationpreview.h"
#include "widgets/gimppreviewrenderer.h"
#include "gimpdisplay.h"
#include "gimpdisplayshell.h"
......@@ -322,10 +323,10 @@ gimp_navigation_view_popup (GimpDisplayShell *shell,
* Warping the pointer would be another solution ...
*/
x = CLAMP (x, 0, (gdk_screen_width () -
GIMP_PREVIEW (preview)->width -
GIMP_PREVIEW (preview)->renderer->width -
4 * widget->style->xthickness));
y = CLAMP (y, 0, (gdk_screen_height () -
GIMP_PREVIEW (preview)->height -
GIMP_PREVIEW (preview)->renderer->height -
4 * widget->style->ythickness));
gtk_window_move (GTK_WINDOW (shell->nav_popup), x, y);
......@@ -366,7 +367,7 @@ gimp_navigation_view_new_private (GimpDisplayShell *shell,
gimp_preview_set_size (preview,
config->nav_preview_size * 3,
preview->border_width);
preview->renderer->border_width);
}
else
{
......@@ -478,10 +479,10 @@ gimp_navigation_view_abox_resized (GtkWidget *widget,
if (! preview->viewable)
return;
if (preview->width > allocation->width ||
preview->height > allocation->height ||
(preview->width != allocation->width &&
preview->height != allocation->height))
if (preview->renderer->width > allocation->width ||
preview->renderer->height > allocation->height ||
(preview->renderer->width != allocation->width &&
preview->renderer->height != allocation->height))
{
GimpNavigationPreview *nav_preview;
GimpImage *gimage;
......@@ -498,7 +499,7 @@ gimp_navigation_view_abox_resized (GtkWidget *widget,
GIMP_PREVIEW_MAX_SIZE),
MIN (allocation->height,
GIMP_PREVIEW_MAX_SIZE),
preview->dot_for_dot,
preview->renderer->dot_for_dot,
gimage->xresolution,
gimage->yresolution,
&width,
......@@ -516,8 +517,8 @@ gimp_navigation_view_abox_resized (GtkWidget *widget,
height = height * allocation->height / height;
}
gimp_preview_set_size_full (preview,
width, height, preview->border_width);
gimp_preview_set_size_full (preview, width, height,
preview->renderer->border_width);
/* FIXME: the GimpNavigationPreview should handle this stuff itself */
......@@ -745,7 +746,8 @@ gimp_navigation_view_update_marker (GimpNavigationView *view)
xratio = SCALEFACTOR_X (view->shell);
yratio = SCALEFACTOR_Y (view->shell);
if (GIMP_PREVIEW (view->preview)->dot_for_dot != view->shell->dot_for_dot)
if (GIMP_PREVIEW (view->preview)->renderer->dot_for_dot !=
view->shell->dot_for_dot)
gimp_preview_set_dot_for_dot (GIMP_PREVIEW (view->preview),
view->shell->dot_for_dot);
......
......@@ -40,6 +40,7 @@
#include "widgets/gimpcontainermenuimpl.h"
#include "widgets/gimpdnd.h"
#include "widgets/gimppreview.h"
#include "widgets/gimppreviewrenderer.h"
#include "widgets/gimpviewabledialog.h"
#include "gradient-select.h"
......@@ -351,7 +352,7 @@ palette_import_dialog_new (Gimp *gimp)
import_dialog->preview = gimp_preview_new_by_type (GIMP_TYPE_PALETTE,
64, 1,
TRUE);
GIMP_PREVIEW (import_dialog->preview)->size = -1;
GIMP_PREVIEW (import_dialog->preview)->renderer->size = -1;
gimp_preview_set_size_full (GIMP_PREVIEW (import_dialog->preview),
192, 192, 1);
gtk_container_add (GTK_CONTAINER (abox), import_dialog->preview);
......
......@@ -23,10 +23,6 @@ libappwidgets_a_sources = \
gimpbrusheditor.h \
gimpbrushfactoryview.c \
gimpbrushfactoryview.h \
gimpbrushpreview.c \
gimpbrushpreview.h \
gimpbufferpreview.c \
gimpbufferpreview.h \
gimpbufferview.c \
gimpbufferview.h \
gimpcellrendererviewable.c \
......@@ -85,8 +81,6 @@ libappwidgets_a_sources = \
gimpdrawablelistitem.h \
gimpdrawablelistview.c \
gimpdrawablelistview.h \
gimpdrawablepreview.c \
gimpdrawablepreview.h \
gimpeditor.c \
gimpeditor.h \
gimpenummenu.c \
......@@ -107,8 +101,6 @@ libappwidgets_a_sources = \
gimpimagedock.h \
gimpimageeditor.c \
gimpimageeditor.h \
gimpimagepreview.c \
gimpimagepreview.h \
gimpimageview.c \
gimpimageview.h \
gimpitemfactory.c \
......@@ -135,8 +127,16 @@ libappwidgets_a_sources = \
gimppreview.h \
gimppreview-popup.c \
gimppreview-popup.h \
gimppreview-utils.c \
gimppreview-utils.h \
gimppreviewrenderer.c \
gimppreviewrenderer.h \
gimppreviewrenderer-utils.c \
gimppreviewrenderer-utils.h \
gimppreviewrendererbrush.c \
gimppreviewrendererbrush.h \
gimppreviewrendererdrawable.c \
gimppreviewrendererdrawable.h \
gimppreviewrendererimage.c \
gimppreviewrendererimage.h \
gimppropwidgets.c \
gimppropwidgets.h \
gimpselectioneditor.c \
......
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpbrushpreview.c
* Copyright (C) 2001 Michael Natterer <mitch@gimp.org>
*
* 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.
*/
#include "config.h"
#include <gtk/gtk.h>
#include "widgets-types.h"
#include "base/temp-buf.h"
#include "core/gimpbrush.h"
#include "core/gimpbrushpipe.h"
#include "gimpbrushpreview.h"
#include "gimpdnd.h"
static void gimp_brush_preview_class_init (GimpBrushPreviewClass *klass);
static void gimp_brush_preview_init (GimpBrushPreview *preview);
static void gimp_brush_preview_destroy (GtkObject *object);
static void gimp_brush_preview_render (GimpPreview *preview);
static gboolean gimp_brush_preview_render_timeout (gpointer data);
static GimpPreviewClass *parent_class = NULL;
GType
gimp_brush_preview_get_type (void)
{
static GType preview_type = 0;
if (! preview_type)
{
static const GTypeInfo preview_info =
{
sizeof (GimpBrushPreviewClass),
NULL, /* base_init */
NULL, /* base_finalize */
(GClassInitFunc) gimp_brush_preview_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpBrushPreview),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_brush_preview_init,
};
preview_type = g_type_register_static (GIMP_TYPE_PREVIEW,
"GimpBrushPreview",
&preview_info, 0);
}
return preview_type;
}
static void
gimp_brush_preview_class_init (GimpBrushPreviewClass *klass)
{
GtkObjectClass *object_class;
GimpPreviewClass *preview_class;
object_class = GTK_OBJECT_CLASS (klass);
preview_class = GIMP_PREVIEW_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->destroy = gimp_brush_preview_destroy;
preview_class->render = gimp_brush_preview_render;
}
static void
gimp_brush_preview_init (GimpBrushPreview *brush_preview)
{
brush_preview->pipe_timeout_id = 0;
brush_preview->pipe_animation_index = 0;
}
static void
gimp_brush_preview_destroy (GtkObject *object)
{
GimpBrushPreview *brush_preview;
brush_preview = GIMP_BRUSH_PREVIEW (object);
if (brush_preview->pipe_timeout_id)
{
g_source_remove (brush_preview->pipe_timeout_id);
brush_preview->pipe_timeout_id = 0;
brush_preview->pipe_animation_index = 0;
}
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
static void
gimp_brush_preview_render (GimpPreview *preview)
{
GimpBrushPreview *brush_preview;
GimpBrush *brush;
TempBuf *temp_buf;
gint width;
gint height;
gint brush_width;
gint brush_height;
brush_preview = GIMP_BRUSH_PREVIEW (preview);
if (brush_preview->pipe_timeout_id)
{
g_source_remove (brush_preview->pipe_timeout_id);
brush_preview->pipe_timeout_id = 0;
}
brush = GIMP_BRUSH (preview->viewable);
brush_width = brush->mask->width;
brush_height = brush->mask->height;
width = preview->width;
height = preview->height;
temp_buf = gimp_viewable_get_new_preview (preview->viewable,
width, height);
if (temp_buf->width < width)
temp_buf->x = (width - temp_buf->width) / 2;
if (temp_buf->height < height)
temp_buf->y = (height - temp_buf->height) / 2;
if (preview->is_popup)
{
gimp_preview_render_preview (preview, temp_buf, -1,
GIMP_PREVIEW_BG_WHITE,
GIMP_PREVIEW_BG_WHITE);
temp_buf_free (temp_buf);
if (GIMP_IS_BRUSH_PIPE (brush))
{
if (width != brush_width || height != brush_height)
{
g_warning ("%s(): non-fullsize pipe popups are not supported yet.",
G_GNUC_FUNCTION);
return;
}
brush_preview->pipe_animation_index = 0;
brush_preview->pipe_timeout_id =
g_timeout_add (300, gimp_brush_preview_render_timeout,
brush_preview);
}
return;
}
#define INDICATOR_WIDTH 7
#define INDICATOR_HEIGHT 7
if (temp_buf->width >= INDICATOR_WIDTH &&
temp_buf->height >= INDICATOR_HEIGHT &&
(width < brush_width ||
height < brush_height ||
GIMP_IS_BRUSH_PIPE (brush)))
{
#define WHT { 255, 255, 255 }
#define BLK { 0, 0, 0 }
#define RED { 255, 127, 127 }
static const guchar scale_indicator_bits[7][7][3] =
{
{ WHT, WHT, WHT, WHT, WHT, WHT, WHT },
{ WHT, WHT, WHT, BLK, WHT, WHT, WHT },
{ WHT, WHT, WHT, BLK, WHT, WHT, WHT },
{ WHT, BLK, BLK, BLK, BLK, BLK, WHT },
{ WHT, WHT, WHT, BLK, WHT, WHT, WHT },
{ WHT, WHT, WHT, BLK, WHT, WHT, WHT },
{ WHT, WHT, WHT, WHT, WHT, WHT, WHT }
};
static const guchar scale_pipe_indicator_bits[7][7][3] =
{
{ WHT, WHT, WHT, WHT, WHT, WHT, WHT },
{ WHT, WHT, WHT, BLK, WHT, WHT, RED },
{ WHT, WHT, WHT, BLK, WHT, RED, RED },
{ WHT, BLK, BLK, BLK, BLK, BLK, RED },
{ WHT, WHT, WHT, BLK, RED, RED, RED },
{ WHT, WHT, RED, BLK, RED, RED, RED },
{ WHT, RED, RED, RED, RED, RED, RED }
};
static const guchar pipe_indicator_bits[7][7][3] =
{
{ WHT, WHT, WHT, WHT, WHT, WHT, WHT },
{ WHT, WHT, WHT, WHT, WHT, WHT, RED },
{ WHT, WHT, WHT, WHT, WHT, RED, RED },
{ WHT, WHT, WHT, WHT, RED, RED, RED },
{ WHT, WHT, WHT, RED, RED, RED, RED },
{ WHT, WHT, RED, RED, RED, RED, RED },
{ WHT, RED, RED, RED, RED, RED, RED }
};
#undef WHT
#undef BLK
#undef RED
guchar *buf;
gint x, y;
gint offset_x;
gint offset_y;
gboolean alpha;
gboolean pipe;
gboolean scale;
buf = temp_buf_data (temp_buf);
offset_x = temp_buf->width - INDICATOR_WIDTH;
offset_y = temp_buf->height - INDICATOR_HEIGHT;
buf += (offset_y * temp_buf->width + offset_x) * temp_buf->bytes;
pipe = GIMP_IS_BRUSH_PIPE (brush);
scale = (width < brush_width || height < brush_height);
alpha = (temp_buf->bytes == 4);
for (y = 0; y < INDICATOR_HEIGHT; y++)
{
for (x = 0; x < INDICATOR_WIDTH; x++)
{
if (scale)
{
if (pipe)
{
*buf++ = scale_pipe_indicator_bits[y][x][0];
*buf++ = scale_pipe_indicator_bits[y][x][1];
*buf++ = scale_pipe_indicator_bits[y][x][2];
}
else
{
*buf++ = scale_indicator_bits[y][x][0];
*buf++ = scale_indicator_bits[y][x][1];
*buf++ = scale_indicator_bits[y][x][2];
}
}
else if (pipe)
{
*buf++ = pipe_indicator_bits[y][x][0];