libgimp/gimp.h plug-ins/jpeg.c applied gimp-austin-981010-0, fixes

* libgimp/gimp.h
* plug-ins/jpeg.c
* plug-ins/tiff.c: applied gimp-austin-981010-0, fixes compilation
warnings for jpeg and tiff plugin

* plug-ins/tiff/tiff.c: applied gimp-austin-981011-0, adds comment
parasite support to tiff plugin

* app/color_select.c: applied gimp-austin-981011-1, fixes color
selector redraw bug

* app/layer.c: applied gimp-austin-981011-2, fixes marching ants
weirdness (doesn't move when selection moved)

-Yosh
This commit is contained in:
Manish Singh 1998-10-11 22:50:03 +00:00
parent cd15045088
commit 0c635a62c1
17 changed files with 504 additions and 126 deletions

View File

@ -1,3 +1,19 @@
Sun Oct 11 15:45:21 PDT 1998 Manish Singh <yosh@gimp.org>
* libgimp/gimp.h
* plug-ins/jpeg.c
* plug-ins/tiff.c: applied gimp-austin-981010-0, fixes compilation
warnings for jpeg and tiff plugin
* plug-ins/tiff/tiff.c: applied gimp-austin-981011-0, adds comment
parasite support to tiff plugin
* app/color_select.c: applied gimp-austin-981011-1, fixes color
selector redraw bug
* app/layer.c: applied gimp-austin-981011-2, fixes marching ants
weirdness (doesn't move when selection moved)
Sat Oct 10 00:48:30 PDT 1998 Manish Singh <yosh@gimp.org>
* app/temp_buf.c: applied gimp-entity-980929-1, adds

View File

@ -99,8 +99,8 @@ static gint color_select_hex_entry_leave (GtkWidget *, GdkEvent *, gpointer);
static void color_select_image_fill (GtkWidget *, ColorSelectFillType, int *);
static void color_select_draw_z_marker (ColorSelectP, int);
static void color_select_draw_xy_marker (ColorSelectP, int);
static void color_select_draw_z_marker (ColorSelectP, GdkRectangle *);
static void color_select_draw_xy_marker (ColorSelectP, GdkRectangle *);
static void color_select_update_red (ColorSelectFill *);
static void color_select_update_green (ColorSelectFill *);
@ -856,7 +856,7 @@ color_select_xy_expose (GtkWidget *widget,
if (!csp->gc)
csp->gc = gdk_gc_new (widget->window);
color_select_draw_xy_marker (csp, 1);
color_select_draw_xy_marker (csp, &event->area);
return FALSE;
}
@ -875,7 +875,7 @@ color_select_xy_events (GtkWidget *widget,
case GDK_BUTTON_PRESS:
bevent = (GdkEventButton *) event;
color_select_draw_xy_marker (csp, 1);
color_select_draw_xy_marker (csp, NULL);
csp->pos[0] = (bevent->x * 255) / (XY_DEF_WIDTH - 1);
csp->pos[1] = 255 - (bevent->y * 255) / (XY_DEF_HEIGHT - 1);
@ -892,7 +892,7 @@ color_select_xy_events (GtkWidget *widget,
gdk_pointer_grab (csp->xy_color->window, FALSE,
GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK,
NULL, NULL, bevent->time);
color_select_draw_xy_marker (csp, 1);
color_select_draw_xy_marker (csp, NULL);
color_select_update (csp, UPDATE_VALUES);
break;
@ -900,7 +900,7 @@ color_select_xy_events (GtkWidget *widget,
case GDK_BUTTON_RELEASE:
bevent = (GdkEventButton *) event;
color_select_draw_xy_marker (csp, 1);
color_select_draw_xy_marker (csp, NULL);
csp->pos[0] = (bevent->x * 255) / (XY_DEF_WIDTH - 1);
csp->pos[1] = 255 - (bevent->y * 255) / (XY_DEF_HEIGHT - 1);
@ -915,7 +915,7 @@ color_select_xy_events (GtkWidget *widget,
csp->pos[1] = 255;
gdk_pointer_ungrab (bevent->time);
color_select_draw_xy_marker (csp, 1);
color_select_draw_xy_marker (csp, NULL);
color_select_update (csp, UPDATE_VALUES);
break;
@ -928,7 +928,7 @@ color_select_xy_events (GtkWidget *widget,
mevent->y = ty;
}
color_select_draw_xy_marker (csp, 1);
color_select_draw_xy_marker (csp, NULL);
csp->pos[0] = (mevent->x * 255) / (XY_DEF_WIDTH - 1);
csp->pos[1] = 255 - (mevent->y * 255) / (XY_DEF_HEIGHT - 1);
@ -942,7 +942,7 @@ color_select_xy_events (GtkWidget *widget,
if (csp->pos[1] > 255)
csp->pos[1] = 255;
color_select_draw_xy_marker (csp, 1);
color_select_draw_xy_marker (csp, NULL);
color_select_update (csp, UPDATE_VALUES);
break;
@ -961,7 +961,7 @@ color_select_z_expose (GtkWidget *widget,
if (!csp->gc)
csp->gc = gdk_gc_new (widget->window);
color_select_draw_z_marker (csp, 1);
color_select_draw_z_marker (csp, &event->area);
return FALSE;
}
@ -980,7 +980,7 @@ color_select_z_events (GtkWidget *widget,
case GDK_BUTTON_PRESS:
bevent = (GdkEventButton *) event;
color_select_draw_z_marker (csp, 1);
color_select_draw_z_marker (csp, NULL);
csp->pos[2] = 255 - (bevent->y * 255) / (Z_DEF_HEIGHT - 1);
if (csp->pos[2] < 0)
@ -991,14 +991,14 @@ color_select_z_events (GtkWidget *widget,
gdk_pointer_grab (csp->z_color->window, FALSE,
GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK,
NULL, NULL, bevent->time);
color_select_draw_z_marker (csp, 1);
color_select_draw_z_marker (csp, NULL);
color_select_update (csp, UPDATE_VALUES);
break;
case GDK_BUTTON_RELEASE:
bevent = (GdkEventButton *) event;
color_select_draw_z_marker (csp, 1);
color_select_draw_z_marker (csp, NULL);
csp->pos[2] = 255 - (bevent->y * 255) / (Z_DEF_HEIGHT - 1);
if (csp->pos[2] < 0)
@ -1007,7 +1007,7 @@ color_select_z_events (GtkWidget *widget,
csp->pos[2] = 255;
gdk_pointer_ungrab (bevent->time);
color_select_draw_z_marker (csp, 1);
color_select_draw_z_marker (csp, NULL);
color_select_update (csp, UPDATE_VALUES | UPDATE_XY_COLOR);
break;
@ -1020,7 +1020,7 @@ color_select_z_events (GtkWidget *widget,
mevent->y = ty;
}
color_select_draw_z_marker (csp, 1);
color_select_draw_z_marker (csp, NULL);
csp->pos[2] = 255 - (mevent->y * 255) / (Z_DEF_HEIGHT - 1);
if (csp->pos[2] < 0)
@ -1028,7 +1028,7 @@ color_select_z_events (GtkWidget *widget,
if (csp->pos[2] > 255)
csp->pos[2] = 255;
color_select_draw_z_marker (csp, 1);
color_select_draw_z_marker (csp, NULL);
color_select_update (csp, UPDATE_VALUES);
break;
@ -1116,23 +1116,23 @@ color_select_slider_update (GtkAdjustment *adjustment,
if (update_z_marker)
{
color_select_draw_z_marker (csp, 1);
color_select_draw_z_marker (csp, NULL);
color_select_update (csp, UPDATE_POS | UPDATE_XY_COLOR);
color_select_draw_z_marker (csp, 1);
color_select_draw_z_marker (csp, NULL);
}
else
{
if (update_z_marker)
color_select_draw_z_marker (csp, 1);
color_select_draw_z_marker (csp, NULL);
if (update_xy_marker)
color_select_draw_xy_marker (csp, 1);
color_select_draw_xy_marker (csp, NULL);
color_select_update (csp, UPDATE_POS);
if (update_z_marker)
color_select_draw_z_marker (csp, 1);
color_select_draw_z_marker (csp, NULL);
if (update_xy_marker)
color_select_draw_xy_marker (csp, 1);
color_select_draw_xy_marker (csp, NULL);
}
color_select_update (csp, UPDATE_NEW_COLOR);
@ -1189,23 +1189,23 @@ color_select_entry_update (GtkWidget *w,
if (update_z_marker)
{
color_select_draw_z_marker (csp, 1);
color_select_draw_z_marker (csp, NULL);
color_select_update (csp, UPDATE_POS | UPDATE_XY_COLOR);
color_select_draw_z_marker (csp, 1);
color_select_draw_z_marker (csp, NULL);
}
else
{
if (update_z_marker)
color_select_draw_z_marker (csp, 1);
color_select_draw_z_marker (csp, NULL);
if (update_xy_marker)
color_select_draw_xy_marker (csp, 1);
color_select_draw_xy_marker (csp, NULL);
color_select_update (csp, UPDATE_POS);
if (update_z_marker)
color_select_draw_z_marker (csp, 1);
color_select_draw_z_marker (csp, NULL);
if (update_xy_marker)
color_select_draw_xy_marker (csp, 1);
color_select_draw_xy_marker (csp, NULL);
}
color_select_update (csp, UPDATE_NEW_COLOR);
@ -1335,31 +1335,49 @@ color_select_image_fill (GtkWidget *preview,
static void
color_select_draw_z_marker (ColorSelectP csp,
int update)
GdkRectangle *clip)
{
int width;
int height;
int y;
int minx;
int miny;
if (csp->gc)
{
y = (Z_DEF_HEIGHT - 1) - ((Z_DEF_HEIGHT - 1) * csp->pos[2]) / 255;
width = csp->z_color->requisition.width;
height = csp->z_color->requisition.height;
minx = 0;
miny = 0;
if (width <= 0)
return;
gdk_gc_set_function (csp->gc, GDK_INVERT);
gdk_draw_line (csp->z_color->window, csp->gc, 0, y, width, y);
gdk_gc_set_function (csp->gc, GDK_COPY);
if (clip)
{
width = MIN(width, clip->x + clip->width);
height = MIN(height, clip->y + clip->height);
minx = MAX(0, clip->x);
miny = MAX(0, clip->y);
}
if (y >= miny && y < height)
{
gdk_gc_set_function (csp->gc, GDK_INVERT);
gdk_draw_line (csp->z_color->window, csp->gc, minx, y, width, y);
gdk_gc_set_function (csp->gc, GDK_COPY);
}
}
}
static void
color_select_draw_xy_marker (ColorSelectP csp,
int update)
GdkRectangle *clip)
{
int width;
int height;
int x, y;
int minx, miny;
if (csp->gc)
{
@ -1367,12 +1385,27 @@ color_select_draw_xy_marker (ColorSelectP csp,
y = (XY_DEF_HEIGHT - 1) - ((XY_DEF_HEIGHT - 1) * csp->pos[1]) / 255;
width = csp->xy_color->requisition.width;
height = csp->xy_color->requisition.height;
minx = 0;
miny = 0;
if ((width <= 0) || (height <= 0))
return;
gdk_gc_set_function (csp->gc, GDK_INVERT);
gdk_draw_line (csp->xy_color->window, csp->gc, 0, y, width, y);
gdk_draw_line (csp->xy_color->window, csp->gc, x, 0, x, height);
if (clip)
{
width = MIN(width, clip->x + clip->width);
height = MIN(height, clip->y + clip->height);
minx = MAX(0, clip->x);
miny = MAX(0, clip->y);
}
if (y >= miny && y < height)
gdk_draw_line (csp->xy_color->window, csp->gc, minx, y, width, y);
if (x >= minx && x < width)
gdk_draw_line (csp->xy_color->window, csp->gc, x, miny, x, height);
gdk_gc_set_function (csp->gc, GDK_COPY);
}
}

View File

@ -926,6 +926,9 @@ layer_invalidate_boundary (layer)
mask->boundary_known = FALSE;
}
if (layer_is_floating_sel(layer))
floating_sel_invalidate(layer);
/* clear the affected region surrounding the layer */
/* gdisplays_selection_visibility (GIMP_DRAWABLE(layer)->gimage,
SelectionLayerOff); */

View File

@ -926,6 +926,9 @@ layer_invalidate_boundary (layer)
mask->boundary_known = FALSE;
}
if (layer_is_floating_sel(layer))
floating_sel_invalidate(layer);
/* clear the affected region surrounding the layer */
/* gdisplays_selection_visibility (GIMP_DRAWABLE(layer)->gimage,
SelectionLayerOff); */

View File

@ -99,8 +99,8 @@ static gint color_select_hex_entry_leave (GtkWidget *, GdkEvent *, gpointer);
static void color_select_image_fill (GtkWidget *, ColorSelectFillType, int *);
static void color_select_draw_z_marker (ColorSelectP, int);
static void color_select_draw_xy_marker (ColorSelectP, int);
static void color_select_draw_z_marker (ColorSelectP, GdkRectangle *);
static void color_select_draw_xy_marker (ColorSelectP, GdkRectangle *);
static void color_select_update_red (ColorSelectFill *);
static void color_select_update_green (ColorSelectFill *);
@ -856,7 +856,7 @@ color_select_xy_expose (GtkWidget *widget,
if (!csp->gc)
csp->gc = gdk_gc_new (widget->window);
color_select_draw_xy_marker (csp, 1);
color_select_draw_xy_marker (csp, &event->area);
return FALSE;
}
@ -875,7 +875,7 @@ color_select_xy_events (GtkWidget *widget,
case GDK_BUTTON_PRESS:
bevent = (GdkEventButton *) event;
color_select_draw_xy_marker (csp, 1);
color_select_draw_xy_marker (csp, NULL);
csp->pos[0] = (bevent->x * 255) / (XY_DEF_WIDTH - 1);
csp->pos[1] = 255 - (bevent->y * 255) / (XY_DEF_HEIGHT - 1);
@ -892,7 +892,7 @@ color_select_xy_events (GtkWidget *widget,
gdk_pointer_grab (csp->xy_color->window, FALSE,
GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK,
NULL, NULL, bevent->time);
color_select_draw_xy_marker (csp, 1);
color_select_draw_xy_marker (csp, NULL);
color_select_update (csp, UPDATE_VALUES);
break;
@ -900,7 +900,7 @@ color_select_xy_events (GtkWidget *widget,
case GDK_BUTTON_RELEASE:
bevent = (GdkEventButton *) event;
color_select_draw_xy_marker (csp, 1);
color_select_draw_xy_marker (csp, NULL);
csp->pos[0] = (bevent->x * 255) / (XY_DEF_WIDTH - 1);
csp->pos[1] = 255 - (bevent->y * 255) / (XY_DEF_HEIGHT - 1);
@ -915,7 +915,7 @@ color_select_xy_events (GtkWidget *widget,
csp->pos[1] = 255;
gdk_pointer_ungrab (bevent->time);
color_select_draw_xy_marker (csp, 1);
color_select_draw_xy_marker (csp, NULL);
color_select_update (csp, UPDATE_VALUES);
break;
@ -928,7 +928,7 @@ color_select_xy_events (GtkWidget *widget,
mevent->y = ty;
}
color_select_draw_xy_marker (csp, 1);
color_select_draw_xy_marker (csp, NULL);
csp->pos[0] = (mevent->x * 255) / (XY_DEF_WIDTH - 1);
csp->pos[1] = 255 - (mevent->y * 255) / (XY_DEF_HEIGHT - 1);
@ -942,7 +942,7 @@ color_select_xy_events (GtkWidget *widget,
if (csp->pos[1] > 255)
csp->pos[1] = 255;
color_select_draw_xy_marker (csp, 1);
color_select_draw_xy_marker (csp, NULL);
color_select_update (csp, UPDATE_VALUES);
break;
@ -961,7 +961,7 @@ color_select_z_expose (GtkWidget *widget,
if (!csp->gc)
csp->gc = gdk_gc_new (widget->window);
color_select_draw_z_marker (csp, 1);
color_select_draw_z_marker (csp, &event->area);
return FALSE;
}
@ -980,7 +980,7 @@ color_select_z_events (GtkWidget *widget,
case GDK_BUTTON_PRESS:
bevent = (GdkEventButton *) event;
color_select_draw_z_marker (csp, 1);
color_select_draw_z_marker (csp, NULL);
csp->pos[2] = 255 - (bevent->y * 255) / (Z_DEF_HEIGHT - 1);
if (csp->pos[2] < 0)
@ -991,14 +991,14 @@ color_select_z_events (GtkWidget *widget,
gdk_pointer_grab (csp->z_color->window, FALSE,
GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK,
NULL, NULL, bevent->time);
color_select_draw_z_marker (csp, 1);
color_select_draw_z_marker (csp, NULL);
color_select_update (csp, UPDATE_VALUES);
break;
case GDK_BUTTON_RELEASE:
bevent = (GdkEventButton *) event;
color_select_draw_z_marker (csp, 1);
color_select_draw_z_marker (csp, NULL);
csp->pos[2] = 255 - (bevent->y * 255) / (Z_DEF_HEIGHT - 1);
if (csp->pos[2] < 0)
@ -1007,7 +1007,7 @@ color_select_z_events (GtkWidget *widget,
csp->pos[2] = 255;
gdk_pointer_ungrab (bevent->time);
color_select_draw_z_marker (csp, 1);
color_select_draw_z_marker (csp, NULL);
color_select_update (csp, UPDATE_VALUES | UPDATE_XY_COLOR);
break;
@ -1020,7 +1020,7 @@ color_select_z_events (GtkWidget *widget,
mevent->y = ty;
}
color_select_draw_z_marker (csp, 1);
color_select_draw_z_marker (csp, NULL);
csp->pos[2] = 255 - (mevent->y * 255) / (Z_DEF_HEIGHT - 1);
if (csp->pos[2] < 0)
@ -1028,7 +1028,7 @@ color_select_z_events (GtkWidget *widget,
if (csp->pos[2] > 255)
csp->pos[2] = 255;
color_select_draw_z_marker (csp, 1);
color_select_draw_z_marker (csp, NULL);
color_select_update (csp, UPDATE_VALUES);
break;
@ -1116,23 +1116,23 @@ color_select_slider_update (GtkAdjustment *adjustment,
if (update_z_marker)
{
color_select_draw_z_marker (csp, 1);
color_select_draw_z_marker (csp, NULL);
color_select_update (csp, UPDATE_POS | UPDATE_XY_COLOR);
color_select_draw_z_marker (csp, 1);
color_select_draw_z_marker (csp, NULL);
}
else
{
if (update_z_marker)
color_select_draw_z_marker (csp, 1);
color_select_draw_z_marker (csp, NULL);
if (update_xy_marker)
color_select_draw_xy_marker (csp, 1);
color_select_draw_xy_marker (csp, NULL);
color_select_update (csp, UPDATE_POS);
if (update_z_marker)
color_select_draw_z_marker (csp, 1);
color_select_draw_z_marker (csp, NULL);
if (update_xy_marker)
color_select_draw_xy_marker (csp, 1);
color_select_draw_xy_marker (csp, NULL);
}
color_select_update (csp, UPDATE_NEW_COLOR);
@ -1189,23 +1189,23 @@ color_select_entry_update (GtkWidget *w,
if (update_z_marker)
{
color_select_draw_z_marker (csp, 1);
color_select_draw_z_marker (csp, NULL);
color_select_update (csp, UPDATE_POS | UPDATE_XY_COLOR);
color_select_draw_z_marker (csp, 1);
color_select_draw_z_marker (csp, NULL);
}
else
{
if (update_z_marker)
color_select_draw_z_marker (csp, 1);
color_select_draw_z_marker (csp, NULL);
if (update_xy_marker)
color_select_draw_xy_marker (csp, 1);
color_select_draw_xy_marker (csp, NULL);
color_select_update (csp, UPDATE_POS);
if (update_z_marker)
color_select_draw_z_marker (csp, 1);
color_select_draw_z_marker (csp, NULL);
if (update_xy_marker)
color_select_draw_xy_marker (csp, 1);
color_select_draw_xy_marker (csp, NULL);
}
color_select_update (csp, UPDATE_NEW_COLOR);
@ -1335,31 +1335,49 @@ color_select_image_fill (GtkWidget *preview,
static void
color_select_draw_z_marker (ColorSelectP csp,
int update)
GdkRectangle *clip)
{
int width;
int height;
int y;
int minx;
int miny;
if (csp->gc)
{
y = (Z_DEF_HEIGHT - 1) - ((Z_DEF_HEIGHT - 1) * csp->pos[2]) / 255;
width = csp->z_color->requisition.width;
height = csp->z_color->requisition.height;
minx = 0;
miny = 0;
if (width <= 0)
return;
gdk_gc_set_function (csp->gc, GDK_INVERT);
gdk_draw_line (csp->z_color->window, csp->gc, 0, y, width, y);
gdk_gc_set_function (csp->gc, GDK_COPY);
if (clip)
{
width = MIN(width, clip->x + clip->width);
height = MIN(height, clip->y + clip->height);
minx = MAX(0, clip->x);
miny = MAX(0, clip->y);
}
if (y >= miny && y < height)
{
gdk_gc_set_function (csp->gc, GDK_INVERT);
gdk_draw_line (csp->z_color->window, csp->gc, minx, y, width, y);
gdk_gc_set_function (csp->gc, GDK_COPY);
}
}
}
static void
color_select_draw_xy_marker (ColorSelectP csp,
int update)
GdkRectangle *clip)
{
int width;
int height;
int x, y;
int minx, miny;
if (csp->gc)
{
@ -1367,12 +1385,27 @@ color_select_draw_xy_marker (ColorSelectP csp,
y = (XY_DEF_HEIGHT - 1) - ((XY_DEF_HEIGHT - 1) * csp->pos[1]) / 255;
width = csp->xy_color->requisition.width;
height = csp->xy_color->requisition.height;
minx = 0;
miny = 0;
if ((width <= 0) || (height <= 0))
return;
gdk_gc_set_function (csp->gc, GDK_INVERT);
gdk_draw_line (csp->xy_color->window, csp->gc, 0, y, width, y);
gdk_draw_line (csp->xy_color->window, csp->gc, x, 0, x, height);
if (clip)
{
width = MIN(width, clip->x + clip->width);
height = MIN(height, clip->y + clip->height);
minx = MAX(0, clip->x);
miny = MAX(0, clip->y);
}
if (y >= miny && y < height)
gdk_draw_line (csp->xy_color->window, csp->gc, minx, y, width, y);
if (x >= minx && x < width)
gdk_draw_line (csp->xy_color->window, csp->gc, x, miny, x, height);
gdk_gc_set_function (csp->gc, GDK_COPY);
}
}

View File

@ -926,6 +926,9 @@ layer_invalidate_boundary (layer)
mask->boundary_known = FALSE;
}
if (layer_is_floating_sel(layer))
floating_sel_invalidate(layer);
/* clear the affected region surrounding the layer */
/* gdisplays_selection_visibility (GIMP_DRAWABLE(layer)->gimage,
SelectionLayerOff); */

View File

@ -181,7 +181,7 @@ int gimp_main (int argc,
/* Forcefully causes the gimp library to exit and
* close down its connection to main gimp application.
*/
void gimp_quit (void);
void G_GNUC_NORETURN gimp_quit (void);
/* Specify a range of data to be associated with 'id'.
* The data will exist for as long as the main gimp

View File

@ -99,8 +99,8 @@ static gint color_select_hex_entry_leave (GtkWidget *, GdkEvent *, gpointer);
static void color_select_image_fill (GtkWidget *, ColorSelectFillType, int *);
static void color_select_draw_z_marker (ColorSelectP, int);
static void color_select_draw_xy_marker (ColorSelectP, int);
static void color_select_draw_z_marker (ColorSelectP, GdkRectangle *);
static void color_select_draw_xy_marker (ColorSelectP, GdkRectangle *);
static void color_select_update_red (ColorSelectFill *);
static void color_select_update_green (ColorSelectFill *);
@ -856,7 +856,7 @@ color_select_xy_expose (GtkWidget *widget,
if (!csp->gc)
csp->gc = gdk_gc_new (widget->window);
color_select_draw_xy_marker (csp, 1);
color_select_draw_xy_marker (csp, &event->area);
return FALSE;
}
@ -875,7 +875,7 @@ color_select_xy_events (GtkWidget *widget,
case GDK_BUTTON_PRESS:
bevent = (GdkEventButton *) event;
color_select_draw_xy_marker (csp, 1);
color_select_draw_xy_marker (csp, NULL);
csp->pos[0] = (bevent->x * 255) / (XY_DEF_WIDTH - 1);
csp->pos[1] = 255 - (bevent->y * 255) / (XY_DEF_HEIGHT - 1);
@ -892,7 +892,7 @@ color_select_xy_events (GtkWidget *widget,
gdk_pointer_grab (csp->xy_color->window, FALSE,
GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK,
NULL, NULL, bevent->time);
color_select_draw_xy_marker (csp, 1);
color_select_draw_xy_marker (csp, NULL);
color_select_update (csp, UPDATE_VALUES);
break;
@ -900,7 +900,7 @@ color_select_xy_events (GtkWidget *widget,
case GDK_BUTTON_RELEASE:
bevent = (GdkEventButton *) event;
color_select_draw_xy_marker (csp, 1);
color_select_draw_xy_marker (csp, NULL);
csp->pos[0] = (bevent->x * 255) / (XY_DEF_WIDTH - 1);
csp->pos[1] = 255 - (bevent->y * 255) / (XY_DEF_HEIGHT - 1);
@ -915,7 +915,7 @@ color_select_xy_events (GtkWidget *widget,
csp->pos[1] = 255;
gdk_pointer_ungrab (bevent->time);
color_select_draw_xy_marker (csp, 1);
color_select_draw_xy_marker (csp, NULL);
color_select_update (csp, UPDATE_VALUES);
break;
@ -928,7 +928,7 @@ color_select_xy_events (GtkWidget *widget,
mevent->y = ty;
}
color_select_draw_xy_marker (csp, 1);
color_select_draw_xy_marker (csp, NULL);
csp->pos[0] = (mevent->x * 255) / (XY_DEF_WIDTH - 1);
csp->pos[1] = 255 - (mevent->y * 255) / (XY_DEF_HEIGHT - 1);
@ -942,7 +942,7 @@ color_select_xy_events (GtkWidget *widget,
if (csp->pos[1] > 255)
csp->pos[1] = 255;
color_select_draw_xy_marker (csp, 1);
color_select_draw_xy_marker (csp, NULL);
color_select_update (csp, UPDATE_VALUES);
break;
@ -961,7 +961,7 @@ color_select_z_expose (GtkWidget *widget,
if (!csp->gc)
csp->gc = gdk_gc_new (widget->window);
color_select_draw_z_marker (csp, 1);
color_select_draw_z_marker (csp, &event->area);
return FALSE;
}
@ -980,7 +980,7 @@ color_select_z_events (GtkWidget *widget,
case GDK_BUTTON_PRESS:
bevent = (GdkEventButton *) event;
color_select_draw_z_marker (csp, 1);
color_select_draw_z_marker (csp, NULL);
csp->pos[2] = 255 - (bevent->y * 255) / (Z_DEF_HEIGHT - 1);
if (csp->pos[2] < 0)
@ -991,14 +991,14 @@ color_select_z_events (GtkWidget *widget,
gdk_pointer_grab (csp->z_color->window, FALSE,
GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK,
NULL, NULL, bevent->time);
color_select_draw_z_marker (csp, 1);
color_select_draw_z_marker (csp, NULL);
color_select_update (csp, UPDATE_VALUES);
break;
case GDK_BUTTON_RELEASE:
bevent = (GdkEventButton *) event;
color_select_draw_z_marker (csp, 1);
color_select_draw_z_marker (csp, NULL);
csp->pos[2] = 255 - (bevent->y * 255) / (Z_DEF_HEIGHT - 1);
if (csp->pos[2] < 0)
@ -1007,7 +1007,7 @@ color_select_z_events (GtkWidget *widget,
csp->pos[2] = 255;
gdk_pointer_ungrab (bevent->time);
color_select_draw_z_marker (csp, 1);
color_select_draw_z_marker (csp, NULL);
color_select_update (csp, UPDATE_VALUES | UPDATE_XY_COLOR);
break;
@ -1020,7 +1020,7 @@ color_select_z_events (GtkWidget *widget,
mevent->y = ty;
}
color_select_draw_z_marker (csp, 1);
color_select_draw_z_marker (csp, NULL);
csp->pos[2] = 255 - (mevent->y * 255) / (Z_DEF_HEIGHT - 1);
if (csp->pos[2] < 0)
@ -1028,7 +1028,7 @@ color_select_z_events (GtkWidget *widget,
if (csp->pos[2] > 255)
csp->pos[2] = 255;
color_select_draw_z_marker (csp, 1);
color_select_draw_z_marker (csp, NULL);
color_select_update (csp, UPDATE_VALUES);
break;
@ -1116,23 +1116,23 @@ color_select_slider_update (GtkAdjustment *adjustment,
if (update_z_marker)
{
color_select_draw_z_marker (csp, 1);
color_select_draw_z_marker (csp, NULL);
color_select_update (csp, UPDATE_POS | UPDATE_XY_COLOR);
color_select_draw_z_marker (csp, 1);
color_select_draw_z_marker (csp, NULL);
}
else
{
if (update_z_marker)
color_select_draw_z_marker (csp, 1);
color_select_draw_z_marker (csp, NULL);
if (update_xy_marker)
color_select_draw_xy_marker (csp, 1);
color_select_draw_xy_marker (csp, NULL);
color_select_update (csp, UPDATE_POS);
if (update_z_marker)
color_select_draw_z_marker (csp, 1);
color_select_draw_z_marker (csp, NULL);
if (update_xy_marker)
color_select_draw_xy_marker (csp, 1);
color_select_draw_xy_marker (csp, NULL);
}
color_select_update (csp, UPDATE_NEW_COLOR);
@ -1189,23 +1189,23 @@ color_select_entry_update (GtkWidget *w,
if (update_z_marker)
{
color_select_draw_z_marker (csp, 1);
color_select_draw_z_marker (csp, NULL);
color_select_update (csp, UPDATE_POS | UPDATE_XY_COLOR);
color_select_draw_z_marker (csp, 1);
color_select_draw_z_marker (csp, NULL);
}
else
{
if (update_z_marker)
color_select_draw_z_marker (csp, 1);
color_select_draw_z_marker (csp, NULL);
if (update_xy_marker)
color_select_draw_xy_marker (csp, 1);
color_select_draw_xy_marker (csp, NULL);
color_select_update (csp, UPDATE_POS);
if (update_z_marker)
color_select_draw_z_marker (csp, 1);
color_select_draw_z_marker (csp, NULL);
if (update_xy_marker)
color_select_draw_xy_marker (csp, 1);
color_select_draw_xy_marker (csp, NULL);
}
color_select_update (csp, UPDATE_NEW_COLOR);
@ -1335,31 +1335,49 @@ color_select_image_fill (GtkWidget *preview,
static void
color_select_draw_z_marker (ColorSelectP csp,
int update)
GdkRectangle *clip)
{
int width;
int height;
int y;
int minx;
int miny;
if (csp->gc)
{
y = (Z_DEF_HEIGHT - 1) - ((Z_DEF_HEIGHT - 1) * csp->pos[2]) / 255;
width = csp->z_color->requisition.width;
height = csp->z_color->requisition.height;
minx = 0;
miny = 0;
if (width <= 0)
return;
gdk_gc_set_function (csp->gc, GDK_INVERT);
gdk_draw_line (csp->z_color->window, csp->gc, 0, y, width, y);
gdk_gc_set_function (csp->gc, GDK_COPY);
if (clip)
{
width = MIN(width, clip->x + clip->width);
height = MIN(height, clip->y + clip->height);
minx = MAX(0, clip->x);
miny = MAX(0, clip->y);
}
if (y >= miny && y < height)
{
gdk_gc_set_function (csp->gc, GDK_INVERT);
gdk_draw_line (csp->z_color->window, csp->gc, minx, y, width, y);
gdk_gc_set_function (csp->gc, GDK_COPY);
}
}
}
static void
color_select_draw_xy_marker (ColorSelectP csp,
int update)
GdkRectangle *clip)
{
int width;
int height;
int x, y;
int minx, miny;
if (csp->gc)
{
@ -1367,12 +1385,27 @@ color_select_draw_xy_marker (ColorSelectP csp,
y = (XY_DEF_HEIGHT - 1) - ((XY_DEF_HEIGHT - 1) * csp->pos[1]) / 255;
width = csp->xy_color->requisition.width;
height = csp->xy_color->requisition.height;
minx = 0;
miny = 0;
if ((width <= 0) || (height <= 0))
return;
gdk_gc_set_function (csp->gc, GDK_INVERT);
gdk_draw_line (csp->xy_color->window, csp->gc, 0, y, width, y);
gdk_draw_line (csp->xy_color->window, csp->gc, x, 0, x, height);
if (clip)
{
width = MIN(width, clip->x + clip->width);
height = MIN(height, clip->y + clip->height);
minx = MAX(0, clip->x);
miny = MAX(0, clip->y);
}
if (y >= miny && y < height)
gdk_draw_line (csp->xy_color->window, csp->gc, minx, y, width, y);
if (x >= minx && x < width)
gdk_draw_line (csp->xy_color->window, csp->gc, x, miny, x, height);
gdk_gc_set_function (csp->gc, GDK_COPY);
}
}

View File

@ -270,7 +270,7 @@ load_image (char *filename)
{
GPixelRgn pixel_rgn;
GDrawable *drawable;
gint32 image_ID;
gint32 volatile image_ID;
gint32 layer_ID;
struct jpeg_decompress_struct cinfo;
struct my_error_mgr jerr;
@ -451,7 +451,7 @@ save_image (char *filename,
GDrawableType drawable_type;
struct jpeg_compress_struct cinfo;
struct my_error_mgr jerr;
FILE *outfile;
FILE * volatile outfile;
guchar *temp, *t;
guchar *data;
guchar *src, *s;
@ -585,6 +585,10 @@ save_image (char *filename,
temp = (guchar *) malloc (cinfo.image_width * cinfo.input_components);
data = (guchar *) malloc (rowstride * gimp_tile_height ());
/* fault if cinfo.next_scanline isn't initially a multiple of
* gimp_tile_height */
src = NULL;
while (cinfo.next_scanline < cinfo.image_height)
{
if ((cinfo.next_scanline % gimp_tile_height ()) == 0)

View File

@ -36,6 +36,7 @@
#include "gtk/gtk.h"
#include "libgimp/gimp.h"
typedef struct
{
gint compression;
@ -68,7 +69,10 @@ static void save_ok_callback (GtkWidget *widget,
gpointer data);
static void save_toggle_update (GtkWidget *widget,
gpointer data);
static void comment_entry_callback (GtkWidget *widget,
gpointer data);
#define DEFAULT_COMMENT "Created with The GIMP"
GPlugInInfo PLUG_IN_INFO =
{
@ -89,6 +93,7 @@ static TiffSaveInterface tsint =
FALSE /* run */
};
static char *image_comment;
MAIN ()
@ -149,6 +154,9 @@ query ()
gimp_register_save_handler ("file_tiff_save", "tif,tiff", "");
}
static void
run (char *name,
int nparams,
@ -187,6 +195,21 @@ run (char *name,
else if (strcmp (name, "file_tiff_save") == 0)
{
int image = param[1].data.d_int32;
/* get the image comment either from a parasite, or from our
* compiled-in default */
{
GParasite *parasite;
image_comment = NULL;
parasite = gimp_image_find_parasite(image, "GIF2", "CMNT");
if (!gparasite_is_error(parasite))
image_comment = g_strdup(parasite->data);
gparasite_free(parasite);
if (!image_comment)
image_comment = g_strdup(DEFAULT_COMMENT);
}
switch (run_mode)
{
case RUN_INTERACTIVE:
@ -401,6 +424,26 @@ static gint32 load_image (char *filename) {
gparasite_free(parasite);
/* Attach a parasite containing the image description. Pretend to
* be a GIF2 comment so other plugins will use this description as
* an image comment where appropriate. */
{
char *img_desc;
if (TIFFGetField (tif, TIFFTAG_IMAGEDESCRIPTION, &img_desc))
{
int len;
len = strlen(img_desc) + 1;
len = MIN(len, 241);
img_desc[len-1] = '\000';
parasite = gparasite_new("GIF2", "CMNT", 1, len, img_desc);
gimp_image_attach_parasite(image, parasite);
gparasite_free(parasite);
}
}
/* any resolution info in the file? */
{
float xres=0, yres=0;
@ -802,7 +845,6 @@ static gint save_image (char *filename, gint32 image, gint32 layer) {
TIFFSetField (tif, TIFFTAG_PHOTOMETRIC, photometric);
TIFFSetField (tif, TIFFTAG_FILLORDER, fillorder);
TIFFSetField (tif, TIFFTAG_DOCUMENTNAME, filename);
TIFFSetField (tif, TIFFTAG_IMAGEDESCRIPTION, "Created with The GIMP");
TIFFSetField (tif, TIFFTAG_SAMPLESPERPIXEL, samplesperpixel);
TIFFSetField (tif, TIFFTAG_ROWSPERSTRIP, rowsperstrip);
/* TIFFSetField( tif, TIFFTAG_STRIPBYTECOUNTS, rows / rowsperstrip ); */
@ -819,6 +861,20 @@ static gint save_image (char *filename, gint32 image, gint32 layer) {
}
}
/* do we have a comment? If so, create a new parasite to hold it,
* and attach it to the image. The attach function automatically
* detaches a previous incarnation of the parasite. */
if (image_comment && *image_comment != '\000')
{
GParasite *parasite;
TIFFSetField (tif, TIFFTAG_IMAGEDESCRIPTION, image_comment);
parasite = gparasite_new ("GIF2", "CMNT", 1,
strlen(image_comment)+1, image_comment);
gimp_image_attach_parasite (image, parasite);
gparasite_free (parasite);
}
if (drawable_type == INDEXED_IMAGE)
TIFFSetField (tif, TIFFTAG_COLORMAP, red, grn, blu);
@ -871,6 +927,7 @@ static gint save_image (char *filename, gint32 image, gint32 layer) {
success = (TIFFWriteScanline (tif, data, row, 0) >= 0);
break;
default:
success = FALSE;
break;
}
@ -900,6 +957,9 @@ save_dialog ()
GtkWidget *toggle;
GtkWidget *frame;
GtkWidget *toggle_vbox;
GtkWidget *hbox;
GtkWidget *label;
GtkWidget *entry;
GSList *group;
gchar **argv;
gint argc;
@ -941,11 +1001,14 @@ save_dialog ()
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->action_area), button, TRUE, TRUE, 0);
gtk_widget_show (button);
/* hbox for compression and fillorder settings */
hbox = gtk_hbox_new (FALSE, 5);
/* compression */
frame = gtk_frame_new ("Compression");
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN);
gtk_container_border_width (GTK_CONTAINER (frame), 10);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), frame, FALSE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, FALSE, 0);
toggle_vbox = gtk_vbox_new (FALSE, 5);
gtk_container_border_width (GTK_CONTAINER (toggle_vbox), 5);
gtk_container_add (GTK_CONTAINER (frame), toggle_vbox);
@ -985,7 +1048,7 @@ save_dialog ()
frame = gtk_frame_new ("Fill Order");
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN);
gtk_container_border_width (GTK_CONTAINER (frame), 10);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), frame, FALSE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, FALSE, 0);
toggle_vbox = gtk_vbox_new (FALSE, 5);
gtk_container_border_width (GTK_CONTAINER (toggle_vbox), 5);
gtk_container_add (GTK_CONTAINER (frame), toggle_vbox);
@ -1012,6 +1075,33 @@ save_dialog ()
gtk_widget_show (toggle_vbox);
gtk_widget_show (frame);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), hbox, FALSE, TRUE, 0);
gtk_widget_show (hbox);
/* comment entry */
frame = gtk_frame_new(NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
gtk_container_border_width (GTK_CONTAINER (frame), 10);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), frame, FALSE, TRUE, 0);
hbox = gtk_hbox_new (FALSE, 5);
label = gtk_label_new ("Comment: ");
gtk_widget_show (label);
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
entry = gtk_entry_new ();
gtk_widget_show (entry);
gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
gtk_entry_set_text (GTK_ENTRY (entry), image_comment);
gtk_signal_connect (GTK_OBJECT (entry), "changed",
(GtkSignalFunc) comment_entry_callback,
NULL);
gtk_container_add (GTK_CONTAINER (frame), hbox);
gtk_widget_show (hbox);
gtk_widget_show (frame);
gtk_widget_show (dlg);
gtk_main ();
@ -1063,3 +1153,26 @@ save_toggle_update (GtkWidget *widget,
else
*toggle_val = FALSE;
}
static void
comment_entry_callback (GtkWidget *widget,
gpointer data)
{
int len;
char *text;
text = gtk_entry_get_text (GTK_ENTRY (widget));
len = strlen(text);
/* Temporary kludge for overlength strings - just return */
if (len > 240)
{
g_message ("TIFF save: Your comment string is too long.\n");
return;
}
g_free(image_comment);
image_comment = g_strdup(text);
/* g_print ("COMMENT: %s\n", image_comment); */
}

View File

@ -270,7 +270,7 @@ load_image (char *filename)
{
GPixelRgn pixel_rgn;
GDrawable *drawable;
gint32 image_ID;
gint32 volatile image_ID;
gint32 layer_ID;
struct jpeg_decompress_struct cinfo;
struct my_error_mgr jerr;
@ -451,7 +451,7 @@ save_image (char *filename,
GDrawableType drawable_type;
struct jpeg_compress_struct cinfo;
struct my_error_mgr jerr;
FILE *outfile;
FILE * volatile outfile;
guchar *temp, *t;
guchar *data;
guchar *src, *s;
@ -585,6 +585,10 @@ save_image (char *filename,
temp = (guchar *) malloc (cinfo.image_width * cinfo.input_components);
data = (guchar *) malloc (rowstride * gimp_tile_height ());
/* fault if cinfo.next_scanline isn't initially a multiple of
* gimp_tile_height */
src = NULL;
while (cinfo.next_scanline < cinfo.image_height)
{
if ((cinfo.next_scanline % gimp_tile_height ()) == 0)

View File

@ -270,7 +270,7 @@ load_image (char *filename)
{
GPixelRgn pixel_rgn;
GDrawable *drawable;
gint32 image_ID;
gint32 volatile image_ID;
gint32 layer_ID;
struct jpeg_decompress_struct cinfo;
struct my_error_mgr jerr;
@ -451,7 +451,7 @@ save_image (char *filename,
GDrawableType drawable_type;
struct jpeg_compress_struct cinfo;
struct my_error_mgr jerr;
FILE *outfile;
FILE * volatile outfile;
guchar *temp, *t;
guchar *data;
guchar *src, *s;
@ -585,6 +585,10 @@ save_image (char *filename,
temp = (guchar *) malloc (cinfo.image_width * cinfo.input_components);
data = (guchar *) malloc (rowstride * gimp_tile_height ());
/* fault if cinfo.next_scanline isn't initially a multiple of
* gimp_tile_height */
src = NULL;
while (cinfo.next_scanline < cinfo.image_height)
{
if ((cinfo.next_scanline % gimp_tile_height ()) == 0)

View File

@ -270,7 +270,7 @@ load_image (char *filename)
{
GPixelRgn pixel_rgn;
GDrawable *drawable;
gint32 image_ID;
gint32 volatile image_ID;
gint32 layer_ID;
struct jpeg_decompress_struct cinfo;
struct my_error_mgr jerr;
@ -451,7 +451,7 @@ save_image (char *filename,
GDrawableType drawable_type;
struct jpeg_compress_struct cinfo;
struct my_error_mgr jerr;
FILE *outfile;
FILE * volatile outfile;
guchar *temp, *t;
guchar *data;
guchar *src, *s;
@ -585,6 +585,10 @@ save_image (char *filename,
temp = (guchar *) malloc (cinfo.image_width * cinfo.input_components);
data = (guchar *) malloc (rowstride * gimp_tile_height ());
/* fault if cinfo.next_scanline isn't initially a multiple of
* gimp_tile_height */
src = NULL;
while (cinfo.next_scanline < cinfo.image_height)
{
if ((cinfo.next_scanline % gimp_tile_height ()) == 0)

View File

@ -270,7 +270,7 @@ load_image (char *filename)
{
GPixelRgn pixel_rgn;
GDrawable *drawable;
gint32 image_ID;
gint32 volatile image_ID;
gint32 layer_ID;
struct jpeg_decompress_struct cinfo;
struct my_error_mgr jerr;
@ -451,7 +451,7 @@ save_image (char *filename,
GDrawableType drawable_type;
struct jpeg_compress_struct cinfo;
struct my_error_mgr jerr;
FILE *outfile;
FILE * volatile outfile;
guchar *temp, *t;
guchar *data;
guchar *src, *s;
@ -585,6 +585,10 @@ save_image (char *filename,
temp = (guchar *) malloc (cinfo.image_width * cinfo.input_components);
data = (guchar *) malloc (rowstride * gimp_tile_height ());
/* fault if cinfo.next_scanline isn't initially a multiple of
* gimp_tile_height */
src = NULL;
while (cinfo.next_scanline < cinfo.image_height)
{
if ((cinfo.next_scanline % gimp_tile_height ()) == 0)

View File

@ -270,7 +270,7 @@ load_image (char *filename)
{
GPixelRgn pixel_rgn;
GDrawable *drawable;
gint32 image_ID;
gint32 volatile image_ID;
gint32 layer_ID;
struct jpeg_decompress_struct cinfo;
struct my_error_mgr jerr;
@ -451,7 +451,7 @@ save_image (char *filename,
GDrawableType drawable_type;
struct jpeg_compress_struct cinfo;
struct my_error_mgr jerr;
FILE *outfile;
FILE * volatile outfile;
guchar *temp, *t;
guchar *data;
guchar *src, *s;
@ -585,6 +585,10 @@ save_image (char *filename,
temp = (guchar *) malloc (cinfo.image_width * cinfo.input_components);
data = (guchar *) malloc (rowstride * gimp_tile_height ());
/* fault if cinfo.next_scanline isn't initially a multiple of
* gimp_tile_height */
src = NULL;
while (cinfo.next_scanline < cinfo.image_height)
{
if ((cinfo.next_scanline % gimp_tile_height ()) == 0)

View File

@ -270,7 +270,7 @@ load_image (char *filename)
{
GPixelRgn pixel_rgn;
GDrawable *drawable;
gint32 image_ID;
gint32 volatile image_ID;
gint32 layer_ID;
struct jpeg_decompress_struct cinfo;
struct my_error_mgr jerr;
@ -451,7 +451,7 @@ save_image (char *filename,
GDrawableType drawable_type;
struct jpeg_compress_struct cinfo;
struct my_error_mgr jerr;
FILE *outfile;
FILE * volatile outfile;
guchar *temp, *t;
guchar *data;
guchar *src, *s;
@ -585,6 +585,10 @@ save_image (char *filename,
temp = (guchar *) malloc (cinfo.image_width * cinfo.input_components);
data = (guchar *) malloc (rowstride * gimp_tile_height ());
/* fault if cinfo.next_scanline isn't initially a multiple of
* gimp_tile_height */
src = NULL;
while (cinfo.next_scanline < cinfo.image_height)
{
if ((cinfo.next_scanline % gimp_tile_height ()) == 0)

View File

@ -36,6 +36,7 @@
#include "gtk/gtk.h"
#include "libgimp/gimp.h"
typedef struct
{
gint compression;
@ -68,7 +69,10 @@ static void save_ok_callback (GtkWidget *widget,
gpointer data);
static void save_toggle_update (GtkWidget *widget,
gpointer data);
static void comment_entry_callback (GtkWidget *widget,
gpointer data);
#define DEFAULT_COMMENT "Created with The GIMP"
GPlugInInfo PLUG_IN_INFO =
{
@ -89,6 +93,7 @@ static TiffSaveInterface tsint =
FALSE /* run */
};
static char *image_comment;
MAIN ()
@ -149,6 +154,9 @@ query ()
gimp_register_save_handler ("file_tiff_save", "tif,tiff", "");
}
static void
run (char *name,
int nparams,
@ -187,6 +195,21 @@ run (char *name,
else if (strcmp (name, "file_tiff_save") == 0)
{
int image = param[1].data.d_int32;
/* get the image comment either from a parasite, or from our
* compiled-in default */
{
GParasite *parasite;
image_comment = NULL;
parasite = gimp_image_find_parasite(image, "GIF2", "CMNT");
if (!gparasite_is_error(parasite))
image_comment = g_strdup(parasite->data);
gparasite_free(parasite);
if (!image_comment)
image_comment = g_strdup(DEFAULT_COMMENT);
}
switch (run_mode)
{
case RUN_INTERACTIVE:
@ -401,6 +424,26 @@ static gint32 load_image (char *filename) {
gparasite_free(parasite);
/* Attach a parasite containing the image description. Pretend to
* be a GIF2 comment so other plugins will use this description as
* an image comment where appropriate. */
{
char *img_desc;
if (TIFFGetField (tif, TIFFTAG_IMAGEDESCRIPTION, &img_desc))
{
int len;
len = strlen(img_desc) + 1;
len = MIN(len, 241);
img_desc[len-1] = '\000';
parasite = gparasite_new("GIF2", "CMNT", 1, len, img_desc);
gimp_image_attach_parasite(image, parasite);
gparasite_free(parasite);
}
}
/* any resolution info in the file? */
{
float xres=0, yres=0;
@ -802,7 +845,6 @@ static gint save_image (char *filename, gint32 image, gint32 layer) {
TIFFSetField (tif, TIFFTAG_PHOTOMETRIC, photometric);
TIFFSetField (tif, TIFFTAG_FILLORDER, fillorder);
TIFFSetField (tif, TIFFTAG_DOCUMENTNAME, filename);
TIFFSetField (tif, TIFFTAG_IMAGEDESCRIPTION, "Created with The GIMP");
TIFFSetField (tif, TIFFTAG_SAMPLESPERPIXEL, samplesperpixel);
TIFFSetField (tif, TIFFTAG_ROWSPERSTRIP, rowsperstrip);
/* TIFFSetField( tif, TIFFTAG_STRIPBYTECOUNTS, rows / rowsperstrip ); */
@ -819,6 +861,20 @@ static gint save_image (char *filename, gint32 image, gint32 layer) {
}
}
/* do we have a comment? If so, create a new parasite to hold it,
* and attach it to the image. The attach function automatically
* detaches a previous incarnation of the parasite. */
if (image_comment && *image_comment != '\000')
{
GParasite *parasite;
TIFFSetField (tif, TIFFTAG_IMAGEDESCRIPTION, image_comment);
parasite = gparasite_new ("GIF2", "CMNT", 1,
strlen(image_comment)+1, image_comment);
gimp_image_attach_parasite (image, parasite);
gparasite_free (parasite);
}
if (drawable_type == INDEXED_IMAGE)
TIFFSetField (tif, TIFFTAG_COLORMAP, red, grn, blu);
@ -871,6 +927,7 @@ static gint save_image (char *filename, gint32 image, gint32 layer) {
success = (TIFFWriteScanline (tif, data, row, 0) >= 0);
break;
default:
success = FALSE;
break;
}
@ -900,6 +957,9 @@ save_dialog ()
GtkWidget *toggle;
GtkWidget *frame;
GtkWidget *toggle_vbox;
GtkWidget *hbox;
GtkWidget *label;
GtkWidget *entry;
GSList *group;
gchar **argv;
gint argc;
@ -941,11 +1001,14 @@ save_dialog ()
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->action_area), button, TRUE, TRUE, 0);
gtk_widget_show (button);
/* hbox for compression and fillorder settings */
hbox = gtk_hbox_new (FALSE, 5);
/* compression */
frame = gtk_frame_new ("Compression");
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN);
gtk_container_border_width (GTK_CONTAINER (frame), 10);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), frame, FALSE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, FALSE, 0);
toggle_vbox = gtk_vbox_new (FALSE, 5);
gtk_container_border_width (GTK_CONTAINER (toggle_vbox), 5);
gtk_container_add (GTK_CONTAINER (frame), toggle_vbox);
@ -985,7 +1048,7 @@ save_dialog ()
frame = gtk_frame_new ("Fill Order");
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN);
gtk_container_border_width (GTK_CONTAINER (frame), 10);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), frame, FALSE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, FALSE, 0);
toggle_vbox = gtk_vbox_new (FALSE, 5);
gtk_container_border_width (GTK_CONTAINER (toggle_vbox), 5);
gtk_container_add (GTK_CONTAINER (frame), toggle_vbox);
@ -1012,6 +1075,33 @@ save_dialog ()
gtk_widget_show (toggle_vbox);
gtk_widget_show (frame);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), hbox, FALSE, TRUE, 0);
gtk_widget_show (hbox);
/* comment entry */
frame = gtk_frame_new(NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
gtk_container_border_width (GTK_CONTAINER (frame), 10);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), frame, FALSE, TRUE, 0);
hbox = gtk_hbox_new (FALSE, 5);
label = gtk_label_new ("Comment: ");
gtk_widget_show (label);
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
entry = gtk_entry_new ();
gtk_widget_show (entry);
gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
gtk_entry_set_text (GTK_ENTRY (entry), image_comment);
gtk_signal_connect (GTK_OBJECT (entry), "changed",
(GtkSignalFunc) comment_entry_callback,
NULL);
gtk_container_add (GTK_CONTAINER (frame), hbox);
gtk_widget_show (hbox);
gtk_widget_show (frame);
gtk_widget_show (dlg);
gtk_main ();
@ -1063,3 +1153,26 @@ save_toggle_update (GtkWidget *widget,
else
*toggle_val = FALSE;
}
static void
comment_entry_callback (GtkWidget *widget,
gpointer data)
{
int len;
char *text;
text = gtk_entry_get_text (GTK_ENTRY (widget));
len = strlen(text);
/* Temporary kludge for overlength strings - just return */
if (len > 240)
{
g_message ("TIFF save: Your comment string is too long.\n");
return;
}
g_free(image_comment);
image_comment = g_strdup(text);
/* g_print ("COMMENT: %s\n", image_comment); */
}