mirror of https://github.com/GNOME/gimp.git
Fixed up loose ends with the GdkRgb integration. Color selection areas are
dithered now, and dither patterns align correctly when scrolling.
This commit is contained in:
parent
401df1a726
commit
fe6c43af7c
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
|||
Mon Aug 31 15:15:01 1998 Raph Levien <raph@gimp.org>
|
||||
|
||||
* app/color_select.c (color_select_update_colors): made it use the
|
||||
color_area rectangle draw so it dithers.
|
||||
|
||||
* app/color_area.[ch] (color_area_draw_rect): made it draw the color
|
||||
rectangle with gdkrgb (so it gets dithered) rather than the
|
||||
rectangle drawing primitive.
|
||||
|
||||
* app/gximage.[ch] (gximage_put): made it align dithers
|
||||
|
||||
* app/gdisplay.c (gdisplay_display_area): made it so that the
|
||||
gximage_put routine gets dither alignment values
|
||||
|
||||
Mon Aug 31 16:51:35 CDT 1998 Larry Ewing <lewing@gimp.org>
|
||||
|
||||
* app/internal_procs.c: included in merge down changes
|
||||
|
|
|
@ -73,6 +73,45 @@ color_area_target (int x,
|
|||
return -1;
|
||||
}
|
||||
|
||||
void
|
||||
color_area_draw_rect (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
gint x, gint y, gint width, gint height,
|
||||
unsigned char r, unsigned char g, unsigned char b)
|
||||
{
|
||||
static unsigned char *color_area_rgb_buf = NULL;
|
||||
static gint color_area_rgb_buf_size;
|
||||
static gint rowstride;
|
||||
gint xx, yy;
|
||||
unsigned char *bp;
|
||||
|
||||
rowstride = 3 * ((width + 3) & -4);
|
||||
if (color_area_rgb_buf == NULL ||
|
||||
color_area_rgb_buf_size < height * rowstride)
|
||||
{
|
||||
if (color_area_rgb_buf)
|
||||
g_free (color_area_rgb_buf);
|
||||
color_area_rgb_buf = g_malloc (rowstride * height);
|
||||
}
|
||||
bp = color_area_rgb_buf;
|
||||
for (xx = 0; xx < width; xx++)
|
||||
{
|
||||
*bp++ = r;
|
||||
*bp++ = g;
|
||||
*bp++ = b;
|
||||
}
|
||||
bp = color_area_rgb_buf;
|
||||
for (yy = 1; yy < height; yy++)
|
||||
{
|
||||
bp += rowstride;
|
||||
memcpy (bp, color_area_rgb_buf, rowstride);
|
||||
}
|
||||
gdk_draw_rgb_image (drawable, gc, x, y, width, height,
|
||||
GDK_RGB_DITHER_MAX,
|
||||
color_area_rgb_buf,
|
||||
rowstride);
|
||||
}
|
||||
|
||||
static void
|
||||
color_area_draw (void)
|
||||
{
|
||||
|
@ -82,6 +121,7 @@ color_area_draw (void)
|
|||
int width, height;
|
||||
int def_width, def_height;
|
||||
int swap_width, swap_height;
|
||||
unsigned char r, g, b;
|
||||
|
||||
/* Check we haven't gotten initial expose yet,
|
||||
* no point in drawing anything */
|
||||
|
@ -102,9 +142,16 @@ color_area_draw (void)
|
|||
gdk_draw_rectangle (color_area_pixmap, color_area_gc, 1,
|
||||
0, 0, width, height);
|
||||
|
||||
#ifdef OLD_COLOR_AREA
|
||||
gdk_gc_set_foreground (color_area_gc, &bg);
|
||||
gdk_draw_rectangle (color_area_pixmap, color_area_gc, 1,
|
||||
(width - rect_w), (height - rect_h), rect_w, rect_h);
|
||||
#else
|
||||
palette_get_background (&r, &g, &b);
|
||||
color_area_draw_rect (color_area_pixmap, color_area_gc,
|
||||
(width - rect_w), (height - rect_h), rect_w, rect_h,
|
||||
r, g, b);
|
||||
#endif
|
||||
|
||||
if (active_color == FOREGROUND)
|
||||
gtk_draw_shadow (color_area->style, color_area_pixmap, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
|
||||
|
@ -113,9 +160,16 @@ color_area_draw (void)
|
|||
gtk_draw_shadow (color_area->style, color_area_pixmap, GTK_STATE_NORMAL, GTK_SHADOW_IN,
|
||||
(width - rect_w), (height - rect_h), rect_w, rect_h);
|
||||
|
||||
#ifdef OLD_COLOR_AREA
|
||||
gdk_gc_set_foreground (color_area_gc, &fg);
|
||||
gdk_draw_rectangle (color_area_pixmap, color_area_gc, 1,
|
||||
0, 0, rect_w, rect_h);
|
||||
#else
|
||||
palette_get_foreground (&r, &g, &b);
|
||||
color_area_draw_rect (color_area_pixmap, color_area_gc,
|
||||
0, 0, rect_w, rect_h,
|
||||
r, g, b);
|
||||
#endif
|
||||
|
||||
if (active_color == FOREGROUND)
|
||||
gtk_draw_shadow (color_area->style, color_area_pixmap, GTK_STATE_NORMAL, GTK_SHADOW_IN,
|
||||
|
|
|
@ -28,9 +28,17 @@ GtkWidget * color_area_create (int width,
|
|||
GdkPixmap *swap_pixmap);
|
||||
void color_area_update (void);
|
||||
|
||||
/* Exported for use by color_select */
|
||||
void
|
||||
color_area_draw_rect (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
gint x, gint y, gint width, gint height,
|
||||
unsigned char r, unsigned char g, unsigned char b);
|
||||
|
||||
/*
|
||||
* Global variables
|
||||
*/
|
||||
extern int active_color; /* foreground (= 0) or background (= 1) */
|
||||
|
||||
|
||||
#endif /* __COLOR_AREA_H__ */
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "errors.h"
|
||||
#include "gimprc.h"
|
||||
#include "session.h"
|
||||
#include "color_area.h" /* for color_area_draw_rect */
|
||||
|
||||
#define XY_DEF_WIDTH 240
|
||||
#define XY_DEF_HEIGHT 240
|
||||
|
@ -787,9 +788,15 @@ color_select_update_colors (ColorSelectP csp,
|
|||
|
||||
if (csp->gc)
|
||||
{
|
||||
#ifdef OLD_COLOR_AREA
|
||||
gdk_gc_set_foreground (csp->gc, &color);
|
||||
gdk_draw_rectangle (window, csp->gc, 1,
|
||||
0, 0, width, height);
|
||||
#else
|
||||
color_area_draw_rect (window, csp->gc,
|
||||
0, 0, width, height,
|
||||
red, green, blue);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -844,7 +844,9 @@ gdisplay_display_area (GDisplay *gdisp,
|
|||
dy = (y2 - i < GXIMAGE_HEIGHT) ? y2 - i : GXIMAGE_HEIGHT;
|
||||
render_image (gdisp, j - gdisp->disp_xoffset, i - gdisp->disp_yoffset, dx, dy);
|
||||
gximage_put (gdisp->canvas->window,
|
||||
j, i, dx, dy);
|
||||
j, i, dx, dy,
|
||||
gdisp->offset_x,
|
||||
gdisp->offset_y);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -844,7 +844,9 @@ gdisplay_display_area (GDisplay *gdisp,
|
|||
dy = (y2 - i < GXIMAGE_HEIGHT) ? y2 - i : GXIMAGE_HEIGHT;
|
||||
render_image (gdisp, j - gdisp->disp_xoffset, i - gdisp->disp_yoffset, dx, dy);
|
||||
gximage_put (gdisp->canvas->window,
|
||||
j, i, dx, dy);
|
||||
j, i, dx, dy,
|
||||
gdisp->offset_x,
|
||||
gdisp->offset_y);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -108,7 +108,7 @@ gximage_get_byte_order ()
|
|||
}
|
||||
|
||||
void
|
||||
gximage_put (GdkWindow *win, int x, int y, int w, int h)
|
||||
gximage_put (GdkWindow *win, int x, int y, int w, int h, int xdith, int ydith)
|
||||
{
|
||||
/* create the GC if it doesn't yet exist */
|
||||
if (!gximage->gc)
|
||||
|
@ -117,13 +117,15 @@ gximage_put (GdkWindow *win, int x, int y, int w, int h)
|
|||
gdk_gc_set_exposures (gximage->gc, TRUE);
|
||||
}
|
||||
|
||||
gdk_draw_rgb_image (win,
|
||||
gximage->gc,
|
||||
x,
|
||||
y,
|
||||
w,
|
||||
h,
|
||||
GDK_RGB_DITHER_MAX, /* todo: make configurable */
|
||||
gximage->data,
|
||||
GXIMAGE_WIDTH * 3);
|
||||
gdk_draw_rgb_image_dithalign (win,
|
||||
gximage->gc,
|
||||
x,
|
||||
y,
|
||||
w,
|
||||
h,
|
||||
/* todo: make configurable */
|
||||
GDK_RGB_DITHER_MAX,
|
||||
gximage->data,
|
||||
GXIMAGE_WIDTH * 3,
|
||||
xdith, ydith);
|
||||
}
|
||||
|
|
|
@ -24,7 +24,8 @@
|
|||
void gximage_init (void);
|
||||
void gximage_free (void);
|
||||
|
||||
void gximage_put (GdkWindow *, int, int, int, int);
|
||||
void
|
||||
gximage_put (GdkWindow *win, int x, int y, int w, int h, int xdith, int ydith);
|
||||
guchar* gximage_get_data (void);
|
||||
int gximage_get_bpp (void);
|
||||
int gximage_get_bpl (void);
|
||||
|
|
|
@ -844,7 +844,9 @@ gdisplay_display_area (GDisplay *gdisp,
|
|||
dy = (y2 - i < GXIMAGE_HEIGHT) ? y2 - i : GXIMAGE_HEIGHT;
|
||||
render_image (gdisp, j - gdisp->disp_xoffset, i - gdisp->disp_yoffset, dx, dy);
|
||||
gximage_put (gdisp->canvas->window,
|
||||
j, i, dx, dy);
|
||||
j, i, dx, dy,
|
||||
gdisp->offset_x,
|
||||
gdisp->offset_y);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -73,6 +73,45 @@ color_area_target (int x,
|
|||
return -1;
|
||||
}
|
||||
|
||||
void
|
||||
color_area_draw_rect (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
gint x, gint y, gint width, gint height,
|
||||
unsigned char r, unsigned char g, unsigned char b)
|
||||
{
|
||||
static unsigned char *color_area_rgb_buf = NULL;
|
||||
static gint color_area_rgb_buf_size;
|
||||
static gint rowstride;
|
||||
gint xx, yy;
|
||||
unsigned char *bp;
|
||||
|
||||
rowstride = 3 * ((width + 3) & -4);
|
||||
if (color_area_rgb_buf == NULL ||
|
||||
color_area_rgb_buf_size < height * rowstride)
|
||||
{
|
||||
if (color_area_rgb_buf)
|
||||
g_free (color_area_rgb_buf);
|
||||
color_area_rgb_buf = g_malloc (rowstride * height);
|
||||
}
|
||||
bp = color_area_rgb_buf;
|
||||
for (xx = 0; xx < width; xx++)
|
||||
{
|
||||
*bp++ = r;
|
||||
*bp++ = g;
|
||||
*bp++ = b;
|
||||
}
|
||||
bp = color_area_rgb_buf;
|
||||
for (yy = 1; yy < height; yy++)
|
||||
{
|
||||
bp += rowstride;
|
||||
memcpy (bp, color_area_rgb_buf, rowstride);
|
||||
}
|
||||
gdk_draw_rgb_image (drawable, gc, x, y, width, height,
|
||||
GDK_RGB_DITHER_MAX,
|
||||
color_area_rgb_buf,
|
||||
rowstride);
|
||||
}
|
||||
|
||||
static void
|
||||
color_area_draw (void)
|
||||
{
|
||||
|
@ -82,6 +121,7 @@ color_area_draw (void)
|
|||
int width, height;
|
||||
int def_width, def_height;
|
||||
int swap_width, swap_height;
|
||||
unsigned char r, g, b;
|
||||
|
||||
/* Check we haven't gotten initial expose yet,
|
||||
* no point in drawing anything */
|
||||
|
@ -102,9 +142,16 @@ color_area_draw (void)
|
|||
gdk_draw_rectangle (color_area_pixmap, color_area_gc, 1,
|
||||
0, 0, width, height);
|
||||
|
||||
#ifdef OLD_COLOR_AREA
|
||||
gdk_gc_set_foreground (color_area_gc, &bg);
|
||||
gdk_draw_rectangle (color_area_pixmap, color_area_gc, 1,
|
||||
(width - rect_w), (height - rect_h), rect_w, rect_h);
|
||||
#else
|
||||
palette_get_background (&r, &g, &b);
|
||||
color_area_draw_rect (color_area_pixmap, color_area_gc,
|
||||
(width - rect_w), (height - rect_h), rect_w, rect_h,
|
||||
r, g, b);
|
||||
#endif
|
||||
|
||||
if (active_color == FOREGROUND)
|
||||
gtk_draw_shadow (color_area->style, color_area_pixmap, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
|
||||
|
@ -113,9 +160,16 @@ color_area_draw (void)
|
|||
gtk_draw_shadow (color_area->style, color_area_pixmap, GTK_STATE_NORMAL, GTK_SHADOW_IN,
|
||||
(width - rect_w), (height - rect_h), rect_w, rect_h);
|
||||
|
||||
#ifdef OLD_COLOR_AREA
|
||||
gdk_gc_set_foreground (color_area_gc, &fg);
|
||||
gdk_draw_rectangle (color_area_pixmap, color_area_gc, 1,
|
||||
0, 0, rect_w, rect_h);
|
||||
#else
|
||||
palette_get_foreground (&r, &g, &b);
|
||||
color_area_draw_rect (color_area_pixmap, color_area_gc,
|
||||
0, 0, rect_w, rect_h,
|
||||
r, g, b);
|
||||
#endif
|
||||
|
||||
if (active_color == FOREGROUND)
|
||||
gtk_draw_shadow (color_area->style, color_area_pixmap, GTK_STATE_NORMAL, GTK_SHADOW_IN,
|
||||
|
|
|
@ -28,9 +28,17 @@ GtkWidget * color_area_create (int width,
|
|||
GdkPixmap *swap_pixmap);
|
||||
void color_area_update (void);
|
||||
|
||||
/* Exported for use by color_select */
|
||||
void
|
||||
color_area_draw_rect (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
gint x, gint y, gint width, gint height,
|
||||
unsigned char r, unsigned char g, unsigned char b);
|
||||
|
||||
/*
|
||||
* Global variables
|
||||
*/
|
||||
extern int active_color; /* foreground (= 0) or background (= 1) */
|
||||
|
||||
|
||||
#endif /* __COLOR_AREA_H__ */
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "errors.h"
|
||||
#include "gimprc.h"
|
||||
#include "session.h"
|
||||
#include "color_area.h" /* for color_area_draw_rect */
|
||||
|
||||
#define XY_DEF_WIDTH 240
|
||||
#define XY_DEF_HEIGHT 240
|
||||
|
@ -787,9 +788,15 @@ color_select_update_colors (ColorSelectP csp,
|
|||
|
||||
if (csp->gc)
|
||||
{
|
||||
#ifdef OLD_COLOR_AREA
|
||||
gdk_gc_set_foreground (csp->gc, &color);
|
||||
gdk_draw_rectangle (window, csp->gc, 1,
|
||||
0, 0, width, height);
|
||||
#else
|
||||
color_area_draw_rect (window, csp->gc,
|
||||
0, 0, width, height,
|
||||
red, green, blue);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@ gximage_get_byte_order ()
|
|||
}
|
||||
|
||||
void
|
||||
gximage_put (GdkWindow *win, int x, int y, int w, int h)
|
||||
gximage_put (GdkWindow *win, int x, int y, int w, int h, int xdith, int ydith)
|
||||
{
|
||||
/* create the GC if it doesn't yet exist */
|
||||
if (!gximage->gc)
|
||||
|
@ -117,13 +117,15 @@ gximage_put (GdkWindow *win, int x, int y, int w, int h)
|
|||
gdk_gc_set_exposures (gximage->gc, TRUE);
|
||||
}
|
||||
|
||||
gdk_draw_rgb_image (win,
|
||||
gximage->gc,
|
||||
x,
|
||||
y,
|
||||
w,
|
||||
h,
|
||||
GDK_RGB_DITHER_MAX, /* todo: make configurable */
|
||||
gximage->data,
|
||||
GXIMAGE_WIDTH * 3);
|
||||
gdk_draw_rgb_image_dithalign (win,
|
||||
gximage->gc,
|
||||
x,
|
||||
y,
|
||||
w,
|
||||
h,
|
||||
/* todo: make configurable */
|
||||
GDK_RGB_DITHER_MAX,
|
||||
gximage->data,
|
||||
GXIMAGE_WIDTH * 3,
|
||||
xdith, ydith);
|
||||
}
|
||||
|
|
|
@ -24,7 +24,8 @@
|
|||
void gximage_init (void);
|
||||
void gximage_free (void);
|
||||
|
||||
void gximage_put (GdkWindow *, int, int, int, int);
|
||||
void
|
||||
gximage_put (GdkWindow *win, int x, int y, int w, int h, int xdith, int ydith);
|
||||
guchar* gximage_get_data (void);
|
||||
int gximage_get_bpp (void);
|
||||
int gximage_get_bpl (void);
|
||||
|
|
|
@ -73,6 +73,45 @@ color_area_target (int x,
|
|||
return -1;
|
||||
}
|
||||
|
||||
void
|
||||
color_area_draw_rect (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
gint x, gint y, gint width, gint height,
|
||||
unsigned char r, unsigned char g, unsigned char b)
|
||||
{
|
||||
static unsigned char *color_area_rgb_buf = NULL;
|
||||
static gint color_area_rgb_buf_size;
|
||||
static gint rowstride;
|
||||
gint xx, yy;
|
||||
unsigned char *bp;
|
||||
|
||||
rowstride = 3 * ((width + 3) & -4);
|
||||
if (color_area_rgb_buf == NULL ||
|
||||
color_area_rgb_buf_size < height * rowstride)
|
||||
{
|
||||
if (color_area_rgb_buf)
|
||||
g_free (color_area_rgb_buf);
|
||||
color_area_rgb_buf = g_malloc (rowstride * height);
|
||||
}
|
||||
bp = color_area_rgb_buf;
|
||||
for (xx = 0; xx < width; xx++)
|
||||
{
|
||||
*bp++ = r;
|
||||
*bp++ = g;
|
||||
*bp++ = b;
|
||||
}
|
||||
bp = color_area_rgb_buf;
|
||||
for (yy = 1; yy < height; yy++)
|
||||
{
|
||||
bp += rowstride;
|
||||
memcpy (bp, color_area_rgb_buf, rowstride);
|
||||
}
|
||||
gdk_draw_rgb_image (drawable, gc, x, y, width, height,
|
||||
GDK_RGB_DITHER_MAX,
|
||||
color_area_rgb_buf,
|
||||
rowstride);
|
||||
}
|
||||
|
||||
static void
|
||||
color_area_draw (void)
|
||||
{
|
||||
|
@ -82,6 +121,7 @@ color_area_draw (void)
|
|||
int width, height;
|
||||
int def_width, def_height;
|
||||
int swap_width, swap_height;
|
||||
unsigned char r, g, b;
|
||||
|
||||
/* Check we haven't gotten initial expose yet,
|
||||
* no point in drawing anything */
|
||||
|
@ -102,9 +142,16 @@ color_area_draw (void)
|
|||
gdk_draw_rectangle (color_area_pixmap, color_area_gc, 1,
|
||||
0, 0, width, height);
|
||||
|
||||
#ifdef OLD_COLOR_AREA
|
||||
gdk_gc_set_foreground (color_area_gc, &bg);
|
||||
gdk_draw_rectangle (color_area_pixmap, color_area_gc, 1,
|
||||
(width - rect_w), (height - rect_h), rect_w, rect_h);
|
||||
#else
|
||||
palette_get_background (&r, &g, &b);
|
||||
color_area_draw_rect (color_area_pixmap, color_area_gc,
|
||||
(width - rect_w), (height - rect_h), rect_w, rect_h,
|
||||
r, g, b);
|
||||
#endif
|
||||
|
||||
if (active_color == FOREGROUND)
|
||||
gtk_draw_shadow (color_area->style, color_area_pixmap, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
|
||||
|
@ -113,9 +160,16 @@ color_area_draw (void)
|
|||
gtk_draw_shadow (color_area->style, color_area_pixmap, GTK_STATE_NORMAL, GTK_SHADOW_IN,
|
||||
(width - rect_w), (height - rect_h), rect_w, rect_h);
|
||||
|
||||
#ifdef OLD_COLOR_AREA
|
||||
gdk_gc_set_foreground (color_area_gc, &fg);
|
||||
gdk_draw_rectangle (color_area_pixmap, color_area_gc, 1,
|
||||
0, 0, rect_w, rect_h);
|
||||
#else
|
||||
palette_get_foreground (&r, &g, &b);
|
||||
color_area_draw_rect (color_area_pixmap, color_area_gc,
|
||||
0, 0, rect_w, rect_h,
|
||||
r, g, b);
|
||||
#endif
|
||||
|
||||
if (active_color == FOREGROUND)
|
||||
gtk_draw_shadow (color_area->style, color_area_pixmap, GTK_STATE_NORMAL, GTK_SHADOW_IN,
|
||||
|
|
|
@ -28,9 +28,17 @@ GtkWidget * color_area_create (int width,
|
|||
GdkPixmap *swap_pixmap);
|
||||
void color_area_update (void);
|
||||
|
||||
/* Exported for use by color_select */
|
||||
void
|
||||
color_area_draw_rect (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
gint x, gint y, gint width, gint height,
|
||||
unsigned char r, unsigned char g, unsigned char b);
|
||||
|
||||
/*
|
||||
* Global variables
|
||||
*/
|
||||
extern int active_color; /* foreground (= 0) or background (= 1) */
|
||||
|
||||
|
||||
#endif /* __COLOR_AREA_H__ */
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "errors.h"
|
||||
#include "gimprc.h"
|
||||
#include "session.h"
|
||||
#include "color_area.h" /* for color_area_draw_rect */
|
||||
|
||||
#define XY_DEF_WIDTH 240
|
||||
#define XY_DEF_HEIGHT 240
|
||||
|
@ -787,9 +788,15 @@ color_select_update_colors (ColorSelectP csp,
|
|||
|
||||
if (csp->gc)
|
||||
{
|
||||
#ifdef OLD_COLOR_AREA
|
||||
gdk_gc_set_foreground (csp->gc, &color);
|
||||
gdk_draw_rectangle (window, csp->gc, 1,
|
||||
0, 0, width, height);
|
||||
#else
|
||||
color_area_draw_rect (window, csp->gc,
|
||||
0, 0, width, height,
|
||||
red, green, blue);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue