mirror of https://github.com/GNOME/gimp.git
app/layer.c app/layers_dialog.c reviewed code in an attempt to fix the
2000-12-03 Sven Neumann <sven@gimp.org> * app/layer.c * app/layers_dialog.c * plug-ins/common/jpeg.c: reviewed code in an attempt to fix the crash-on-jpeg-save. The only thing that I have changed (despite lots of indentation) is that we now connect the preview rewdraw using gtk_signal_connect_while_alive() which should keep gimp from trying to create previews of nonexistant drawables. Updated german translation.
This commit is contained in:
parent
d7adc8ad08
commit
0d9382fb04
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
2000-12-03 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/layer.c
|
||||
* app/layers_dialog.c
|
||||
* plug-ins/common/jpeg.c: reviewed code in an attempt to fix the
|
||||
crash-on-jpeg-save. The only thing that I have changed (despite
|
||||
lots of indentation) is that we now connect the preview rewdraw
|
||||
using gtk_signal_connect_while_alive() which should keep gimp from
|
||||
trying to create previews of nonexistant drawables.
|
||||
|
||||
2000-12-03 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* libgimp/gimpunitmenu.c (gimp_unit_menu_new): set empty menu_items
|
||||
|
|
|
@ -97,7 +97,7 @@ gimp_layer_get_type (void)
|
|||
static void
|
||||
gimp_layer_class_init (GimpLayerClass *class)
|
||||
{
|
||||
GtkObjectClass *object_class;
|
||||
GtkObjectClass *object_class;
|
||||
GimpDrawableClass *drawable_class;
|
||||
|
||||
object_class = (GtkObjectClass*) class;
|
||||
|
@ -210,9 +210,11 @@ transform_color (GImage *gimage,
|
|||
GimpDrawable *drawable,
|
||||
GimpImageBaseType type)
|
||||
{
|
||||
int i, h;
|
||||
unsigned char * s, * d;
|
||||
void * pr;
|
||||
gint i;
|
||||
gint h;
|
||||
guchar *s;
|
||||
guchar *d;
|
||||
gpointer pr;
|
||||
|
||||
for (pr = pixel_regions_register (2, layerPR, bufPR);
|
||||
pr != NULL;
|
||||
|
@ -252,7 +254,7 @@ layer_new (GimpImage *gimage,
|
|||
gint opacity,
|
||||
LayerModeEffects mode)
|
||||
{
|
||||
Layer * layer;
|
||||
Layer *layer;
|
||||
|
||||
if (width == 0 || height == 0)
|
||||
{
|
||||
|
@ -293,6 +295,7 @@ layer_ref (Layer *layer)
|
|||
{
|
||||
gtk_object_ref (GTK_OBJECT (layer));
|
||||
gtk_object_sink (GTK_OBJECT (layer));
|
||||
|
||||
return layer;
|
||||
}
|
||||
|
||||
|
@ -306,23 +309,25 @@ Layer *
|
|||
layer_copy (Layer *layer,
|
||||
gboolean add_alpha)
|
||||
{
|
||||
gchar * layer_name;
|
||||
Layer * new_layer;
|
||||
GimpImageType new_type;
|
||||
gchar *ext;
|
||||
gint number;
|
||||
gchar *name;
|
||||
gint len;
|
||||
PixelRegion srcPR, destPR;
|
||||
gchar *layer_name;
|
||||
Layer *new_layer;
|
||||
GimpImageType new_type;
|
||||
gchar *ext;
|
||||
gint number;
|
||||
gchar *name;
|
||||
gint len;
|
||||
PixelRegion srcPR;
|
||||
PixelRegion destPR;
|
||||
|
||||
/* formulate the new layer name */
|
||||
name = layer_get_name (layer);
|
||||
ext = strrchr (name, '#');
|
||||
len = strlen (_("copy"));
|
||||
|
||||
if ((strlen(name) >= len &&
|
||||
strcmp (&name[strlen (name) - len], _("copy")) == 0) ||
|
||||
(ext && (number = atoi (ext + 1)) > 0 &&
|
||||
((int) (log10 (number) + 1)) == strlen (ext + 1)))
|
||||
((gint) (log10 (number) + 1)) == strlen (ext + 1)))
|
||||
/* don't have redundant "copy"s */
|
||||
layer_name = g_strdup (name);
|
||||
else
|
||||
|
@ -424,8 +429,9 @@ layer_new_from_tiles (GimpImage *gimage,
|
|||
gint opacity,
|
||||
LayerModeEffects mode)
|
||||
{
|
||||
Layer * new_layer;
|
||||
PixelRegion layerPR, bufPR;
|
||||
Layer *new_layer;
|
||||
PixelRegion layerPR;
|
||||
PixelRegion bufPR;
|
||||
|
||||
/* Function copies buffer to a layer
|
||||
* taking into consideration the possibility of transforming
|
||||
|
@ -452,11 +458,13 @@ layer_new_from_tiles (GimpImage *gimage,
|
|||
/* Configure the pixel regions */
|
||||
pixel_region_init (&layerPR, GIMP_DRAWABLE (new_layer)->tiles,
|
||||
0, 0,
|
||||
GIMP_DRAWABLE (new_layer)->width, GIMP_DRAWABLE (new_layer)->height,
|
||||
GIMP_DRAWABLE (new_layer)->width,
|
||||
GIMP_DRAWABLE (new_layer)->height,
|
||||
TRUE);
|
||||
pixel_region_init (&bufPR, tiles,
|
||||
0, 0,
|
||||
GIMP_DRAWABLE (new_layer)->width, GIMP_DRAWABLE (new_layer)->height,
|
||||
GIMP_DRAWABLE (new_layer)->width,
|
||||
GIMP_DRAWABLE (new_layer)->height,
|
||||
FALSE);
|
||||
|
||||
if ((tiles->bpp == 4 && GIMP_DRAWABLE (new_layer)->type == RGBA_GIMAGE) ||
|
||||
|
@ -467,7 +475,7 @@ layer_new_from_tiles (GimpImage *gimage,
|
|||
/* Transform the contents of the buf to the new_layer */
|
||||
transform_color (gimage, &layerPR, &bufPR, GIMP_DRAWABLE (new_layer),
|
||||
(tiles->bpp == 4) ? RGB : GRAY);
|
||||
|
||||
|
||||
return new_layer;
|
||||
}
|
||||
|
||||
|
@ -488,7 +496,8 @@ layer_add_mask (Layer *layer,
|
|||
|
||||
drawable_update (GIMP_DRAWABLE(layer),
|
||||
0, 0,
|
||||
GIMP_DRAWABLE(layer)->width, GIMP_DRAWABLE(layer)->height);
|
||||
GIMP_DRAWABLE(layer)->width,
|
||||
GIMP_DRAWABLE(layer)->height);
|
||||
|
||||
return layer->mask;
|
||||
}
|
||||
|
@ -497,12 +506,13 @@ LayerMask *
|
|||
layer_create_mask (Layer *layer,
|
||||
AddMaskType add_mask_type)
|
||||
{
|
||||
PixelRegion maskPR, layerPR;
|
||||
LayerMask *mask;
|
||||
gchar *mask_name;
|
||||
guchar black[3] = {0, 0, 0};
|
||||
guchar white_mask = OPAQUE_OPACITY;
|
||||
guchar black_mask = TRANSPARENT_OPACITY;
|
||||
PixelRegion maskPR;
|
||||
PixelRegion layerPR;
|
||||
LayerMask *mask;
|
||||
gchar *mask_name;
|
||||
guchar black[3] = {0, 0, 0};
|
||||
guchar white_mask = OPAQUE_OPACITY;
|
||||
guchar black_mask = TRANSPARENT_OPACITY;
|
||||
|
||||
mask_name = g_strdup_printf (_("%s mask"), GIMP_DRAWABLE (layer)->name);
|
||||
|
||||
|
@ -951,11 +961,15 @@ layer_scale (Layer *layer,
|
|||
else
|
||||
{
|
||||
new_offset_x = (gint)(((gdouble) new_width *
|
||||
GIMP_DRAWABLE(layer)->offset_x / (gdouble) GIMP_DRAWABLE(layer)->width));
|
||||
GIMP_DRAWABLE(layer)->offset_x /
|
||||
(gdouble) GIMP_DRAWABLE(layer)->width));
|
||||
new_offset_y = (gint)(((gdouble) new_height *
|
||||
GIMP_DRAWABLE(layer)->offset_y / (gdouble) GIMP_DRAWABLE(layer)->height));
|
||||
GIMP_DRAWABLE(layer)->offset_y /
|
||||
(gdouble) GIMP_DRAWABLE(layer)->height));
|
||||
}
|
||||
layer_scale_lowlevel (layer, new_width, new_height, new_offset_x, new_offset_y);
|
||||
layer_scale_lowlevel (layer,
|
||||
new_width, new_height,
|
||||
new_offset_x, new_offset_y);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -975,7 +989,7 @@ layer_resize (Layer *layer,
|
|||
|
||||
x1 = CLAMP (offx, 0, new_width);
|
||||
y1 = CLAMP (offy, 0, new_height);
|
||||
x2 = CLAMP ((offx + GIMP_DRAWABLE(layer)->width), 0, new_width);
|
||||
x2 = CLAMP ((offx + GIMP_DRAWABLE(layer)->width), 0, new_width);
|
||||
y2 = CLAMP ((offy + GIMP_DRAWABLE(layer)->height), 0, new_height);
|
||||
w = x2 - x1;
|
||||
h = y2 - y1;
|
||||
|
@ -1014,7 +1028,8 @@ layer_resize (Layer *layer,
|
|||
FALSE);
|
||||
|
||||
/* Allocate the new layer, configure dest region */
|
||||
new_tiles = tile_manager_new (new_width, new_height, GIMP_DRAWABLE(layer)->bytes);
|
||||
new_tiles = tile_manager_new (new_width, new_height,
|
||||
GIMP_DRAWABLE(layer)->bytes);
|
||||
pixel_region_init (&destPR, new_tiles,
|
||||
0, 0,
|
||||
new_width, new_height,
|
||||
|
@ -1030,7 +1045,8 @@ layer_resize (Layer *layer,
|
|||
else
|
||||
{
|
||||
unsigned char bg[3];
|
||||
gimage_get_background (GIMP_DRAWABLE(layer)->gimage, GIMP_DRAWABLE(layer), bg);
|
||||
gimage_get_background (GIMP_DRAWABLE(layer)->gimage,
|
||||
GIMP_DRAWABLE(layer), bg);
|
||||
color_region (&destPR, bg);
|
||||
}
|
||||
pixel_region_init (&destPR, new_tiles,
|
||||
|
@ -1203,7 +1219,8 @@ layer_pick_correlate (Layer *layer,
|
|||
/* Otherwise, determine if the alpha value at
|
||||
* the given point is non-zero
|
||||
*/
|
||||
tile = tile_manager_get_tile (GIMP_DRAWABLE(layer)->tiles, x, y, TRUE, FALSE);
|
||||
tile = tile_manager_get_tile (GIMP_DRAWABLE(layer)->tiles,
|
||||
x, y, TRUE, FALSE);
|
||||
|
||||
val = * ((unsigned char*) tile_data_pointer (tile,
|
||||
x % TILE_WIDTH,
|
||||
|
@ -1212,7 +1229,8 @@ layer_pick_correlate (Layer *layer,
|
|||
if (layer->mask)
|
||||
{
|
||||
unsigned char *ptr;
|
||||
mask_tile = tile_manager_get_tile (GIMP_DRAWABLE(layer->mask)->tiles, x, y, TRUE, FALSE);
|
||||
mask_tile = tile_manager_get_tile (GIMP_DRAWABLE(layer->mask)->tiles,
|
||||
x, y, TRUE, FALSE);
|
||||
ptr = tile_data_pointer (mask_tile, x % TILE_WIDTH, y % TILE_HEIGHT);
|
||||
val = val * (*ptr) / 255;
|
||||
tile_release (mask_tile, FALSE);
|
||||
|
@ -1287,26 +1305,27 @@ layer_preview_private (Layer *layer,
|
|||
gint w,
|
||||
gint h)
|
||||
{
|
||||
GImage *gimage;
|
||||
TempBuf *preview_buf;
|
||||
PixelRegion srcPR, destPR;
|
||||
GimpImageBaseType type;
|
||||
gint bytes;
|
||||
gint subsample;
|
||||
TempBuf *ret_buf;
|
||||
GImage *gimage;
|
||||
TempBuf *preview_buf;
|
||||
PixelRegion srcPR, destPR;
|
||||
GimpImageBaseType type;
|
||||
gint bytes;
|
||||
gint subsample;
|
||||
TempBuf *ret_buf;
|
||||
|
||||
type = RGB;
|
||||
bytes = 0;
|
||||
|
||||
/* The easy way */
|
||||
if (GIMP_DRAWABLE(layer)->preview_valid &&
|
||||
(ret_buf = gimp_preview_cache_get (&(GIMP_DRAWABLE(layer)->preview_cache), w,h)))
|
||||
if (GIMP_DRAWABLE (layer)->preview_valid &&
|
||||
(ret_buf =
|
||||
gimp_preview_cache_get (&(GIMP_DRAWABLE (layer)->preview_cache), w, h)))
|
||||
return ret_buf;
|
||||
/* The hard way */
|
||||
else
|
||||
{
|
||||
gimage = GIMP_DRAWABLE(layer)->gimage;
|
||||
switch (GIMP_DRAWABLE(layer)->type)
|
||||
gimage = GIMP_DRAWABLE (layer)->gimage;
|
||||
switch (GIMP_DRAWABLE (layer)->type)
|
||||
{
|
||||
case RGB_GIMAGE: case RGBA_GIMAGE:
|
||||
type = RGB;
|
||||
|
@ -1333,7 +1352,8 @@ layer_preview_private (Layer *layer,
|
|||
|
||||
pixel_region_init (&srcPR, GIMP_DRAWABLE(layer)->tiles,
|
||||
0, 0,
|
||||
GIMP_DRAWABLE(layer)->width, GIMP_DRAWABLE(layer)->height,
|
||||
GIMP_DRAWABLE(layer)->width,
|
||||
GIMP_DRAWABLE(layer)->height,
|
||||
FALSE);
|
||||
|
||||
preview_buf = temp_buf_new (w, h, bytes, 0, 0, NULL);
|
||||
|
@ -1351,7 +1371,8 @@ layer_preview_private (Layer *layer,
|
|||
|
||||
GIMP_DRAWABLE (layer)->preview_valid = TRUE;
|
||||
|
||||
gimp_preview_cache_add (&(GIMP_DRAWABLE (layer)->preview_cache), preview_buf);
|
||||
gimp_preview_cache_add (&(GIMP_DRAWABLE (layer)->preview_cache),
|
||||
preview_buf);
|
||||
|
||||
return preview_buf;
|
||||
}
|
||||
|
@ -1386,11 +1407,11 @@ layer_mask_preview_private (Layer *layer,
|
|||
gint w,
|
||||
gint h)
|
||||
{
|
||||
TempBuf *preview_buf;
|
||||
LayerMask *mask;
|
||||
PixelRegion srcPR, destPR;
|
||||
gint subsample;
|
||||
TempBuf *ret_buf;
|
||||
TempBuf *preview_buf;
|
||||
LayerMask *mask;
|
||||
PixelRegion srcPR, destPR;
|
||||
gint subsample;
|
||||
TempBuf *ret_buf;
|
||||
|
||||
mask = layer->mask;
|
||||
if (!mask)
|
||||
|
@ -1398,7 +1419,8 @@ layer_mask_preview_private (Layer *layer,
|
|||
|
||||
/* The easy way */
|
||||
if (GIMP_DRAWABLE(mask)->preview_valid &&
|
||||
(ret_buf = gimp_preview_cache_get (&(GIMP_DRAWABLE(mask)->preview_cache), w, h)))
|
||||
(ret_buf = gimp_preview_cache_get (&(GIMP_DRAWABLE(mask)->preview_cache),
|
||||
w, h)))
|
||||
return ret_buf;
|
||||
/* The hard way */
|
||||
else
|
||||
|
@ -1413,7 +1435,8 @@ layer_mask_preview_private (Layer *layer,
|
|||
|
||||
pixel_region_init (&srcPR, GIMP_DRAWABLE(mask)->tiles,
|
||||
0, 0,
|
||||
GIMP_DRAWABLE(mask)->width, GIMP_DRAWABLE(mask)->height,
|
||||
GIMP_DRAWABLE(mask)->width,
|
||||
GIMP_DRAWABLE(mask)->height,
|
||||
FALSE);
|
||||
|
||||
preview_buf = temp_buf_new (w, h, 1, 0, 0, NULL);
|
||||
|
@ -1424,7 +1447,7 @@ layer_mask_preview_private (Layer *layer,
|
|||
destPR.rowstride = w * destPR.bytes;
|
||||
destPR.data = temp_buf_data (preview_buf);
|
||||
|
||||
layer_preview_scale (1 /* GRAY */, NULL, &srcPR, &destPR, subsample);
|
||||
layer_preview_scale (GRAY, NULL, &srcPR, &destPR, subsample);
|
||||
|
||||
if (!GIMP_DRAWABLE (mask)->preview_valid)
|
||||
gimp_preview_cache_invalidate (&(GIMP_DRAWABLE (mask)->preview_cache));
|
||||
|
@ -1447,9 +1470,9 @@ layer_mask_preview (Layer *layer,
|
|||
width <= PREVIEW_CACHE_PRIME_WIDTH &&
|
||||
height <= PREVIEW_CACHE_PRIME_HEIGHT)
|
||||
{
|
||||
TempBuf * tb = layer_mask_preview_private(layer,
|
||||
PREVIEW_CACHE_PRIME_WIDTH,
|
||||
PREVIEW_CACHE_PRIME_HEIGHT);
|
||||
TempBuf * tb = layer_mask_preview_private (layer,
|
||||
PREVIEW_CACHE_PRIME_WIDTH,
|
||||
PREVIEW_CACHE_PRIME_HEIGHT);
|
||||
|
||||
/* Save the 2nd call */
|
||||
if (width == PREVIEW_CACHE_PRIME_WIDTH &&
|
||||
|
@ -1479,18 +1502,15 @@ layer_set_tattoo (const Layer *layer,
|
|||
void
|
||||
layer_invalidate_previews (GimpImage *gimage)
|
||||
{
|
||||
GSList * tmp;
|
||||
Layer * layer;
|
||||
GSList *tmp;
|
||||
Layer *layer;
|
||||
|
||||
g_return_if_fail (gimage != NULL);
|
||||
|
||||
tmp = gimage->layers;
|
||||
|
||||
while (tmp)
|
||||
for (tmp = gimage->layers; tmp; tmp = g_slist_next (tmp))
|
||||
{
|
||||
layer = (Layer *) tmp->data;
|
||||
gimp_drawable_invalidate_preview (GIMP_DRAWABLE(layer), TRUE);
|
||||
tmp = g_slist_next (tmp);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1502,27 +1522,27 @@ layer_preview_scale (GimpImageBaseType type,
|
|||
gint subsample)
|
||||
{
|
||||
#define EPSILON 0.000001
|
||||
guchar *src, *s;
|
||||
guchar *dest, *d;
|
||||
guchar *src, *s;
|
||||
guchar *dest, *d;
|
||||
gdouble *row, *r;
|
||||
gint destwidth;
|
||||
gint src_row, src_col;
|
||||
gint bytes, b;
|
||||
gint width, height;
|
||||
gint orig_width, orig_height;
|
||||
gdouble x_rat, y_rat;
|
||||
gdouble x_cum, y_cum;
|
||||
gdouble x_last, y_last;
|
||||
gdouble * x_frac, y_frac, tot_frac;
|
||||
gint i, j;
|
||||
gint frac;
|
||||
gint destwidth;
|
||||
gint src_row, src_col;
|
||||
gint bytes, b;
|
||||
gint width, height;
|
||||
gint orig_width, orig_height;
|
||||
gdouble x_rat, y_rat;
|
||||
gdouble x_cum, y_cum;
|
||||
gdouble x_last, y_last;
|
||||
gdouble *x_frac, y_frac, tot_frac;
|
||||
gint i, j;
|
||||
gint frac;
|
||||
gboolean advance_dest;
|
||||
guchar rgb[MAX_CHANNELS];
|
||||
guchar rgb[MAX_CHANNELS];
|
||||
|
||||
orig_width = srcPR->w / subsample;
|
||||
orig_height = srcPR->h / subsample;
|
||||
width = destPR->w;
|
||||
height = destPR->h;
|
||||
width = destPR->w;
|
||||
height = destPR->h;
|
||||
|
||||
/* Some calculations... */
|
||||
bytes = destPR->bytes;
|
||||
|
@ -1568,7 +1588,12 @@ layer_preview_scale (GimpImageBaseType type,
|
|||
y_cum = (double) src_row;
|
||||
y_last = y_cum;
|
||||
|
||||
pixel_region_get_row (srcPR, 0, src_row * subsample, orig_width * subsample, src, subsample);
|
||||
pixel_region_get_row (srcPR,
|
||||
0,
|
||||
src_row * subsample,
|
||||
orig_width * subsample,
|
||||
src,
|
||||
subsample);
|
||||
|
||||
/* Scale the selected region */
|
||||
for (i = 0; i < height; )
|
||||
|
@ -1657,7 +1682,12 @@ layer_preview_scale (GimpImageBaseType type,
|
|||
i++;
|
||||
}
|
||||
else
|
||||
pixel_region_get_row (srcPR, 0, src_row * subsample, orig_width * subsample, src, subsample);
|
||||
pixel_region_get_row (srcPR,
|
||||
0,
|
||||
src_row * subsample,
|
||||
orig_width * subsample,
|
||||
src,
|
||||
subsample);
|
||||
}
|
||||
|
||||
/* free up temporary arrays */
|
||||
|
@ -1688,8 +1718,8 @@ layer_mask_new (GimpImage *gimage,
|
|||
gint opacity,
|
||||
guchar *col)
|
||||
{
|
||||
LayerMask * layer_mask;
|
||||
gint i;
|
||||
LayerMask *layer_mask;
|
||||
gint i;
|
||||
|
||||
layer_mask = gtk_type_new (gimp_layer_mask_get_type ());
|
||||
|
||||
|
@ -1721,12 +1751,13 @@ layer_mask_new (GimpImage *gimage,
|
|||
LayerMask *
|
||||
layer_mask_copy (LayerMask *layer_mask)
|
||||
{
|
||||
gchar * layer_mask_name;
|
||||
LayerMask * new_layer_mask;
|
||||
PixelRegion srcPR, destPR;
|
||||
gchar *layer_mask_name;
|
||||
LayerMask *new_layer_mask;
|
||||
PixelRegion srcPR, destPR;
|
||||
|
||||
/* formulate the new layer_mask name */
|
||||
layer_mask_name = g_strdup_printf (_("%s copy"), GIMP_DRAWABLE(layer_mask)->name);
|
||||
layer_mask_name = g_strdup_printf (_("%s copy"),
|
||||
GIMP_DRAWABLE(layer_mask)->name);
|
||||
|
||||
/* allocate a new layer_mask object */
|
||||
new_layer_mask = layer_mask_new (GIMP_DRAWABLE(layer_mask)->gimage,
|
||||
|
@ -1735,19 +1766,25 @@ layer_mask_copy (LayerMask *layer_mask)
|
|||
layer_mask_name,
|
||||
GIMP_CHANNEL(layer_mask)->opacity,
|
||||
GIMP_CHANNEL(layer_mask)->col);
|
||||
GIMP_DRAWABLE(new_layer_mask)->visible = GIMP_DRAWABLE(layer_mask)->visible;
|
||||
GIMP_DRAWABLE(new_layer_mask)->offset_x = GIMP_DRAWABLE(layer_mask)->offset_x;
|
||||
GIMP_DRAWABLE(new_layer_mask)->offset_y = GIMP_DRAWABLE(layer_mask)->offset_y;
|
||||
GIMP_CHANNEL(new_layer_mask)->show_masked = GIMP_CHANNEL(layer_mask)->show_masked;
|
||||
GIMP_DRAWABLE(new_layer_mask)->visible =
|
||||
GIMP_DRAWABLE(layer_mask)->visible;
|
||||
GIMP_DRAWABLE(new_layer_mask)->offset_x =
|
||||
GIMP_DRAWABLE(layer_mask)->offset_x;
|
||||
GIMP_DRAWABLE(new_layer_mask)->offset_y =
|
||||
GIMP_DRAWABLE(layer_mask)->offset_y;
|
||||
GIMP_CHANNEL(new_layer_mask)->show_masked =
|
||||
GIMP_CHANNEL(layer_mask)->show_masked;
|
||||
|
||||
/* copy the contents across layer masks */
|
||||
pixel_region_init (&srcPR, GIMP_DRAWABLE(layer_mask)->tiles,
|
||||
0, 0,
|
||||
GIMP_DRAWABLE(layer_mask)->width, GIMP_DRAWABLE(layer_mask)->height,
|
||||
GIMP_DRAWABLE(layer_mask)->width,
|
||||
GIMP_DRAWABLE(layer_mask)->height,
|
||||
FALSE);
|
||||
pixel_region_init (&destPR, GIMP_DRAWABLE(new_layer_mask)->tiles,
|
||||
0, 0,
|
||||
GIMP_DRAWABLE(layer_mask)->width, GIMP_DRAWABLE(layer_mask)->height,
|
||||
GIMP_DRAWABLE(layer_mask)->width,
|
||||
GIMP_DRAWABLE(layer_mask)->height,
|
||||
TRUE);
|
||||
copy_region (&srcPR, &destPR);
|
||||
|
||||
|
@ -1809,8 +1846,8 @@ channel_layer_mask (Channel *mask,
|
|||
Layer *layer)
|
||||
{
|
||||
PixelRegion srcPR, destPR;
|
||||
guchar empty = 0;
|
||||
gint x1, y1, x2, y2;
|
||||
guchar empty = 0;
|
||||
gint x1, y1, x2, y2;
|
||||
|
||||
/* push the current mask onto the undo stack */
|
||||
channel_push_undo (mask);
|
||||
|
@ -1830,7 +1867,8 @@ channel_layer_mask (Channel *mask,
|
|||
0, GIMP_DRAWABLE(mask)->height);
|
||||
|
||||
pixel_region_init (&srcPR, GIMP_DRAWABLE(layer->mask)->tiles,
|
||||
(x1 - GIMP_DRAWABLE(layer)->offset_x), (y1 - GIMP_DRAWABLE(layer)->offset_y),
|
||||
(x1 - GIMP_DRAWABLE(layer)->offset_x),
|
||||
(y1 - GIMP_DRAWABLE(layer)->offset_y),
|
||||
(x2 - x1), (y2 - y1),
|
||||
FALSE);
|
||||
pixel_region_init (&destPR, GIMP_DRAWABLE(mask)->tiles,
|
||||
|
|
232
app/gimplayer.c
232
app/gimplayer.c
|
@ -97,7 +97,7 @@ gimp_layer_get_type (void)
|
|||
static void
|
||||
gimp_layer_class_init (GimpLayerClass *class)
|
||||
{
|
||||
GtkObjectClass *object_class;
|
||||
GtkObjectClass *object_class;
|
||||
GimpDrawableClass *drawable_class;
|
||||
|
||||
object_class = (GtkObjectClass*) class;
|
||||
|
@ -210,9 +210,11 @@ transform_color (GImage *gimage,
|
|||
GimpDrawable *drawable,
|
||||
GimpImageBaseType type)
|
||||
{
|
||||
int i, h;
|
||||
unsigned char * s, * d;
|
||||
void * pr;
|
||||
gint i;
|
||||
gint h;
|
||||
guchar *s;
|
||||
guchar *d;
|
||||
gpointer pr;
|
||||
|
||||
for (pr = pixel_regions_register (2, layerPR, bufPR);
|
||||
pr != NULL;
|
||||
|
@ -252,7 +254,7 @@ layer_new (GimpImage *gimage,
|
|||
gint opacity,
|
||||
LayerModeEffects mode)
|
||||
{
|
||||
Layer * layer;
|
||||
Layer *layer;
|
||||
|
||||
if (width == 0 || height == 0)
|
||||
{
|
||||
|
@ -293,6 +295,7 @@ layer_ref (Layer *layer)
|
|||
{
|
||||
gtk_object_ref (GTK_OBJECT (layer));
|
||||
gtk_object_sink (GTK_OBJECT (layer));
|
||||
|
||||
return layer;
|
||||
}
|
||||
|
||||
|
@ -306,23 +309,25 @@ Layer *
|
|||
layer_copy (Layer *layer,
|
||||
gboolean add_alpha)
|
||||
{
|
||||
gchar * layer_name;
|
||||
Layer * new_layer;
|
||||
GimpImageType new_type;
|
||||
gchar *ext;
|
||||
gint number;
|
||||
gchar *name;
|
||||
gint len;
|
||||
PixelRegion srcPR, destPR;
|
||||
gchar *layer_name;
|
||||
Layer *new_layer;
|
||||
GimpImageType new_type;
|
||||
gchar *ext;
|
||||
gint number;
|
||||
gchar *name;
|
||||
gint len;
|
||||
PixelRegion srcPR;
|
||||
PixelRegion destPR;
|
||||
|
||||
/* formulate the new layer name */
|
||||
name = layer_get_name (layer);
|
||||
ext = strrchr (name, '#');
|
||||
len = strlen (_("copy"));
|
||||
|
||||
if ((strlen(name) >= len &&
|
||||
strcmp (&name[strlen (name) - len], _("copy")) == 0) ||
|
||||
(ext && (number = atoi (ext + 1)) > 0 &&
|
||||
((int) (log10 (number) + 1)) == strlen (ext + 1)))
|
||||
((gint) (log10 (number) + 1)) == strlen (ext + 1)))
|
||||
/* don't have redundant "copy"s */
|
||||
layer_name = g_strdup (name);
|
||||
else
|
||||
|
@ -424,8 +429,9 @@ layer_new_from_tiles (GimpImage *gimage,
|
|||
gint opacity,
|
||||
LayerModeEffects mode)
|
||||
{
|
||||
Layer * new_layer;
|
||||
PixelRegion layerPR, bufPR;
|
||||
Layer *new_layer;
|
||||
PixelRegion layerPR;
|
||||
PixelRegion bufPR;
|
||||
|
||||
/* Function copies buffer to a layer
|
||||
* taking into consideration the possibility of transforming
|
||||
|
@ -452,11 +458,13 @@ layer_new_from_tiles (GimpImage *gimage,
|
|||
/* Configure the pixel regions */
|
||||
pixel_region_init (&layerPR, GIMP_DRAWABLE (new_layer)->tiles,
|
||||
0, 0,
|
||||
GIMP_DRAWABLE (new_layer)->width, GIMP_DRAWABLE (new_layer)->height,
|
||||
GIMP_DRAWABLE (new_layer)->width,
|
||||
GIMP_DRAWABLE (new_layer)->height,
|
||||
TRUE);
|
||||
pixel_region_init (&bufPR, tiles,
|
||||
0, 0,
|
||||
GIMP_DRAWABLE (new_layer)->width, GIMP_DRAWABLE (new_layer)->height,
|
||||
GIMP_DRAWABLE (new_layer)->width,
|
||||
GIMP_DRAWABLE (new_layer)->height,
|
||||
FALSE);
|
||||
|
||||
if ((tiles->bpp == 4 && GIMP_DRAWABLE (new_layer)->type == RGBA_GIMAGE) ||
|
||||
|
@ -467,7 +475,7 @@ layer_new_from_tiles (GimpImage *gimage,
|
|||
/* Transform the contents of the buf to the new_layer */
|
||||
transform_color (gimage, &layerPR, &bufPR, GIMP_DRAWABLE (new_layer),
|
||||
(tiles->bpp == 4) ? RGB : GRAY);
|
||||
|
||||
|
||||
return new_layer;
|
||||
}
|
||||
|
||||
|
@ -488,7 +496,8 @@ layer_add_mask (Layer *layer,
|
|||
|
||||
drawable_update (GIMP_DRAWABLE(layer),
|
||||
0, 0,
|
||||
GIMP_DRAWABLE(layer)->width, GIMP_DRAWABLE(layer)->height);
|
||||
GIMP_DRAWABLE(layer)->width,
|
||||
GIMP_DRAWABLE(layer)->height);
|
||||
|
||||
return layer->mask;
|
||||
}
|
||||
|
@ -497,12 +506,13 @@ LayerMask *
|
|||
layer_create_mask (Layer *layer,
|
||||
AddMaskType add_mask_type)
|
||||
{
|
||||
PixelRegion maskPR, layerPR;
|
||||
LayerMask *mask;
|
||||
gchar *mask_name;
|
||||
guchar black[3] = {0, 0, 0};
|
||||
guchar white_mask = OPAQUE_OPACITY;
|
||||
guchar black_mask = TRANSPARENT_OPACITY;
|
||||
PixelRegion maskPR;
|
||||
PixelRegion layerPR;
|
||||
LayerMask *mask;
|
||||
gchar *mask_name;
|
||||
guchar black[3] = {0, 0, 0};
|
||||
guchar white_mask = OPAQUE_OPACITY;
|
||||
guchar black_mask = TRANSPARENT_OPACITY;
|
||||
|
||||
mask_name = g_strdup_printf (_("%s mask"), GIMP_DRAWABLE (layer)->name);
|
||||
|
||||
|
@ -951,11 +961,15 @@ layer_scale (Layer *layer,
|
|||
else
|
||||
{
|
||||
new_offset_x = (gint)(((gdouble) new_width *
|
||||
GIMP_DRAWABLE(layer)->offset_x / (gdouble) GIMP_DRAWABLE(layer)->width));
|
||||
GIMP_DRAWABLE(layer)->offset_x /
|
||||
(gdouble) GIMP_DRAWABLE(layer)->width));
|
||||
new_offset_y = (gint)(((gdouble) new_height *
|
||||
GIMP_DRAWABLE(layer)->offset_y / (gdouble) GIMP_DRAWABLE(layer)->height));
|
||||
GIMP_DRAWABLE(layer)->offset_y /
|
||||
(gdouble) GIMP_DRAWABLE(layer)->height));
|
||||
}
|
||||
layer_scale_lowlevel (layer, new_width, new_height, new_offset_x, new_offset_y);
|
||||
layer_scale_lowlevel (layer,
|
||||
new_width, new_height,
|
||||
new_offset_x, new_offset_y);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -975,7 +989,7 @@ layer_resize (Layer *layer,
|
|||
|
||||
x1 = CLAMP (offx, 0, new_width);
|
||||
y1 = CLAMP (offy, 0, new_height);
|
||||
x2 = CLAMP ((offx + GIMP_DRAWABLE(layer)->width), 0, new_width);
|
||||
x2 = CLAMP ((offx + GIMP_DRAWABLE(layer)->width), 0, new_width);
|
||||
y2 = CLAMP ((offy + GIMP_DRAWABLE(layer)->height), 0, new_height);
|
||||
w = x2 - x1;
|
||||
h = y2 - y1;
|
||||
|
@ -1014,7 +1028,8 @@ layer_resize (Layer *layer,
|
|||
FALSE);
|
||||
|
||||
/* Allocate the new layer, configure dest region */
|
||||
new_tiles = tile_manager_new (new_width, new_height, GIMP_DRAWABLE(layer)->bytes);
|
||||
new_tiles = tile_manager_new (new_width, new_height,
|
||||
GIMP_DRAWABLE(layer)->bytes);
|
||||
pixel_region_init (&destPR, new_tiles,
|
||||
0, 0,
|
||||
new_width, new_height,
|
||||
|
@ -1030,7 +1045,8 @@ layer_resize (Layer *layer,
|
|||
else
|
||||
{
|
||||
unsigned char bg[3];
|
||||
gimage_get_background (GIMP_DRAWABLE(layer)->gimage, GIMP_DRAWABLE(layer), bg);
|
||||
gimage_get_background (GIMP_DRAWABLE(layer)->gimage,
|
||||
GIMP_DRAWABLE(layer), bg);
|
||||
color_region (&destPR, bg);
|
||||
}
|
||||
pixel_region_init (&destPR, new_tiles,
|
||||
|
@ -1203,7 +1219,8 @@ layer_pick_correlate (Layer *layer,
|
|||
/* Otherwise, determine if the alpha value at
|
||||
* the given point is non-zero
|
||||
*/
|
||||
tile = tile_manager_get_tile (GIMP_DRAWABLE(layer)->tiles, x, y, TRUE, FALSE);
|
||||
tile = tile_manager_get_tile (GIMP_DRAWABLE(layer)->tiles,
|
||||
x, y, TRUE, FALSE);
|
||||
|
||||
val = * ((unsigned char*) tile_data_pointer (tile,
|
||||
x % TILE_WIDTH,
|
||||
|
@ -1212,7 +1229,8 @@ layer_pick_correlate (Layer *layer,
|
|||
if (layer->mask)
|
||||
{
|
||||
unsigned char *ptr;
|
||||
mask_tile = tile_manager_get_tile (GIMP_DRAWABLE(layer->mask)->tiles, x, y, TRUE, FALSE);
|
||||
mask_tile = tile_manager_get_tile (GIMP_DRAWABLE(layer->mask)->tiles,
|
||||
x, y, TRUE, FALSE);
|
||||
ptr = tile_data_pointer (mask_tile, x % TILE_WIDTH, y % TILE_HEIGHT);
|
||||
val = val * (*ptr) / 255;
|
||||
tile_release (mask_tile, FALSE);
|
||||
|
@ -1287,26 +1305,27 @@ layer_preview_private (Layer *layer,
|
|||
gint w,
|
||||
gint h)
|
||||
{
|
||||
GImage *gimage;
|
||||
TempBuf *preview_buf;
|
||||
PixelRegion srcPR, destPR;
|
||||
GimpImageBaseType type;
|
||||
gint bytes;
|
||||
gint subsample;
|
||||
TempBuf *ret_buf;
|
||||
GImage *gimage;
|
||||
TempBuf *preview_buf;
|
||||
PixelRegion srcPR, destPR;
|
||||
GimpImageBaseType type;
|
||||
gint bytes;
|
||||
gint subsample;
|
||||
TempBuf *ret_buf;
|
||||
|
||||
type = RGB;
|
||||
bytes = 0;
|
||||
|
||||
/* The easy way */
|
||||
if (GIMP_DRAWABLE(layer)->preview_valid &&
|
||||
(ret_buf = gimp_preview_cache_get (&(GIMP_DRAWABLE(layer)->preview_cache), w,h)))
|
||||
if (GIMP_DRAWABLE (layer)->preview_valid &&
|
||||
(ret_buf =
|
||||
gimp_preview_cache_get (&(GIMP_DRAWABLE (layer)->preview_cache), w, h)))
|
||||
return ret_buf;
|
||||
/* The hard way */
|
||||
else
|
||||
{
|
||||
gimage = GIMP_DRAWABLE(layer)->gimage;
|
||||
switch (GIMP_DRAWABLE(layer)->type)
|
||||
gimage = GIMP_DRAWABLE (layer)->gimage;
|
||||
switch (GIMP_DRAWABLE (layer)->type)
|
||||
{
|
||||
case RGB_GIMAGE: case RGBA_GIMAGE:
|
||||
type = RGB;
|
||||
|
@ -1333,7 +1352,8 @@ layer_preview_private (Layer *layer,
|
|||
|
||||
pixel_region_init (&srcPR, GIMP_DRAWABLE(layer)->tiles,
|
||||
0, 0,
|
||||
GIMP_DRAWABLE(layer)->width, GIMP_DRAWABLE(layer)->height,
|
||||
GIMP_DRAWABLE(layer)->width,
|
||||
GIMP_DRAWABLE(layer)->height,
|
||||
FALSE);
|
||||
|
||||
preview_buf = temp_buf_new (w, h, bytes, 0, 0, NULL);
|
||||
|
@ -1351,7 +1371,8 @@ layer_preview_private (Layer *layer,
|
|||
|
||||
GIMP_DRAWABLE (layer)->preview_valid = TRUE;
|
||||
|
||||
gimp_preview_cache_add (&(GIMP_DRAWABLE (layer)->preview_cache), preview_buf);
|
||||
gimp_preview_cache_add (&(GIMP_DRAWABLE (layer)->preview_cache),
|
||||
preview_buf);
|
||||
|
||||
return preview_buf;
|
||||
}
|
||||
|
@ -1386,11 +1407,11 @@ layer_mask_preview_private (Layer *layer,
|
|||
gint w,
|
||||
gint h)
|
||||
{
|
||||
TempBuf *preview_buf;
|
||||
LayerMask *mask;
|
||||
PixelRegion srcPR, destPR;
|
||||
gint subsample;
|
||||
TempBuf *ret_buf;
|
||||
TempBuf *preview_buf;
|
||||
LayerMask *mask;
|
||||
PixelRegion srcPR, destPR;
|
||||
gint subsample;
|
||||
TempBuf *ret_buf;
|
||||
|
||||
mask = layer->mask;
|
||||
if (!mask)
|
||||
|
@ -1398,7 +1419,8 @@ layer_mask_preview_private (Layer *layer,
|
|||
|
||||
/* The easy way */
|
||||
if (GIMP_DRAWABLE(mask)->preview_valid &&
|
||||
(ret_buf = gimp_preview_cache_get (&(GIMP_DRAWABLE(mask)->preview_cache), w, h)))
|
||||
(ret_buf = gimp_preview_cache_get (&(GIMP_DRAWABLE(mask)->preview_cache),
|
||||
w, h)))
|
||||
return ret_buf;
|
||||
/* The hard way */
|
||||
else
|
||||
|
@ -1413,7 +1435,8 @@ layer_mask_preview_private (Layer *layer,
|
|||
|
||||
pixel_region_init (&srcPR, GIMP_DRAWABLE(mask)->tiles,
|
||||
0, 0,
|
||||
GIMP_DRAWABLE(mask)->width, GIMP_DRAWABLE(mask)->height,
|
||||
GIMP_DRAWABLE(mask)->width,
|
||||
GIMP_DRAWABLE(mask)->height,
|
||||
FALSE);
|
||||
|
||||
preview_buf = temp_buf_new (w, h, 1, 0, 0, NULL);
|
||||
|
@ -1424,7 +1447,7 @@ layer_mask_preview_private (Layer *layer,
|
|||
destPR.rowstride = w * destPR.bytes;
|
||||
destPR.data = temp_buf_data (preview_buf);
|
||||
|
||||
layer_preview_scale (1 /* GRAY */, NULL, &srcPR, &destPR, subsample);
|
||||
layer_preview_scale (GRAY, NULL, &srcPR, &destPR, subsample);
|
||||
|
||||
if (!GIMP_DRAWABLE (mask)->preview_valid)
|
||||
gimp_preview_cache_invalidate (&(GIMP_DRAWABLE (mask)->preview_cache));
|
||||
|
@ -1447,9 +1470,9 @@ layer_mask_preview (Layer *layer,
|
|||
width <= PREVIEW_CACHE_PRIME_WIDTH &&
|
||||
height <= PREVIEW_CACHE_PRIME_HEIGHT)
|
||||
{
|
||||
TempBuf * tb = layer_mask_preview_private(layer,
|
||||
PREVIEW_CACHE_PRIME_WIDTH,
|
||||
PREVIEW_CACHE_PRIME_HEIGHT);
|
||||
TempBuf * tb = layer_mask_preview_private (layer,
|
||||
PREVIEW_CACHE_PRIME_WIDTH,
|
||||
PREVIEW_CACHE_PRIME_HEIGHT);
|
||||
|
||||
/* Save the 2nd call */
|
||||
if (width == PREVIEW_CACHE_PRIME_WIDTH &&
|
||||
|
@ -1479,18 +1502,15 @@ layer_set_tattoo (const Layer *layer,
|
|||
void
|
||||
layer_invalidate_previews (GimpImage *gimage)
|
||||
{
|
||||
GSList * tmp;
|
||||
Layer * layer;
|
||||
GSList *tmp;
|
||||
Layer *layer;
|
||||
|
||||
g_return_if_fail (gimage != NULL);
|
||||
|
||||
tmp = gimage->layers;
|
||||
|
||||
while (tmp)
|
||||
for (tmp = gimage->layers; tmp; tmp = g_slist_next (tmp))
|
||||
{
|
||||
layer = (Layer *) tmp->data;
|
||||
gimp_drawable_invalidate_preview (GIMP_DRAWABLE(layer), TRUE);
|
||||
tmp = g_slist_next (tmp);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1502,27 +1522,27 @@ layer_preview_scale (GimpImageBaseType type,
|
|||
gint subsample)
|
||||
{
|
||||
#define EPSILON 0.000001
|
||||
guchar *src, *s;
|
||||
guchar *dest, *d;
|
||||
guchar *src, *s;
|
||||
guchar *dest, *d;
|
||||
gdouble *row, *r;
|
||||
gint destwidth;
|
||||
gint src_row, src_col;
|
||||
gint bytes, b;
|
||||
gint width, height;
|
||||
gint orig_width, orig_height;
|
||||
gdouble x_rat, y_rat;
|
||||
gdouble x_cum, y_cum;
|
||||
gdouble x_last, y_last;
|
||||
gdouble * x_frac, y_frac, tot_frac;
|
||||
gint i, j;
|
||||
gint frac;
|
||||
gint destwidth;
|
||||
gint src_row, src_col;
|
||||
gint bytes, b;
|
||||
gint width, height;
|
||||
gint orig_width, orig_height;
|
||||
gdouble x_rat, y_rat;
|
||||
gdouble x_cum, y_cum;
|
||||
gdouble x_last, y_last;
|
||||
gdouble *x_frac, y_frac, tot_frac;
|
||||
gint i, j;
|
||||
gint frac;
|
||||
gboolean advance_dest;
|
||||
guchar rgb[MAX_CHANNELS];
|
||||
guchar rgb[MAX_CHANNELS];
|
||||
|
||||
orig_width = srcPR->w / subsample;
|
||||
orig_height = srcPR->h / subsample;
|
||||
width = destPR->w;
|
||||
height = destPR->h;
|
||||
width = destPR->w;
|
||||
height = destPR->h;
|
||||
|
||||
/* Some calculations... */
|
||||
bytes = destPR->bytes;
|
||||
|
@ -1568,7 +1588,12 @@ layer_preview_scale (GimpImageBaseType type,
|
|||
y_cum = (double) src_row;
|
||||
y_last = y_cum;
|
||||
|
||||
pixel_region_get_row (srcPR, 0, src_row * subsample, orig_width * subsample, src, subsample);
|
||||
pixel_region_get_row (srcPR,
|
||||
0,
|
||||
src_row * subsample,
|
||||
orig_width * subsample,
|
||||
src,
|
||||
subsample);
|
||||
|
||||
/* Scale the selected region */
|
||||
for (i = 0; i < height; )
|
||||
|
@ -1657,7 +1682,12 @@ layer_preview_scale (GimpImageBaseType type,
|
|||
i++;
|
||||
}
|
||||
else
|
||||
pixel_region_get_row (srcPR, 0, src_row * subsample, orig_width * subsample, src, subsample);
|
||||
pixel_region_get_row (srcPR,
|
||||
0,
|
||||
src_row * subsample,
|
||||
orig_width * subsample,
|
||||
src,
|
||||
subsample);
|
||||
}
|
||||
|
||||
/* free up temporary arrays */
|
||||
|
@ -1688,8 +1718,8 @@ layer_mask_new (GimpImage *gimage,
|
|||
gint opacity,
|
||||
guchar *col)
|
||||
{
|
||||
LayerMask * layer_mask;
|
||||
gint i;
|
||||
LayerMask *layer_mask;
|
||||
gint i;
|
||||
|
||||
layer_mask = gtk_type_new (gimp_layer_mask_get_type ());
|
||||
|
||||
|
@ -1721,12 +1751,13 @@ layer_mask_new (GimpImage *gimage,
|
|||
LayerMask *
|
||||
layer_mask_copy (LayerMask *layer_mask)
|
||||
{
|
||||
gchar * layer_mask_name;
|
||||
LayerMask * new_layer_mask;
|
||||
PixelRegion srcPR, destPR;
|
||||
gchar *layer_mask_name;
|
||||
LayerMask *new_layer_mask;
|
||||
PixelRegion srcPR, destPR;
|
||||
|
||||
/* formulate the new layer_mask name */
|
||||
layer_mask_name = g_strdup_printf (_("%s copy"), GIMP_DRAWABLE(layer_mask)->name);
|
||||
layer_mask_name = g_strdup_printf (_("%s copy"),
|
||||
GIMP_DRAWABLE(layer_mask)->name);
|
||||
|
||||
/* allocate a new layer_mask object */
|
||||
new_layer_mask = layer_mask_new (GIMP_DRAWABLE(layer_mask)->gimage,
|
||||
|
@ -1735,19 +1766,25 @@ layer_mask_copy (LayerMask *layer_mask)
|
|||
layer_mask_name,
|
||||
GIMP_CHANNEL(layer_mask)->opacity,
|
||||
GIMP_CHANNEL(layer_mask)->col);
|
||||
GIMP_DRAWABLE(new_layer_mask)->visible = GIMP_DRAWABLE(layer_mask)->visible;
|
||||
GIMP_DRAWABLE(new_layer_mask)->offset_x = GIMP_DRAWABLE(layer_mask)->offset_x;
|
||||
GIMP_DRAWABLE(new_layer_mask)->offset_y = GIMP_DRAWABLE(layer_mask)->offset_y;
|
||||
GIMP_CHANNEL(new_layer_mask)->show_masked = GIMP_CHANNEL(layer_mask)->show_masked;
|
||||
GIMP_DRAWABLE(new_layer_mask)->visible =
|
||||
GIMP_DRAWABLE(layer_mask)->visible;
|
||||
GIMP_DRAWABLE(new_layer_mask)->offset_x =
|
||||
GIMP_DRAWABLE(layer_mask)->offset_x;
|
||||
GIMP_DRAWABLE(new_layer_mask)->offset_y =
|
||||
GIMP_DRAWABLE(layer_mask)->offset_y;
|
||||
GIMP_CHANNEL(new_layer_mask)->show_masked =
|
||||
GIMP_CHANNEL(layer_mask)->show_masked;
|
||||
|
||||
/* copy the contents across layer masks */
|
||||
pixel_region_init (&srcPR, GIMP_DRAWABLE(layer_mask)->tiles,
|
||||
0, 0,
|
||||
GIMP_DRAWABLE(layer_mask)->width, GIMP_DRAWABLE(layer_mask)->height,
|
||||
GIMP_DRAWABLE(layer_mask)->width,
|
||||
GIMP_DRAWABLE(layer_mask)->height,
|
||||
FALSE);
|
||||
pixel_region_init (&destPR, GIMP_DRAWABLE(new_layer_mask)->tiles,
|
||||
0, 0,
|
||||
GIMP_DRAWABLE(layer_mask)->width, GIMP_DRAWABLE(layer_mask)->height,
|
||||
GIMP_DRAWABLE(layer_mask)->width,
|
||||
GIMP_DRAWABLE(layer_mask)->height,
|
||||
TRUE);
|
||||
copy_region (&srcPR, &destPR);
|
||||
|
||||
|
@ -1809,8 +1846,8 @@ channel_layer_mask (Channel *mask,
|
|||
Layer *layer)
|
||||
{
|
||||
PixelRegion srcPR, destPR;
|
||||
guchar empty = 0;
|
||||
gint x1, y1, x2, y2;
|
||||
guchar empty = 0;
|
||||
gint x1, y1, x2, y2;
|
||||
|
||||
/* push the current mask onto the undo stack */
|
||||
channel_push_undo (mask);
|
||||
|
@ -1830,7 +1867,8 @@ channel_layer_mask (Channel *mask,
|
|||
0, GIMP_DRAWABLE(mask)->height);
|
||||
|
||||
pixel_region_init (&srcPR, GIMP_DRAWABLE(layer->mask)->tiles,
|
||||
(x1 - GIMP_DRAWABLE(layer)->offset_x), (y1 - GIMP_DRAWABLE(layer)->offset_y),
|
||||
(x1 - GIMP_DRAWABLE(layer)->offset_x),
|
||||
(y1 - GIMP_DRAWABLE(layer)->offset_y),
|
||||
(x2 - x1), (y2 - y1),
|
||||
FALSE);
|
||||
pixel_region_init (&destPR, GIMP_DRAWABLE(mask)->tiles,
|
||||
|
|
|
@ -393,7 +393,8 @@ layers_dialog_create (void)
|
|||
FALSE, FALSE, 2);
|
||||
gtk_widget_show (layersD->mode_option_menu);
|
||||
|
||||
gimp_help_set_help_data (layersD->mode_option_menu, NULL, "#paint_mode_menu");
|
||||
gimp_help_set_help_data (layersD->mode_option_menu,
|
||||
NULL, "#paint_mode_menu");
|
||||
|
||||
layersD->preserve_trans =
|
||||
gtk_check_button_new_with_label (_("Keep Trans."));
|
||||
|
@ -589,12 +590,13 @@ layers_dialog_update (GimpImage* gimage)
|
|||
/* Find the preview extents */
|
||||
layers_dialog_preview_extents ();
|
||||
|
||||
layersD->active_layer = NULL;
|
||||
layersD->active_layer = NULL;
|
||||
layersD->active_channel = NULL;
|
||||
layersD->floating_sel = NULL;
|
||||
layersD->floating_sel = NULL;
|
||||
|
||||
item_list = NULL;
|
||||
for (list = gimage->layers; list; list = g_slist_next (list))
|
||||
for (list = gimage->layers, item_list = NULL;
|
||||
list;
|
||||
list = g_slist_next (list))
|
||||
{
|
||||
/* create a layer list item */
|
||||
layer = (Layer *) list->data;
|
||||
|
@ -668,8 +670,9 @@ layers_dialog_flush (void)
|
|||
}
|
||||
|
||||
/* Switch positions of items if necessary */
|
||||
pos = 0;
|
||||
for (list = gimage->layers; list; list = g_slist_next (list))
|
||||
for (list = gimage->layers, pos = 0;
|
||||
list;
|
||||
list = g_slist_next (list))
|
||||
{
|
||||
layer = (Layer *) list->data;
|
||||
layers_dialog_position_layer (layer, pos++);
|
||||
|
@ -692,6 +695,7 @@ layers_dialog_flush (void)
|
|||
gtk_container_foreach (GTK_CONTAINER (layersD->layer_list),
|
||||
layer_widget_layer_flush, NULL);
|
||||
}
|
||||
|
||||
suspend_gimage_notify--;
|
||||
}
|
||||
|
||||
|
@ -719,19 +723,19 @@ render_preview (TempBuf *preview_buf,
|
|||
gint height,
|
||||
gint channel)
|
||||
{
|
||||
guchar *src, *s;
|
||||
guchar *cb;
|
||||
guchar *buf;
|
||||
gint a;
|
||||
gint i, j, b;
|
||||
gint x1, y1, x2, y2;
|
||||
gint rowstride;
|
||||
gint color_buf;
|
||||
gint color;
|
||||
gint alpha;
|
||||
gint has_alpha;
|
||||
gint image_bytes;
|
||||
gint offset;
|
||||
guchar *src, *s;
|
||||
guchar *cb;
|
||||
guchar *buf;
|
||||
gint a;
|
||||
gint i, j, b;
|
||||
gint x1, y1, x2, y2;
|
||||
gint rowstride;
|
||||
gint color_buf;
|
||||
gint color;
|
||||
gint alpha;
|
||||
gboolean has_alpha;
|
||||
gint image_bytes;
|
||||
gint offset;
|
||||
|
||||
alpha = ALPHA_PIX;
|
||||
|
||||
|
@ -746,10 +750,10 @@ render_preview (TempBuf *preview_buf,
|
|||
* 2) Color preview_bufs have bytes == {3, 4}
|
||||
* 3) If image is gray, then preview_buf should have bytes == {1, 2}
|
||||
*/
|
||||
color_buf = (GTK_PREVIEW (preview_widget)->type == GTK_PREVIEW_COLOR);
|
||||
color_buf = (GTK_PREVIEW (preview_widget)->type == GTK_PREVIEW_COLOR);
|
||||
image_bytes = (color_buf) ? 3 : 1;
|
||||
has_alpha = (preview_buf->bytes == 2 || preview_buf->bytes == 4);
|
||||
rowstride = preview_buf->width * preview_buf->bytes;
|
||||
has_alpha = (preview_buf->bytes == 2 || preview_buf->bytes == 4);
|
||||
rowstride = preview_buf->width * preview_buf->bytes;
|
||||
|
||||
/* Determine if the preview buf supplied is color
|
||||
* Generally, if the bytes == {3, 4}, this is true.
|
||||
|
@ -900,11 +904,11 @@ void
|
|||
render_fs_preview (GtkWidget *widget,
|
||||
GdkPixmap *pixmap)
|
||||
{
|
||||
gint w, h;
|
||||
gint x1, y1, x2, y2;
|
||||
GdkPoint poly[6];
|
||||
gint foldh, foldw;
|
||||
gint i;
|
||||
gint w, h;
|
||||
gint x1, y1, x2, y2;
|
||||
GdkPoint poly[6];
|
||||
gint foldh, foldw;
|
||||
gint i;
|
||||
|
||||
gdk_window_get_size (pixmap, &w, &h);
|
||||
|
||||
|
@ -926,10 +930,11 @@ render_fs_preview (GtkWidget *widget,
|
|||
|
||||
poly[0].x = x1 + foldw; poly[0].y = y1;
|
||||
poly[1].x = x1 + foldw; poly[1].y = y1 + foldh;
|
||||
poly[2].x = x1; poly[2].y = y1 + foldh;
|
||||
poly[3].x = x1; poly[3].y = y2;
|
||||
poly[4].x = x2; poly[4].y = y2;
|
||||
poly[5].x = x2; poly[5].y = y1;
|
||||
poly[2].x = x1; poly[2].y = y1 + foldh;
|
||||
poly[3].x = x1; poly[3].y = y2;
|
||||
poly[4].x = x2; poly[4].y = y2;
|
||||
poly[5].x = x2; poly[5].y = y1;
|
||||
|
||||
gdk_draw_polygon (pixmap, widget->style->white_gc, 1, poly, 6);
|
||||
|
||||
gdk_draw_line (pixmap, widget->style->black_gc,
|
||||
|
@ -940,6 +945,7 @@ render_fs_preview (GtkWidget *widget,
|
|||
x2, y2, x2, y1);
|
||||
gdk_draw_line (pixmap, widget->style->black_gc,
|
||||
x1 + foldw, y1, x2, y1);
|
||||
|
||||
for (i = 0; i < foldw; i++)
|
||||
gdk_draw_line (pixmap, widget->style->black_gc,
|
||||
x1 + i, y1 + foldh, x1 + i, (foldw == 1) ? y1 :
|
||||
|
@ -965,16 +971,19 @@ layers_dialog_preview_extents (void)
|
|||
|
||||
/* Get the image width and height variables, based on the gimage */
|
||||
if (gimage->width > gimage->height)
|
||||
layersD->ratio = (double) preview_size / (double) gimage->width;
|
||||
layersD->ratio = (gdouble) preview_size / (gdouble) gimage->width;
|
||||
else
|
||||
layersD->ratio = (double) preview_size / (double) gimage->height;
|
||||
layersD->ratio = (gdouble) preview_size / (gdouble) gimage->height;
|
||||
|
||||
if (preview_size)
|
||||
{
|
||||
layersD->image_width = (gint) (layersD->ratio * gimage->width);
|
||||
layersD->image_height = (gint) (layersD->ratio * gimage->height);
|
||||
if (layersD->image_width < 1) layersD->image_width = 1;
|
||||
if (layersD->image_height < 1) layersD->image_height = 1;
|
||||
|
||||
if (layersD->image_width < 1)
|
||||
layersD->image_width = 1;
|
||||
if (layersD->image_height < 1)
|
||||
layersD->image_height = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -986,18 +995,18 @@ layers_dialog_preview_extents (void)
|
|||
static void
|
||||
layers_dialog_set_menu_sensitivity (void)
|
||||
{
|
||||
gboolean fs; /* floating sel */
|
||||
gboolean ac; /* active channel */
|
||||
gboolean lm; /* layer mask */
|
||||
gboolean gimage; /* is there a gimage */
|
||||
gboolean lp; /* layers present */
|
||||
gboolean alpha; /* alpha channel present */
|
||||
gboolean indexed; /* is indexed */
|
||||
gint next_alpha;
|
||||
GSList *list;
|
||||
GSList *next;
|
||||
GSList *prev;
|
||||
Layer *layer;
|
||||
gboolean fs; /* floating sel */
|
||||
gboolean ac; /* active channel */
|
||||
gboolean lm; /* layer mask */
|
||||
gboolean gimage; /* is there a gimage */
|
||||
gboolean lp; /* layers present */
|
||||
gboolean alpha; /* alpha channel present */
|
||||
gboolean indexed; /* is indexed */
|
||||
gint next_alpha;
|
||||
GSList *list;
|
||||
GSList *next;
|
||||
GSList *prev;
|
||||
Layer *layer;
|
||||
|
||||
lp = FALSE;
|
||||
indexed = FALSE;
|
||||
|
@ -1108,7 +1117,7 @@ static void
|
|||
layers_dialog_scroll_index (gint index)
|
||||
{
|
||||
GtkAdjustment *adj;
|
||||
gint item_height;
|
||||
gint item_height;
|
||||
|
||||
item_height = 6 + (preview_size ? preview_size : layer_height);
|
||||
adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (layersD->scrolled_win));
|
||||
|
@ -1126,6 +1135,7 @@ layers_dialog_scroll_index (gint index)
|
|||
}
|
||||
|
||||
/* Commented out because this piece of code produced strange segfaults
|
||||
|
||||
static gint
|
||||
layer_dialog_idle_set_active_layer_focus (gpointer data)
|
||||
{
|
||||
|
@ -1133,6 +1143,7 @@ layer_dialog_idle_set_active_layer_focus (gpointer data)
|
|||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
static void
|
||||
|
@ -1140,7 +1151,7 @@ layers_dialog_set_active_layer (Layer *layer)
|
|||
{
|
||||
LayerWidget *layer_widget;
|
||||
GtkStateType state;
|
||||
gint index;
|
||||
gint index;
|
||||
|
||||
layer_widget = layer_widget_get_ID (layer);
|
||||
if (!layersD || !layer_widget)
|
||||
|
@ -1174,7 +1185,7 @@ layers_dialog_unset_layer (Layer *layer)
|
|||
{
|
||||
LayerWidget *layer_widget;
|
||||
GtkStateType state;
|
||||
gint index;
|
||||
gint index;
|
||||
|
||||
layer_widget = layer_widget_get_ID (layer);
|
||||
if (!layersD || !layer_widget)
|
||||
|
@ -1199,8 +1210,8 @@ static void
|
|||
layers_dialog_position_layer (Layer *layer,
|
||||
gint new_index)
|
||||
{
|
||||
LayerWidget *layer_widget;
|
||||
GList *list = NULL;
|
||||
LayerWidget *layer_widget;
|
||||
GList *list = NULL;
|
||||
|
||||
layer_widget = layer_widget_get_ID (layer);
|
||||
if (!layersD || !layer_widget)
|
||||
|
@ -1245,8 +1256,8 @@ layers_dialog_add_layer (Layer *layer)
|
|||
{
|
||||
LayerWidget *layer_widget;
|
||||
GimpImage *gimage;
|
||||
GList *item_list;
|
||||
gint position;
|
||||
GList *item_list;
|
||||
gint position;
|
||||
|
||||
if (!layersD || !layer || !(gimage = layersD->gimage))
|
||||
return;
|
||||
|
@ -1266,7 +1277,7 @@ static void
|
|||
layers_dialog_remove_layer (Layer *layer)
|
||||
{
|
||||
LayerWidget *layer_widget;
|
||||
GList *list = NULL;
|
||||
GList *list = NULL;
|
||||
|
||||
layer_widget = layer_widget_get_ID (layer);
|
||||
if (!layersD || !layer_widget)
|
||||
|
@ -1372,7 +1383,8 @@ opacity_scale_update (GtkAdjustment *adjustment,
|
|||
return;
|
||||
|
||||
/* add the 0.001 to insure there are no subtle rounding errors */
|
||||
opacity = (int) (adjustment->value * 2.55 + 0.001);
|
||||
opacity = (gint) (adjustment->value * 2.55 + 0.001);
|
||||
|
||||
if (layer->opacity != opacity)
|
||||
{
|
||||
layer->opacity = opacity;
|
||||
|
@ -1587,7 +1599,7 @@ layers_dialog_new_layer_callback (GtkWidget *widget,
|
|||
gpointer data)
|
||||
{
|
||||
GimpImage *gimage;
|
||||
Layer *layer;
|
||||
Layer *layer;
|
||||
|
||||
if (!layersD || !(gimage = layersD->gimage))
|
||||
return;
|
||||
|
@ -1842,7 +1854,7 @@ layers_dialog_add_alpha_channel_callback (GtkWidget *widget,
|
|||
gpointer data)
|
||||
{
|
||||
GimpImage *gimage;
|
||||
Layer *layer;
|
||||
Layer *layer;
|
||||
|
||||
if (!layersD ||
|
||||
!(gimage = layersD->gimage) ||
|
||||
|
@ -1878,8 +1890,8 @@ layers_dialog_drag_new_layer_callback (GtkWidget *widget,
|
|||
gint y,
|
||||
guint time)
|
||||
{
|
||||
GtkWidget *src_widget;
|
||||
gboolean return_val = FALSE;
|
||||
GtkWidget *src_widget;
|
||||
gboolean return_val = FALSE;
|
||||
|
||||
if ((src_widget = gtk_drag_get_source_widget (context)))
|
||||
{
|
||||
|
@ -1893,8 +1905,8 @@ layers_dialog_drag_new_layer_callback (GtkWidget *widget,
|
|||
{
|
||||
Layer *new_layer;
|
||||
GimpImage *gimage;
|
||||
gint width, height;
|
||||
gint off_x, off_y;
|
||||
gint width, height;
|
||||
gint off_x, off_y;
|
||||
|
||||
gimage = layersD->gimage;
|
||||
|
||||
|
@ -1944,7 +1956,7 @@ layers_dialog_drag_duplicate_layer_callback (GtkWidget *widget,
|
|||
guint time)
|
||||
{
|
||||
GtkWidget *src_widget;
|
||||
gboolean return_val = FALSE;
|
||||
gboolean return_val = FALSE;
|
||||
|
||||
if ((src_widget = gtk_drag_get_source_widget (context)))
|
||||
{
|
||||
|
@ -1976,7 +1988,7 @@ layers_dialog_drag_trashcan_callback (GtkWidget *widget,
|
|||
guint time)
|
||||
{
|
||||
GtkWidget *src_widget;
|
||||
gboolean return_val = FALSE;
|
||||
gboolean return_val = FALSE;
|
||||
|
||||
if ((src_widget = gtk_drag_get_source_widget (context)))
|
||||
{
|
||||
|
@ -2017,7 +2029,7 @@ static LayerWidget *
|
|||
layer_widget_get_ID (Layer *ID)
|
||||
{
|
||||
LayerWidget *lw;
|
||||
GSList *list;
|
||||
GSList *list;
|
||||
|
||||
if (! layersD)
|
||||
return NULL;
|
||||
|
@ -2038,10 +2050,10 @@ layer_widget_create (GimpImage *gimage,
|
|||
Layer *layer)
|
||||
{
|
||||
LayerWidget *layer_widget;
|
||||
GtkWidget *list_item;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *alignment;
|
||||
GtkWidget *list_item;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *alignment;
|
||||
|
||||
list_item = gtk_list_item_new ();
|
||||
|
||||
|
@ -2127,9 +2139,10 @@ layer_widget_create (GimpImage *gimage,
|
|||
gtk_drawing_area_size (GTK_DRAWING_AREA (layer_widget->layer_preview),
|
||||
layersD->image_width + 4, layersD->image_height + 4);
|
||||
gtk_widget_set_events (layer_widget->layer_preview, PREVIEW_EVENT_MASK);
|
||||
gtk_signal_connect (GTK_OBJECT (layer_widget->layer_preview), "event",
|
||||
GTK_SIGNAL_FUNC (layer_widget_preview_events),
|
||||
layer_widget);
|
||||
gtk_signal_connect_while_alive (GTK_OBJECT (layer_widget->layer_preview), "event",
|
||||
GTK_SIGNAL_FUNC (layer_widget_preview_events),
|
||||
layer_widget,
|
||||
GTK_OBJECT (layer));
|
||||
gtk_object_set_user_data (GTK_OBJECT (layer_widget->layer_preview),
|
||||
layer_widget);
|
||||
gtk_container_add (GTK_CONTAINER (alignment), layer_widget->layer_preview);
|
||||
|
@ -2240,16 +2253,15 @@ layer_widget_drag_motion_callback (GtkWidget *widget,
|
|||
gint y,
|
||||
guint time)
|
||||
{
|
||||
LayerWidget *dest;
|
||||
gint dest_index;
|
||||
GtkWidget *src_widget;
|
||||
LayerWidget *src;
|
||||
gint src_index;
|
||||
gint difference;
|
||||
|
||||
GimpDropType drop_type = GIMP_DROP_NONE;
|
||||
GdkDragAction drag_action = GDK_ACTION_DEFAULT;
|
||||
gboolean return_val = FALSE;
|
||||
LayerWidget *dest;
|
||||
gint dest_index;
|
||||
GtkWidget *src_widget;
|
||||
LayerWidget *src;
|
||||
gint src_index;
|
||||
gint difference;
|
||||
GimpDropType drop_type = GIMP_DROP_NONE;
|
||||
GdkDragAction drag_action = GDK_ACTION_DEFAULT;
|
||||
gboolean return_val = FALSE;
|
||||
|
||||
dest = (LayerWidget *) gtk_object_get_user_data (GTK_OBJECT (widget));
|
||||
|
||||
|
@ -2314,7 +2326,8 @@ layer_widget_drag_begin_callback (GtkWidget *widget,
|
|||
{
|
||||
LayerWidget *layer_widget;
|
||||
|
||||
layer_widget = (LayerWidget *) gtk_object_get_user_data (GTK_OBJECT (widget));
|
||||
layer_widget =
|
||||
(LayerWidget *) gtk_object_get_user_data (GTK_OBJECT (widget));
|
||||
|
||||
gimp_dnd_set_drawable_preview_icon (widget, context,
|
||||
GIMP_DRAWABLE (layer_widget->layer));
|
||||
|
@ -2326,7 +2339,8 @@ layer_mask_drag_begin_callback (GtkWidget *widget,
|
|||
{
|
||||
LayerWidget *layer_widget;
|
||||
|
||||
layer_widget = (LayerWidget *) gtk_object_get_user_data (GTK_OBJECT (widget));
|
||||
layer_widget =
|
||||
(LayerWidget *) gtk_object_get_user_data (GTK_OBJECT (widget));
|
||||
|
||||
gimp_dnd_set_drawable_preview_icon
|
||||
(widget, context,
|
||||
|
@ -2362,15 +2376,14 @@ layer_widget_drag_drop_callback (GtkWidget *widget,
|
|||
gint y,
|
||||
guint time)
|
||||
{
|
||||
LayerWidget *dest;
|
||||
gint dest_index;
|
||||
GtkWidget *src_widget;
|
||||
LayerWidget *src;
|
||||
gint src_index;
|
||||
gint difference;
|
||||
|
||||
GimpDropType drop_type = GIMP_DROP_NONE;
|
||||
gboolean return_val = FALSE;
|
||||
LayerWidget *dest;
|
||||
gint dest_index;
|
||||
GtkWidget *src_widget;
|
||||
LayerWidget *src;
|
||||
gint src_index;
|
||||
gint difference;
|
||||
GimpDropType drop_type = GIMP_DROP_NONE;
|
||||
gboolean return_val = FALSE;
|
||||
|
||||
dest = (LayerWidget *) gtk_object_get_user_data (GTK_OBJECT (widget));
|
||||
|
||||
|
@ -2378,16 +2391,18 @@ layer_widget_drag_drop_callback (GtkWidget *widget,
|
|||
layer_has_alpha (dest->layer) &&
|
||||
(src_widget = gtk_drag_get_source_widget (context)))
|
||||
{
|
||||
src
|
||||
= (LayerWidget *) gtk_object_get_user_data (GTK_OBJECT (src_widget));
|
||||
src =
|
||||
(LayerWidget *) gtk_object_get_user_data (GTK_OBJECT (src_widget));
|
||||
|
||||
if (src &&
|
||||
layer_has_alpha (src->layer) &&
|
||||
! layer_is_floating_sel (src->layer) &&
|
||||
src->layer == layersD->active_layer)
|
||||
{
|
||||
src_index = gimp_image_get_layer_index (layersD->gimage, src->layer);
|
||||
dest_index = gimp_image_get_layer_index (layersD->gimage, dest->layer);
|
||||
src_index =
|
||||
gimp_image_get_layer_index (layersD->gimage, src->layer);
|
||||
dest_index =
|
||||
gimp_image_get_layer_index (layersD->gimage, dest->layer);
|
||||
|
||||
difference = dest_index - src_index;
|
||||
|
||||
|
@ -2441,7 +2456,8 @@ layer_widget_drag_leave_callback (GtkWidget *widget,
|
|||
{
|
||||
LayerWidget *layer_widget;
|
||||
|
||||
layer_widget = (LayerWidget *) gtk_object_get_user_data (GTK_OBJECT (widget));
|
||||
layer_widget =
|
||||
(LayerWidget *) gtk_object_get_user_data (GTK_OBJECT (widget));
|
||||
|
||||
layer_widget->drop_type = GIMP_DROP_NONE;
|
||||
}
|
||||
|
@ -2452,7 +2468,8 @@ layer_widget_drag_indicator_callback (GtkWidget *widget,
|
|||
{
|
||||
LayerWidget *layer_widget;
|
||||
|
||||
layer_widget = (LayerWidget *) gtk_object_get_user_data (GTK_OBJECT (widget));
|
||||
layer_widget =
|
||||
(LayerWidget *) gtk_object_get_user_data (GTK_OBJECT (widget));
|
||||
|
||||
layer_widget_draw_drop_indicator (layer_widget, layer_widget->drop_type);
|
||||
}
|
||||
|
@ -2462,7 +2479,7 @@ layer_widget_draw_drop_indicator (LayerWidget *layer_widget,
|
|||
GimpDropType drop_type)
|
||||
{
|
||||
static GdkGC *gc = NULL;
|
||||
gint y = 0;
|
||||
gint y = 0;
|
||||
|
||||
if (!gc)
|
||||
{
|
||||
|
@ -2534,15 +2551,15 @@ layer_widget_button_events (GtkWidget *widget,
|
|||
GdkEvent *event,
|
||||
gpointer data)
|
||||
{
|
||||
LayerWidget *layer_widget;
|
||||
GtkWidget *event_widget;
|
||||
GdkEventButton *bevent;
|
||||
gint return_val;
|
||||
LayerWidget *layer_widget;
|
||||
GtkWidget *event_widget;
|
||||
GdkEventButton *bevent;
|
||||
gint return_val;
|
||||
|
||||
static gboolean button_down = FALSE;
|
||||
static GtkWidget *click_widget = NULL;
|
||||
static gint old_state;
|
||||
static gint exclusive;
|
||||
static gint old_state;
|
||||
static gint exclusive;
|
||||
|
||||
layer_widget = (LayerWidget *) gtk_object_get_user_data (GTK_OBJECT (widget));
|
||||
return_val = FALSE;
|
||||
|
@ -2678,14 +2695,16 @@ layer_widget_preview_events (GtkWidget *widget,
|
|||
GdkEventExpose *eevent;
|
||||
GdkEventButton *bevent;
|
||||
GdkPixmap **pixmap;
|
||||
gboolean valid;
|
||||
gint preview_type;
|
||||
gint sx, sy, dx, dy, w, h;
|
||||
gboolean valid;
|
||||
gint preview_type;
|
||||
gint sx, sy, dx, dy, w, h;
|
||||
|
||||
pixmap = NULL;
|
||||
valid = FALSE;
|
||||
|
||||
layer_widget = (LayerWidget *) gtk_object_get_user_data (GTK_OBJECT (widget));
|
||||
layer_widget =
|
||||
(LayerWidget *) gtk_object_get_user_data (GTK_OBJECT (widget));
|
||||
|
||||
if (!GIMP_IS_DRAWABLE (layer_widget->layer))
|
||||
return FALSE;
|
||||
|
||||
|
@ -2704,7 +2723,8 @@ layer_widget_preview_events (GtkWidget *widget,
|
|||
break;
|
||||
case MASK_PREVIEW:
|
||||
pixmap = &layer_widget->mask_pixmap;
|
||||
valid = GIMP_DRAWABLE (layer_get_mask (layer_widget->layer))->preview_valid;
|
||||
valid =
|
||||
GIMP_DRAWABLE (layer_get_mask (layer_widget->layer))->preview_valid;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -2808,19 +2828,23 @@ layer_widget_preview_events (GtkWidget *widget,
|
|||
|
||||
if ((w > 0) && (h > 0))
|
||||
{
|
||||
/* Expose events are optimzed away by GTK+ if the widget is not
|
||||
visible. Therefore, previews not visible in the layers_dialog
|
||||
are not redrawn when they invalidate. Later the preview gets
|
||||
validated by the image_preview in lc_dialog but is never
|
||||
propagated to the layer_pixmap. We work around this by using an
|
||||
additional flag "layer_pixmap_valid" so that the pixmap gets
|
||||
updated once the preview scrolls into sight.
|
||||
We should probably do the same for all drawables (masks,
|
||||
channels), but it is much more difficult to change one of these
|
||||
when it's not visible.
|
||||
*/
|
||||
if (preview_type == LAYER_PREVIEW && ! layer_widget->layer_pixmap_valid)
|
||||
layer_widget_preview_redraw (layer_widget, preview_type);
|
||||
/*
|
||||
Expose events are optimzed away by GTK+ if the widget is not
|
||||
visible. Therefore, previews not visible in the layers_dialog
|
||||
are not redrawn when they invalidate. Later the preview gets
|
||||
validated by the image_preview in lc_dialog but is never
|
||||
propagated to the layer_pixmap. We work around this by using an
|
||||
additional flag "layer_pixmap_valid" so that the pixmap gets
|
||||
updated once the preview scrolls into sight.
|
||||
We should probably do the same for all drawables (masks,
|
||||
channels), but it is much more difficult to change one of these
|
||||
when it's not visible.
|
||||
*/
|
||||
if (preview_type == LAYER_PREVIEW &&
|
||||
! layer_widget->layer_pixmap_valid)
|
||||
{
|
||||
layer_widget_preview_redraw (layer_widget, preview_type);
|
||||
}
|
||||
|
||||
gdk_draw_pixmap (widget->window,
|
||||
widget->style->black_gc,
|
||||
|
@ -2845,9 +2869,10 @@ static void
|
|||
layer_widget_boundary_redraw (LayerWidget *layer_widget,
|
||||
gint preview_type)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
GdkGC *gc1, *gc2;
|
||||
GtkStateType state;
|
||||
GtkWidget *widget;
|
||||
GdkGC *gc1;
|
||||
GdkGC *gc2;
|
||||
GtkStateType state;
|
||||
|
||||
if (preview_type == LAYER_PREVIEW)
|
||||
widget = layer_widget->layer_preview;
|
||||
|
@ -2883,6 +2908,7 @@ layer_widget_boundary_redraw (LayerWidget *layer_widget,
|
|||
layersD->green_gc = gdk_gc_new (widget->window);
|
||||
gdk_gc_set_foreground (layersD->green_gc, &green);
|
||||
}
|
||||
|
||||
if (layersD->red_gc == NULL)
|
||||
{
|
||||
GdkColor red;
|
||||
|
@ -2916,7 +2942,7 @@ layer_widget_preview_redraw (LayerWidget *layer_widget,
|
|||
TempBuf *preview_buf;
|
||||
GdkPixmap **pixmap;
|
||||
GtkWidget *widget;
|
||||
gint offx, offy;
|
||||
gint offx, offy;
|
||||
|
||||
preview_buf = NULL;
|
||||
pixmap = NULL;
|
||||
|
@ -2953,8 +2979,12 @@ layer_widget_preview_redraw (LayerWidget *layer_widget,
|
|||
(gint) (layersD->ratio * GIMP_DRAWABLE (layer_widget->layer)->width);
|
||||
layer_widget->height =
|
||||
(gint) (layersD->ratio * GIMP_DRAWABLE (layer_widget->layer)->height);
|
||||
if (layer_widget->width < 1) layer_widget->width = 1;
|
||||
if (layer_widget->height < 1) layer_widget->height = 1;
|
||||
|
||||
if (layer_widget->width < 1)
|
||||
layer_widget->width = 1;
|
||||
if (layer_widget->height < 1)
|
||||
layer_widget->height = 1;
|
||||
|
||||
offx = (gint) (layersD->ratio *
|
||||
GIMP_DRAWABLE (layer_widget->layer)->offset_x);
|
||||
offy = (gint) (layersD->ratio *
|
||||
|
@ -3005,15 +3035,15 @@ static void
|
|||
layer_widget_no_preview_redraw (LayerWidget *layer_widget,
|
||||
gint preview_type)
|
||||
{
|
||||
GdkPixmap *pixmap;
|
||||
GdkPixmap **pixmap_normal;
|
||||
GdkPixmap **pixmap_selected;
|
||||
GdkPixmap **pixmap_insensitive;
|
||||
GdkColor *color;
|
||||
GtkWidget *widget;
|
||||
GtkStateType state;
|
||||
gchar *bits;
|
||||
gint width, height;
|
||||
GdkPixmap *pixmap;
|
||||
GdkPixmap **pixmap_normal;
|
||||
GdkPixmap **pixmap_selected;
|
||||
GdkPixmap **pixmap_insensitive;
|
||||
GdkColor *color;
|
||||
GtkWidget *widget;
|
||||
GtkStateType state;
|
||||
gchar *bits;
|
||||
gint width, height;
|
||||
|
||||
pixmap_normal = NULL;
|
||||
pixmap_selected = NULL;
|
||||
|
@ -3097,9 +3127,9 @@ layer_widget_no_preview_redraw (LayerWidget *layer_widget,
|
|||
static void
|
||||
layer_widget_eye_redraw (LayerWidget *layer_widget)
|
||||
{
|
||||
GdkPixmap *pixmap;
|
||||
GdkColor *color;
|
||||
GtkStateType state;
|
||||
GdkPixmap *pixmap;
|
||||
GdkColor *color;
|
||||
GtkStateType state;
|
||||
|
||||
state = layer_widget->list_item->state;
|
||||
|
||||
|
@ -3162,9 +3192,9 @@ layer_widget_eye_redraw (LayerWidget *layer_widget)
|
|||
static void
|
||||
layer_widget_linked_redraw (LayerWidget *layer_widget)
|
||||
{
|
||||
GdkPixmap *pixmap;
|
||||
GdkColor *color;
|
||||
GtkStateType state;
|
||||
GdkPixmap *pixmap;
|
||||
GdkColor *color;
|
||||
GtkStateType state;
|
||||
|
||||
state = layer_widget->list_item->state;
|
||||
|
||||
|
@ -3272,11 +3302,11 @@ layer_widget_layer_flush (GtkWidget *widget,
|
|||
gpointer data)
|
||||
{
|
||||
LayerWidget *layer_widget;
|
||||
Layer *layer;
|
||||
gchar *name;
|
||||
gchar *label_name;
|
||||
gboolean update_layer_preview = FALSE;
|
||||
gboolean update_mask_preview = FALSE;
|
||||
Layer *layer;
|
||||
gchar *name;
|
||||
gchar *label_name;
|
||||
gboolean update_layer_preview = FALSE;
|
||||
gboolean update_mask_preview = FALSE;
|
||||
|
||||
layer_widget = (LayerWidget *) gtk_object_get_user_data (GTK_OBJECT (widget));
|
||||
layer = layer_widget->layer;
|
||||
|
@ -3354,7 +3384,8 @@ layer_widget_layer_flush (GtkWidget *widget,
|
|||
|
||||
if (layer_get_mask (layer))
|
||||
{
|
||||
update_mask_preview = (! GIMP_DRAWABLE (layer_get_mask (layer))->preview_valid);
|
||||
update_mask_preview =
|
||||
(! GIMP_DRAWABLE (layer_get_mask (layer))->preview_valid);
|
||||
|
||||
if (layer->apply_mask != layer_widget->apply_mask)
|
||||
{
|
||||
|
@ -3414,8 +3445,8 @@ new_layer_query_ok_callback (GtkWidget *widget,
|
|||
gpointer data)
|
||||
{
|
||||
NewLayerOptions *options;
|
||||
Layer *layer;
|
||||
GimpImage *gimage;
|
||||
Layer *layer;
|
||||
GimpImage *gimage;
|
||||
|
||||
options = (NewLayerOptions *) data;
|
||||
|
||||
|
@ -3462,12 +3493,12 @@ static void
|
|||
layers_dialog_new_layer_query (GimpImage* gimage)
|
||||
{
|
||||
NewLayerOptions *options;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *table;
|
||||
GtkWidget *label;
|
||||
GtkObject *adjustment;
|
||||
GtkWidget *spinbutton;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *table;
|
||||
GtkWidget *label;
|
||||
GtkObject *adjustment;
|
||||
GtkWidget *spinbutton;
|
||||
GtkWidget *frame;
|
||||
|
||||
/* The new options structure */
|
||||
options = g_new (NewLayerOptions, 1);
|
||||
|
@ -3513,7 +3544,8 @@ layers_dialog_new_layer_query (GimpImage* gimage)
|
|||
|
||||
options->name_entry = gtk_entry_new ();
|
||||
gtk_widget_set_usize (options->name_entry, 75, 0);
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), options->name_entry, 1, 2, 0, 1);
|
||||
gtk_table_attach_defaults (GTK_TABLE (table),
|
||||
options->name_entry, 1, 2, 0, 1);
|
||||
gtk_entry_set_text (GTK_ENTRY (options->name_entry),
|
||||
(layer_name ? layer_name : _("New Layer")));
|
||||
gtk_widget_show (options->name_entry);
|
||||
|
@ -3551,7 +3583,8 @@ layers_dialog_new_layer_query (GimpImage* gimage)
|
|||
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
|
||||
gtk_widget_show (options->size_se);
|
||||
|
||||
gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (options->size_se), GIMP_UNIT_PIXEL);
|
||||
gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (options->size_se),
|
||||
GIMP_UNIT_PIXEL);
|
||||
|
||||
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (options->size_se), 0,
|
||||
gimage->xresolution, FALSE);
|
||||
|
@ -3616,7 +3649,7 @@ edit_layer_query_ok_callback (GtkWidget *widget,
|
|||
gpointer data)
|
||||
{
|
||||
EditLayerOptions *options;
|
||||
Layer *layer;
|
||||
Layer *layer;
|
||||
|
||||
options = (EditLayerOptions *) data;
|
||||
|
||||
|
@ -3647,9 +3680,9 @@ static void
|
|||
layers_dialog_edit_layer_query (LayerWidget *layer_widget)
|
||||
{
|
||||
EditLayerOptions *options;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *label;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *label;
|
||||
|
||||
/* The new options structure */
|
||||
options = g_new (EditLayerOptions, 1);
|
||||
|
@ -3724,9 +3757,9 @@ add_mask_query_ok_callback (GtkWidget *widget,
|
|||
gpointer data)
|
||||
{
|
||||
AddMaskOptions *options;
|
||||
GimpImage *gimage;
|
||||
LayerMask *mask;
|
||||
Layer *layer;
|
||||
GimpImage *gimage;
|
||||
LayerMask *mask;
|
||||
Layer *layer;
|
||||
|
||||
options = (AddMaskOptions *) data;
|
||||
if ((layer = (options->layer)) &&
|
||||
|
@ -3744,7 +3777,7 @@ static void
|
|||
layers_dialog_add_mask_query (Layer *layer)
|
||||
{
|
||||
AddMaskOptions *options;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *frame;
|
||||
|
||||
/* The new options structure */
|
||||
options = g_new (AddMaskOptions, 1);
|
||||
|
@ -3810,8 +3843,8 @@ scale_layer_query_ok_callback (GtkWidget *widget,
|
|||
gpointer data)
|
||||
{
|
||||
ScaleLayerOptions *options;
|
||||
GimpImage *gimage;
|
||||
Layer *layer;
|
||||
GimpImage *gimage;
|
||||
Layer *layer;
|
||||
|
||||
options = (ScaleLayerOptions *) data;
|
||||
|
||||
|
@ -3827,7 +3860,8 @@ scale_layer_query_ok_callback (GtkWidget *widget,
|
|||
if (layer_is_floating_sel (layer))
|
||||
floating_sel_relax (layer, TRUE);
|
||||
|
||||
layer_scale (layer, options->resize->width, options->resize->height, TRUE);
|
||||
layer_scale (layer,
|
||||
options->resize->width, options->resize->height, TRUE);
|
||||
|
||||
if (layer_is_floating_sel (layer))
|
||||
floating_sel_rigor (layer, TRUE);
|
||||
|
@ -3894,8 +3928,8 @@ resize_layer_query_ok_callback (GtkWidget *widget,
|
|||
gpointer data)
|
||||
{
|
||||
ResizeLayerOptions *options;
|
||||
GimpImage *gimage;
|
||||
Layer *layer;
|
||||
GimpImage *gimage;
|
||||
Layer *layer;
|
||||
|
||||
options = (ResizeLayerOptions *) data;
|
||||
|
||||
|
@ -4002,8 +4036,8 @@ layers_dialog_layer_merge_query (GimpImage *gimage,
|
|||
gboolean merge_visible)
|
||||
{
|
||||
LayerMergeOptions *options;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *frame;
|
||||
|
||||
/* The new options structure */
|
||||
options = g_new (LayerMergeOptions, 1);
|
||||
|
|
232
app/layer.c
232
app/layer.c
|
@ -97,7 +97,7 @@ gimp_layer_get_type (void)
|
|||
static void
|
||||
gimp_layer_class_init (GimpLayerClass *class)
|
||||
{
|
||||
GtkObjectClass *object_class;
|
||||
GtkObjectClass *object_class;
|
||||
GimpDrawableClass *drawable_class;
|
||||
|
||||
object_class = (GtkObjectClass*) class;
|
||||
|
@ -210,9 +210,11 @@ transform_color (GImage *gimage,
|
|||
GimpDrawable *drawable,
|
||||
GimpImageBaseType type)
|
||||
{
|
||||
int i, h;
|
||||
unsigned char * s, * d;
|
||||
void * pr;
|
||||
gint i;
|
||||
gint h;
|
||||
guchar *s;
|
||||
guchar *d;
|
||||
gpointer pr;
|
||||
|
||||
for (pr = pixel_regions_register (2, layerPR, bufPR);
|
||||
pr != NULL;
|
||||
|
@ -252,7 +254,7 @@ layer_new (GimpImage *gimage,
|
|||
gint opacity,
|
||||
LayerModeEffects mode)
|
||||
{
|
||||
Layer * layer;
|
||||
Layer *layer;
|
||||
|
||||
if (width == 0 || height == 0)
|
||||
{
|
||||
|
@ -293,6 +295,7 @@ layer_ref (Layer *layer)
|
|||
{
|
||||
gtk_object_ref (GTK_OBJECT (layer));
|
||||
gtk_object_sink (GTK_OBJECT (layer));
|
||||
|
||||
return layer;
|
||||
}
|
||||
|
||||
|
@ -306,23 +309,25 @@ Layer *
|
|||
layer_copy (Layer *layer,
|
||||
gboolean add_alpha)
|
||||
{
|
||||
gchar * layer_name;
|
||||
Layer * new_layer;
|
||||
GimpImageType new_type;
|
||||
gchar *ext;
|
||||
gint number;
|
||||
gchar *name;
|
||||
gint len;
|
||||
PixelRegion srcPR, destPR;
|
||||
gchar *layer_name;
|
||||
Layer *new_layer;
|
||||
GimpImageType new_type;
|
||||
gchar *ext;
|
||||
gint number;
|
||||
gchar *name;
|
||||
gint len;
|
||||
PixelRegion srcPR;
|
||||
PixelRegion destPR;
|
||||
|
||||
/* formulate the new layer name */
|
||||
name = layer_get_name (layer);
|
||||
ext = strrchr (name, '#');
|
||||
len = strlen (_("copy"));
|
||||
|
||||
if ((strlen(name) >= len &&
|
||||
strcmp (&name[strlen (name) - len], _("copy")) == 0) ||
|
||||
(ext && (number = atoi (ext + 1)) > 0 &&
|
||||
((int) (log10 (number) + 1)) == strlen (ext + 1)))
|
||||
((gint) (log10 (number) + 1)) == strlen (ext + 1)))
|
||||
/* don't have redundant "copy"s */
|
||||
layer_name = g_strdup (name);
|
||||
else
|
||||
|
@ -424,8 +429,9 @@ layer_new_from_tiles (GimpImage *gimage,
|
|||
gint opacity,
|
||||
LayerModeEffects mode)
|
||||
{
|
||||
Layer * new_layer;
|
||||
PixelRegion layerPR, bufPR;
|
||||
Layer *new_layer;
|
||||
PixelRegion layerPR;
|
||||
PixelRegion bufPR;
|
||||
|
||||
/* Function copies buffer to a layer
|
||||
* taking into consideration the possibility of transforming
|
||||
|
@ -452,11 +458,13 @@ layer_new_from_tiles (GimpImage *gimage,
|
|||
/* Configure the pixel regions */
|
||||
pixel_region_init (&layerPR, GIMP_DRAWABLE (new_layer)->tiles,
|
||||
0, 0,
|
||||
GIMP_DRAWABLE (new_layer)->width, GIMP_DRAWABLE (new_layer)->height,
|
||||
GIMP_DRAWABLE (new_layer)->width,
|
||||
GIMP_DRAWABLE (new_layer)->height,
|
||||
TRUE);
|
||||
pixel_region_init (&bufPR, tiles,
|
||||
0, 0,
|
||||
GIMP_DRAWABLE (new_layer)->width, GIMP_DRAWABLE (new_layer)->height,
|
||||
GIMP_DRAWABLE (new_layer)->width,
|
||||
GIMP_DRAWABLE (new_layer)->height,
|
||||
FALSE);
|
||||
|
||||
if ((tiles->bpp == 4 && GIMP_DRAWABLE (new_layer)->type == RGBA_GIMAGE) ||
|
||||
|
@ -467,7 +475,7 @@ layer_new_from_tiles (GimpImage *gimage,
|
|||
/* Transform the contents of the buf to the new_layer */
|
||||
transform_color (gimage, &layerPR, &bufPR, GIMP_DRAWABLE (new_layer),
|
||||
(tiles->bpp == 4) ? RGB : GRAY);
|
||||
|
||||
|
||||
return new_layer;
|
||||
}
|
||||
|
||||
|
@ -488,7 +496,8 @@ layer_add_mask (Layer *layer,
|
|||
|
||||
drawable_update (GIMP_DRAWABLE(layer),
|
||||
0, 0,
|
||||
GIMP_DRAWABLE(layer)->width, GIMP_DRAWABLE(layer)->height);
|
||||
GIMP_DRAWABLE(layer)->width,
|
||||
GIMP_DRAWABLE(layer)->height);
|
||||
|
||||
return layer->mask;
|
||||
}
|
||||
|
@ -497,12 +506,13 @@ LayerMask *
|
|||
layer_create_mask (Layer *layer,
|
||||
AddMaskType add_mask_type)
|
||||
{
|
||||
PixelRegion maskPR, layerPR;
|
||||
LayerMask *mask;
|
||||
gchar *mask_name;
|
||||
guchar black[3] = {0, 0, 0};
|
||||
guchar white_mask = OPAQUE_OPACITY;
|
||||
guchar black_mask = TRANSPARENT_OPACITY;
|
||||
PixelRegion maskPR;
|
||||
PixelRegion layerPR;
|
||||
LayerMask *mask;
|
||||
gchar *mask_name;
|
||||
guchar black[3] = {0, 0, 0};
|
||||
guchar white_mask = OPAQUE_OPACITY;
|
||||
guchar black_mask = TRANSPARENT_OPACITY;
|
||||
|
||||
mask_name = g_strdup_printf (_("%s mask"), GIMP_DRAWABLE (layer)->name);
|
||||
|
||||
|
@ -951,11 +961,15 @@ layer_scale (Layer *layer,
|
|||
else
|
||||
{
|
||||
new_offset_x = (gint)(((gdouble) new_width *
|
||||
GIMP_DRAWABLE(layer)->offset_x / (gdouble) GIMP_DRAWABLE(layer)->width));
|
||||
GIMP_DRAWABLE(layer)->offset_x /
|
||||
(gdouble) GIMP_DRAWABLE(layer)->width));
|
||||
new_offset_y = (gint)(((gdouble) new_height *
|
||||
GIMP_DRAWABLE(layer)->offset_y / (gdouble) GIMP_DRAWABLE(layer)->height));
|
||||
GIMP_DRAWABLE(layer)->offset_y /
|
||||
(gdouble) GIMP_DRAWABLE(layer)->height));
|
||||
}
|
||||
layer_scale_lowlevel (layer, new_width, new_height, new_offset_x, new_offset_y);
|
||||
layer_scale_lowlevel (layer,
|
||||
new_width, new_height,
|
||||
new_offset_x, new_offset_y);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -975,7 +989,7 @@ layer_resize (Layer *layer,
|
|||
|
||||
x1 = CLAMP (offx, 0, new_width);
|
||||
y1 = CLAMP (offy, 0, new_height);
|
||||
x2 = CLAMP ((offx + GIMP_DRAWABLE(layer)->width), 0, new_width);
|
||||
x2 = CLAMP ((offx + GIMP_DRAWABLE(layer)->width), 0, new_width);
|
||||
y2 = CLAMP ((offy + GIMP_DRAWABLE(layer)->height), 0, new_height);
|
||||
w = x2 - x1;
|
||||
h = y2 - y1;
|
||||
|
@ -1014,7 +1028,8 @@ layer_resize (Layer *layer,
|
|||
FALSE);
|
||||
|
||||
/* Allocate the new layer, configure dest region */
|
||||
new_tiles = tile_manager_new (new_width, new_height, GIMP_DRAWABLE(layer)->bytes);
|
||||
new_tiles = tile_manager_new (new_width, new_height,
|
||||
GIMP_DRAWABLE(layer)->bytes);
|
||||
pixel_region_init (&destPR, new_tiles,
|
||||
0, 0,
|
||||
new_width, new_height,
|
||||
|
@ -1030,7 +1045,8 @@ layer_resize (Layer *layer,
|
|||
else
|
||||
{
|
||||
unsigned char bg[3];
|
||||
gimage_get_background (GIMP_DRAWABLE(layer)->gimage, GIMP_DRAWABLE(layer), bg);
|
||||
gimage_get_background (GIMP_DRAWABLE(layer)->gimage,
|
||||
GIMP_DRAWABLE(layer), bg);
|
||||
color_region (&destPR, bg);
|
||||
}
|
||||
pixel_region_init (&destPR, new_tiles,
|
||||
|
@ -1203,7 +1219,8 @@ layer_pick_correlate (Layer *layer,
|
|||
/* Otherwise, determine if the alpha value at
|
||||
* the given point is non-zero
|
||||
*/
|
||||
tile = tile_manager_get_tile (GIMP_DRAWABLE(layer)->tiles, x, y, TRUE, FALSE);
|
||||
tile = tile_manager_get_tile (GIMP_DRAWABLE(layer)->tiles,
|
||||
x, y, TRUE, FALSE);
|
||||
|
||||
val = * ((unsigned char*) tile_data_pointer (tile,
|
||||
x % TILE_WIDTH,
|
||||
|
@ -1212,7 +1229,8 @@ layer_pick_correlate (Layer *layer,
|
|||
if (layer->mask)
|
||||
{
|
||||
unsigned char *ptr;
|
||||
mask_tile = tile_manager_get_tile (GIMP_DRAWABLE(layer->mask)->tiles, x, y, TRUE, FALSE);
|
||||
mask_tile = tile_manager_get_tile (GIMP_DRAWABLE(layer->mask)->tiles,
|
||||
x, y, TRUE, FALSE);
|
||||
ptr = tile_data_pointer (mask_tile, x % TILE_WIDTH, y % TILE_HEIGHT);
|
||||
val = val * (*ptr) / 255;
|
||||
tile_release (mask_tile, FALSE);
|
||||
|
@ -1287,26 +1305,27 @@ layer_preview_private (Layer *layer,
|
|||
gint w,
|
||||
gint h)
|
||||
{
|
||||
GImage *gimage;
|
||||
TempBuf *preview_buf;
|
||||
PixelRegion srcPR, destPR;
|
||||
GimpImageBaseType type;
|
||||
gint bytes;
|
||||
gint subsample;
|
||||
TempBuf *ret_buf;
|
||||
GImage *gimage;
|
||||
TempBuf *preview_buf;
|
||||
PixelRegion srcPR, destPR;
|
||||
GimpImageBaseType type;
|
||||
gint bytes;
|
||||
gint subsample;
|
||||
TempBuf *ret_buf;
|
||||
|
||||
type = RGB;
|
||||
bytes = 0;
|
||||
|
||||
/* The easy way */
|
||||
if (GIMP_DRAWABLE(layer)->preview_valid &&
|
||||
(ret_buf = gimp_preview_cache_get (&(GIMP_DRAWABLE(layer)->preview_cache), w,h)))
|
||||
if (GIMP_DRAWABLE (layer)->preview_valid &&
|
||||
(ret_buf =
|
||||
gimp_preview_cache_get (&(GIMP_DRAWABLE (layer)->preview_cache), w, h)))
|
||||
return ret_buf;
|
||||
/* The hard way */
|
||||
else
|
||||
{
|
||||
gimage = GIMP_DRAWABLE(layer)->gimage;
|
||||
switch (GIMP_DRAWABLE(layer)->type)
|
||||
gimage = GIMP_DRAWABLE (layer)->gimage;
|
||||
switch (GIMP_DRAWABLE (layer)->type)
|
||||
{
|
||||
case RGB_GIMAGE: case RGBA_GIMAGE:
|
||||
type = RGB;
|
||||
|
@ -1333,7 +1352,8 @@ layer_preview_private (Layer *layer,
|
|||
|
||||
pixel_region_init (&srcPR, GIMP_DRAWABLE(layer)->tiles,
|
||||
0, 0,
|
||||
GIMP_DRAWABLE(layer)->width, GIMP_DRAWABLE(layer)->height,
|
||||
GIMP_DRAWABLE(layer)->width,
|
||||
GIMP_DRAWABLE(layer)->height,
|
||||
FALSE);
|
||||
|
||||
preview_buf = temp_buf_new (w, h, bytes, 0, 0, NULL);
|
||||
|
@ -1351,7 +1371,8 @@ layer_preview_private (Layer *layer,
|
|||
|
||||
GIMP_DRAWABLE (layer)->preview_valid = TRUE;
|
||||
|
||||
gimp_preview_cache_add (&(GIMP_DRAWABLE (layer)->preview_cache), preview_buf);
|
||||
gimp_preview_cache_add (&(GIMP_DRAWABLE (layer)->preview_cache),
|
||||
preview_buf);
|
||||
|
||||
return preview_buf;
|
||||
}
|
||||
|
@ -1386,11 +1407,11 @@ layer_mask_preview_private (Layer *layer,
|
|||
gint w,
|
||||
gint h)
|
||||
{
|
||||
TempBuf *preview_buf;
|
||||
LayerMask *mask;
|
||||
PixelRegion srcPR, destPR;
|
||||
gint subsample;
|
||||
TempBuf *ret_buf;
|
||||
TempBuf *preview_buf;
|
||||
LayerMask *mask;
|
||||
PixelRegion srcPR, destPR;
|
||||
gint subsample;
|
||||
TempBuf *ret_buf;
|
||||
|
||||
mask = layer->mask;
|
||||
if (!mask)
|
||||
|
@ -1398,7 +1419,8 @@ layer_mask_preview_private (Layer *layer,
|
|||
|
||||
/* The easy way */
|
||||
if (GIMP_DRAWABLE(mask)->preview_valid &&
|
||||
(ret_buf = gimp_preview_cache_get (&(GIMP_DRAWABLE(mask)->preview_cache), w, h)))
|
||||
(ret_buf = gimp_preview_cache_get (&(GIMP_DRAWABLE(mask)->preview_cache),
|
||||
w, h)))
|
||||
return ret_buf;
|
||||
/* The hard way */
|
||||
else
|
||||
|
@ -1413,7 +1435,8 @@ layer_mask_preview_private (Layer *layer,
|
|||
|
||||
pixel_region_init (&srcPR, GIMP_DRAWABLE(mask)->tiles,
|
||||
0, 0,
|
||||
GIMP_DRAWABLE(mask)->width, GIMP_DRAWABLE(mask)->height,
|
||||
GIMP_DRAWABLE(mask)->width,
|
||||
GIMP_DRAWABLE(mask)->height,
|
||||
FALSE);
|
||||
|
||||
preview_buf = temp_buf_new (w, h, 1, 0, 0, NULL);
|
||||
|
@ -1424,7 +1447,7 @@ layer_mask_preview_private (Layer *layer,
|
|||
destPR.rowstride = w * destPR.bytes;
|
||||
destPR.data = temp_buf_data (preview_buf);
|
||||
|
||||
layer_preview_scale (1 /* GRAY */, NULL, &srcPR, &destPR, subsample);
|
||||
layer_preview_scale (GRAY, NULL, &srcPR, &destPR, subsample);
|
||||
|
||||
if (!GIMP_DRAWABLE (mask)->preview_valid)
|
||||
gimp_preview_cache_invalidate (&(GIMP_DRAWABLE (mask)->preview_cache));
|
||||
|
@ -1447,9 +1470,9 @@ layer_mask_preview (Layer *layer,
|
|||
width <= PREVIEW_CACHE_PRIME_WIDTH &&
|
||||
height <= PREVIEW_CACHE_PRIME_HEIGHT)
|
||||
{
|
||||
TempBuf * tb = layer_mask_preview_private(layer,
|
||||
PREVIEW_CACHE_PRIME_WIDTH,
|
||||
PREVIEW_CACHE_PRIME_HEIGHT);
|
||||
TempBuf * tb = layer_mask_preview_private (layer,
|
||||
PREVIEW_CACHE_PRIME_WIDTH,
|
||||
PREVIEW_CACHE_PRIME_HEIGHT);
|
||||
|
||||
/* Save the 2nd call */
|
||||
if (width == PREVIEW_CACHE_PRIME_WIDTH &&
|
||||
|
@ -1479,18 +1502,15 @@ layer_set_tattoo (const Layer *layer,
|
|||
void
|
||||
layer_invalidate_previews (GimpImage *gimage)
|
||||
{
|
||||
GSList * tmp;
|
||||
Layer * layer;
|
||||
GSList *tmp;
|
||||
Layer *layer;
|
||||
|
||||
g_return_if_fail (gimage != NULL);
|
||||
|
||||
tmp = gimage->layers;
|
||||
|
||||
while (tmp)
|
||||
for (tmp = gimage->layers; tmp; tmp = g_slist_next (tmp))
|
||||
{
|
||||
layer = (Layer *) tmp->data;
|
||||
gimp_drawable_invalidate_preview (GIMP_DRAWABLE(layer), TRUE);
|
||||
tmp = g_slist_next (tmp);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1502,27 +1522,27 @@ layer_preview_scale (GimpImageBaseType type,
|
|||
gint subsample)
|
||||
{
|
||||
#define EPSILON 0.000001
|
||||
guchar *src, *s;
|
||||
guchar *dest, *d;
|
||||
guchar *src, *s;
|
||||
guchar *dest, *d;
|
||||
gdouble *row, *r;
|
||||
gint destwidth;
|
||||
gint src_row, src_col;
|
||||
gint bytes, b;
|
||||
gint width, height;
|
||||
gint orig_width, orig_height;
|
||||
gdouble x_rat, y_rat;
|
||||
gdouble x_cum, y_cum;
|
||||
gdouble x_last, y_last;
|
||||
gdouble * x_frac, y_frac, tot_frac;
|
||||
gint i, j;
|
||||
gint frac;
|
||||
gint destwidth;
|
||||
gint src_row, src_col;
|
||||
gint bytes, b;
|
||||
gint width, height;
|
||||
gint orig_width, orig_height;
|
||||
gdouble x_rat, y_rat;
|
||||
gdouble x_cum, y_cum;
|
||||
gdouble x_last, y_last;
|
||||
gdouble *x_frac, y_frac, tot_frac;
|
||||
gint i, j;
|
||||
gint frac;
|
||||
gboolean advance_dest;
|
||||
guchar rgb[MAX_CHANNELS];
|
||||
guchar rgb[MAX_CHANNELS];
|
||||
|
||||
orig_width = srcPR->w / subsample;
|
||||
orig_height = srcPR->h / subsample;
|
||||
width = destPR->w;
|
||||
height = destPR->h;
|
||||
width = destPR->w;
|
||||
height = destPR->h;
|
||||
|
||||
/* Some calculations... */
|
||||
bytes = destPR->bytes;
|
||||
|
@ -1568,7 +1588,12 @@ layer_preview_scale (GimpImageBaseType type,
|
|||
y_cum = (double) src_row;
|
||||
y_last = y_cum;
|
||||
|
||||
pixel_region_get_row (srcPR, 0, src_row * subsample, orig_width * subsample, src, subsample);
|
||||
pixel_region_get_row (srcPR,
|
||||
0,
|
||||
src_row * subsample,
|
||||
orig_width * subsample,
|
||||
src,
|
||||
subsample);
|
||||
|
||||
/* Scale the selected region */
|
||||
for (i = 0; i < height; )
|
||||
|
@ -1657,7 +1682,12 @@ layer_preview_scale (GimpImageBaseType type,
|
|||
i++;
|
||||
}
|
||||
else
|
||||
pixel_region_get_row (srcPR, 0, src_row * subsample, orig_width * subsample, src, subsample);
|
||||
pixel_region_get_row (srcPR,
|
||||
0,
|
||||
src_row * subsample,
|
||||
orig_width * subsample,
|
||||
src,
|
||||
subsample);
|
||||
}
|
||||
|
||||
/* free up temporary arrays */
|
||||
|
@ -1688,8 +1718,8 @@ layer_mask_new (GimpImage *gimage,
|
|||
gint opacity,
|
||||
guchar *col)
|
||||
{
|
||||
LayerMask * layer_mask;
|
||||
gint i;
|
||||
LayerMask *layer_mask;
|
||||
gint i;
|
||||
|
||||
layer_mask = gtk_type_new (gimp_layer_mask_get_type ());
|
||||
|
||||
|
@ -1721,12 +1751,13 @@ layer_mask_new (GimpImage *gimage,
|
|||
LayerMask *
|
||||
layer_mask_copy (LayerMask *layer_mask)
|
||||
{
|
||||
gchar * layer_mask_name;
|
||||
LayerMask * new_layer_mask;
|
||||
PixelRegion srcPR, destPR;
|
||||
gchar *layer_mask_name;
|
||||
LayerMask *new_layer_mask;
|
||||
PixelRegion srcPR, destPR;
|
||||
|
||||
/* formulate the new layer_mask name */
|
||||
layer_mask_name = g_strdup_printf (_("%s copy"), GIMP_DRAWABLE(layer_mask)->name);
|
||||
layer_mask_name = g_strdup_printf (_("%s copy"),
|
||||
GIMP_DRAWABLE(layer_mask)->name);
|
||||
|
||||
/* allocate a new layer_mask object */
|
||||
new_layer_mask = layer_mask_new (GIMP_DRAWABLE(layer_mask)->gimage,
|
||||
|
@ -1735,19 +1766,25 @@ layer_mask_copy (LayerMask *layer_mask)
|
|||
layer_mask_name,
|
||||
GIMP_CHANNEL(layer_mask)->opacity,
|
||||
GIMP_CHANNEL(layer_mask)->col);
|
||||
GIMP_DRAWABLE(new_layer_mask)->visible = GIMP_DRAWABLE(layer_mask)->visible;
|
||||
GIMP_DRAWABLE(new_layer_mask)->offset_x = GIMP_DRAWABLE(layer_mask)->offset_x;
|
||||
GIMP_DRAWABLE(new_layer_mask)->offset_y = GIMP_DRAWABLE(layer_mask)->offset_y;
|
||||
GIMP_CHANNEL(new_layer_mask)->show_masked = GIMP_CHANNEL(layer_mask)->show_masked;
|
||||
GIMP_DRAWABLE(new_layer_mask)->visible =
|
||||
GIMP_DRAWABLE(layer_mask)->visible;
|
||||
GIMP_DRAWABLE(new_layer_mask)->offset_x =
|
||||
GIMP_DRAWABLE(layer_mask)->offset_x;
|
||||
GIMP_DRAWABLE(new_layer_mask)->offset_y =
|
||||
GIMP_DRAWABLE(layer_mask)->offset_y;
|
||||
GIMP_CHANNEL(new_layer_mask)->show_masked =
|
||||
GIMP_CHANNEL(layer_mask)->show_masked;
|
||||
|
||||
/* copy the contents across layer masks */
|
||||
pixel_region_init (&srcPR, GIMP_DRAWABLE(layer_mask)->tiles,
|
||||
0, 0,
|
||||
GIMP_DRAWABLE(layer_mask)->width, GIMP_DRAWABLE(layer_mask)->height,
|
||||
GIMP_DRAWABLE(layer_mask)->width,
|
||||
GIMP_DRAWABLE(layer_mask)->height,
|
||||
FALSE);
|
||||
pixel_region_init (&destPR, GIMP_DRAWABLE(new_layer_mask)->tiles,
|
||||
0, 0,
|
||||
GIMP_DRAWABLE(layer_mask)->width, GIMP_DRAWABLE(layer_mask)->height,
|
||||
GIMP_DRAWABLE(layer_mask)->width,
|
||||
GIMP_DRAWABLE(layer_mask)->height,
|
||||
TRUE);
|
||||
copy_region (&srcPR, &destPR);
|
||||
|
||||
|
@ -1809,8 +1846,8 @@ channel_layer_mask (Channel *mask,
|
|||
Layer *layer)
|
||||
{
|
||||
PixelRegion srcPR, destPR;
|
||||
guchar empty = 0;
|
||||
gint x1, y1, x2, y2;
|
||||
guchar empty = 0;
|
||||
gint x1, y1, x2, y2;
|
||||
|
||||
/* push the current mask onto the undo stack */
|
||||
channel_push_undo (mask);
|
||||
|
@ -1830,7 +1867,8 @@ channel_layer_mask (Channel *mask,
|
|||
0, GIMP_DRAWABLE(mask)->height);
|
||||
|
||||
pixel_region_init (&srcPR, GIMP_DRAWABLE(layer->mask)->tiles,
|
||||
(x1 - GIMP_DRAWABLE(layer)->offset_x), (y1 - GIMP_DRAWABLE(layer)->offset_y),
|
||||
(x1 - GIMP_DRAWABLE(layer)->offset_x),
|
||||
(y1 - GIMP_DRAWABLE(layer)->offset_y),
|
||||
(x2 - x1), (y2 - y1),
|
||||
FALSE);
|
||||
pixel_region_init (&destPR, GIMP_DRAWABLE(mask)->tiles,
|
||||
|
|
|
@ -393,7 +393,8 @@ layers_dialog_create (void)
|
|||
FALSE, FALSE, 2);
|
||||
gtk_widget_show (layersD->mode_option_menu);
|
||||
|
||||
gimp_help_set_help_data (layersD->mode_option_menu, NULL, "#paint_mode_menu");
|
||||
gimp_help_set_help_data (layersD->mode_option_menu,
|
||||
NULL, "#paint_mode_menu");
|
||||
|
||||
layersD->preserve_trans =
|
||||
gtk_check_button_new_with_label (_("Keep Trans."));
|
||||
|
@ -589,12 +590,13 @@ layers_dialog_update (GimpImage* gimage)
|
|||
/* Find the preview extents */
|
||||
layers_dialog_preview_extents ();
|
||||
|
||||
layersD->active_layer = NULL;
|
||||
layersD->active_layer = NULL;
|
||||
layersD->active_channel = NULL;
|
||||
layersD->floating_sel = NULL;
|
||||
layersD->floating_sel = NULL;
|
||||
|
||||
item_list = NULL;
|
||||
for (list = gimage->layers; list; list = g_slist_next (list))
|
||||
for (list = gimage->layers, item_list = NULL;
|
||||
list;
|
||||
list = g_slist_next (list))
|
||||
{
|
||||
/* create a layer list item */
|
||||
layer = (Layer *) list->data;
|
||||
|
@ -668,8 +670,9 @@ layers_dialog_flush (void)
|
|||
}
|
||||
|
||||
/* Switch positions of items if necessary */
|
||||
pos = 0;
|
||||
for (list = gimage->layers; list; list = g_slist_next (list))
|
||||
for (list = gimage->layers, pos = 0;
|
||||
list;
|
||||
list = g_slist_next (list))
|
||||
{
|
||||
layer = (Layer *) list->data;
|
||||
layers_dialog_position_layer (layer, pos++);
|
||||
|
@ -692,6 +695,7 @@ layers_dialog_flush (void)
|
|||
gtk_container_foreach (GTK_CONTAINER (layersD->layer_list),
|
||||
layer_widget_layer_flush, NULL);
|
||||
}
|
||||
|
||||
suspend_gimage_notify--;
|
||||
}
|
||||
|
||||
|
@ -719,19 +723,19 @@ render_preview (TempBuf *preview_buf,
|
|||
gint height,
|
||||
gint channel)
|
||||
{
|
||||
guchar *src, *s;
|
||||
guchar *cb;
|
||||
guchar *buf;
|
||||
gint a;
|
||||
gint i, j, b;
|
||||
gint x1, y1, x2, y2;
|
||||
gint rowstride;
|
||||
gint color_buf;
|
||||
gint color;
|
||||
gint alpha;
|
||||
gint has_alpha;
|
||||
gint image_bytes;
|
||||
gint offset;
|
||||
guchar *src, *s;
|
||||
guchar *cb;
|
||||
guchar *buf;
|
||||
gint a;
|
||||
gint i, j, b;
|
||||
gint x1, y1, x2, y2;
|
||||
gint rowstride;
|
||||
gint color_buf;
|
||||
gint color;
|
||||
gint alpha;
|
||||
gboolean has_alpha;
|
||||
gint image_bytes;
|
||||
gint offset;
|
||||
|
||||
alpha = ALPHA_PIX;
|
||||
|
||||
|
@ -746,10 +750,10 @@ render_preview (TempBuf *preview_buf,
|
|||
* 2) Color preview_bufs have bytes == {3, 4}
|
||||
* 3) If image is gray, then preview_buf should have bytes == {1, 2}
|
||||
*/
|
||||
color_buf = (GTK_PREVIEW (preview_widget)->type == GTK_PREVIEW_COLOR);
|
||||
color_buf = (GTK_PREVIEW (preview_widget)->type == GTK_PREVIEW_COLOR);
|
||||
image_bytes = (color_buf) ? 3 : 1;
|
||||
has_alpha = (preview_buf->bytes == 2 || preview_buf->bytes == 4);
|
||||
rowstride = preview_buf->width * preview_buf->bytes;
|
||||
has_alpha = (preview_buf->bytes == 2 || preview_buf->bytes == 4);
|
||||
rowstride = preview_buf->width * preview_buf->bytes;
|
||||
|
||||
/* Determine if the preview buf supplied is color
|
||||
* Generally, if the bytes == {3, 4}, this is true.
|
||||
|
@ -900,11 +904,11 @@ void
|
|||
render_fs_preview (GtkWidget *widget,
|
||||
GdkPixmap *pixmap)
|
||||
{
|
||||
gint w, h;
|
||||
gint x1, y1, x2, y2;
|
||||
GdkPoint poly[6];
|
||||
gint foldh, foldw;
|
||||
gint i;
|
||||
gint w, h;
|
||||
gint x1, y1, x2, y2;
|
||||
GdkPoint poly[6];
|
||||
gint foldh, foldw;
|
||||
gint i;
|
||||
|
||||
gdk_window_get_size (pixmap, &w, &h);
|
||||
|
||||
|
@ -926,10 +930,11 @@ render_fs_preview (GtkWidget *widget,
|
|||
|
||||
poly[0].x = x1 + foldw; poly[0].y = y1;
|
||||
poly[1].x = x1 + foldw; poly[1].y = y1 + foldh;
|
||||
poly[2].x = x1; poly[2].y = y1 + foldh;
|
||||
poly[3].x = x1; poly[3].y = y2;
|
||||
poly[4].x = x2; poly[4].y = y2;
|
||||
poly[5].x = x2; poly[5].y = y1;
|
||||
poly[2].x = x1; poly[2].y = y1 + foldh;
|
||||
poly[3].x = x1; poly[3].y = y2;
|
||||
poly[4].x = x2; poly[4].y = y2;
|
||||
poly[5].x = x2; poly[5].y = y1;
|
||||
|
||||
gdk_draw_polygon (pixmap, widget->style->white_gc, 1, poly, 6);
|
||||
|
||||
gdk_draw_line (pixmap, widget->style->black_gc,
|
||||
|
@ -940,6 +945,7 @@ render_fs_preview (GtkWidget *widget,
|
|||
x2, y2, x2, y1);
|
||||
gdk_draw_line (pixmap, widget->style->black_gc,
|
||||
x1 + foldw, y1, x2, y1);
|
||||
|
||||
for (i = 0; i < foldw; i++)
|
||||
gdk_draw_line (pixmap, widget->style->black_gc,
|
||||
x1 + i, y1 + foldh, x1 + i, (foldw == 1) ? y1 :
|
||||
|
@ -965,16 +971,19 @@ layers_dialog_preview_extents (void)
|
|||
|
||||
/* Get the image width and height variables, based on the gimage */
|
||||
if (gimage->width > gimage->height)
|
||||
layersD->ratio = (double) preview_size / (double) gimage->width;
|
||||
layersD->ratio = (gdouble) preview_size / (gdouble) gimage->width;
|
||||
else
|
||||
layersD->ratio = (double) preview_size / (double) gimage->height;
|
||||
layersD->ratio = (gdouble) preview_size / (gdouble) gimage->height;
|
||||
|
||||
if (preview_size)
|
||||
{
|
||||
layersD->image_width = (gint) (layersD->ratio * gimage->width);
|
||||
layersD->image_height = (gint) (layersD->ratio * gimage->height);
|
||||
if (layersD->image_width < 1) layersD->image_width = 1;
|
||||
if (layersD->image_height < 1) layersD->image_height = 1;
|
||||
|
||||
if (layersD->image_width < 1)
|
||||
layersD->image_width = 1;
|
||||
if (layersD->image_height < 1)
|
||||
layersD->image_height = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -986,18 +995,18 @@ layers_dialog_preview_extents (void)
|
|||
static void
|
||||
layers_dialog_set_menu_sensitivity (void)
|
||||
{
|
||||
gboolean fs; /* floating sel */
|
||||
gboolean ac; /* active channel */
|
||||
gboolean lm; /* layer mask */
|
||||
gboolean gimage; /* is there a gimage */
|
||||
gboolean lp; /* layers present */
|
||||
gboolean alpha; /* alpha channel present */
|
||||
gboolean indexed; /* is indexed */
|
||||
gint next_alpha;
|
||||
GSList *list;
|
||||
GSList *next;
|
||||
GSList *prev;
|
||||
Layer *layer;
|
||||
gboolean fs; /* floating sel */
|
||||
gboolean ac; /* active channel */
|
||||
gboolean lm; /* layer mask */
|
||||
gboolean gimage; /* is there a gimage */
|
||||
gboolean lp; /* layers present */
|
||||
gboolean alpha; /* alpha channel present */
|
||||
gboolean indexed; /* is indexed */
|
||||
gint next_alpha;
|
||||
GSList *list;
|
||||
GSList *next;
|
||||
GSList *prev;
|
||||
Layer *layer;
|
||||
|
||||
lp = FALSE;
|
||||
indexed = FALSE;
|
||||
|
@ -1108,7 +1117,7 @@ static void
|
|||
layers_dialog_scroll_index (gint index)
|
||||
{
|
||||
GtkAdjustment *adj;
|
||||
gint item_height;
|
||||
gint item_height;
|
||||
|
||||
item_height = 6 + (preview_size ? preview_size : layer_height);
|
||||
adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (layersD->scrolled_win));
|
||||
|
@ -1126,6 +1135,7 @@ layers_dialog_scroll_index (gint index)
|
|||
}
|
||||
|
||||
/* Commented out because this piece of code produced strange segfaults
|
||||
|
||||
static gint
|
||||
layer_dialog_idle_set_active_layer_focus (gpointer data)
|
||||
{
|
||||
|
@ -1133,6 +1143,7 @@ layer_dialog_idle_set_active_layer_focus (gpointer data)
|
|||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
static void
|
||||
|
@ -1140,7 +1151,7 @@ layers_dialog_set_active_layer (Layer *layer)
|
|||
{
|
||||
LayerWidget *layer_widget;
|
||||
GtkStateType state;
|
||||
gint index;
|
||||
gint index;
|
||||
|
||||
layer_widget = layer_widget_get_ID (layer);
|
||||
if (!layersD || !layer_widget)
|
||||
|
@ -1174,7 +1185,7 @@ layers_dialog_unset_layer (Layer *layer)
|
|||
{
|
||||
LayerWidget *layer_widget;
|
||||
GtkStateType state;
|
||||
gint index;
|
||||
gint index;
|
||||
|
||||
layer_widget = layer_widget_get_ID (layer);
|
||||
if (!layersD || !layer_widget)
|
||||
|
@ -1199,8 +1210,8 @@ static void
|
|||
layers_dialog_position_layer (Layer *layer,
|
||||
gint new_index)
|
||||
{
|
||||
LayerWidget *layer_widget;
|
||||
GList *list = NULL;
|
||||
LayerWidget *layer_widget;
|
||||
GList *list = NULL;
|
||||
|
||||
layer_widget = layer_widget_get_ID (layer);
|
||||
if (!layersD || !layer_widget)
|
||||
|
@ -1245,8 +1256,8 @@ layers_dialog_add_layer (Layer *layer)
|
|||
{
|
||||
LayerWidget *layer_widget;
|
||||
GimpImage *gimage;
|
||||
GList *item_list;
|
||||
gint position;
|
||||
GList *item_list;
|
||||
gint position;
|
||||
|
||||
if (!layersD || !layer || !(gimage = layersD->gimage))
|
||||
return;
|
||||
|
@ -1266,7 +1277,7 @@ static void
|
|||
layers_dialog_remove_layer (Layer *layer)
|
||||
{
|
||||
LayerWidget *layer_widget;
|
||||
GList *list = NULL;
|
||||
GList *list = NULL;
|
||||
|
||||
layer_widget = layer_widget_get_ID (layer);
|
||||
if (!layersD || !layer_widget)
|
||||
|
@ -1372,7 +1383,8 @@ opacity_scale_update (GtkAdjustment *adjustment,
|
|||
return;
|
||||
|
||||
/* add the 0.001 to insure there are no subtle rounding errors */
|
||||
opacity = (int) (adjustment->value * 2.55 + 0.001);
|
||||
opacity = (gint) (adjustment->value * 2.55 + 0.001);
|
||||
|
||||
if (layer->opacity != opacity)
|
||||
{
|
||||
layer->opacity = opacity;
|
||||
|
@ -1587,7 +1599,7 @@ layers_dialog_new_layer_callback (GtkWidget *widget,
|
|||
gpointer data)
|
||||
{
|
||||
GimpImage *gimage;
|
||||
Layer *layer;
|
||||
Layer *layer;
|
||||
|
||||
if (!layersD || !(gimage = layersD->gimage))
|
||||
return;
|
||||
|
@ -1842,7 +1854,7 @@ layers_dialog_add_alpha_channel_callback (GtkWidget *widget,
|
|||
gpointer data)
|
||||
{
|
||||
GimpImage *gimage;
|
||||
Layer *layer;
|
||||
Layer *layer;
|
||||
|
||||
if (!layersD ||
|
||||
!(gimage = layersD->gimage) ||
|
||||
|
@ -1878,8 +1890,8 @@ layers_dialog_drag_new_layer_callback (GtkWidget *widget,
|
|||
gint y,
|
||||
guint time)
|
||||
{
|
||||
GtkWidget *src_widget;
|
||||
gboolean return_val = FALSE;
|
||||
GtkWidget *src_widget;
|
||||
gboolean return_val = FALSE;
|
||||
|
||||
if ((src_widget = gtk_drag_get_source_widget (context)))
|
||||
{
|
||||
|
@ -1893,8 +1905,8 @@ layers_dialog_drag_new_layer_callback (GtkWidget *widget,
|
|||
{
|
||||
Layer *new_layer;
|
||||
GimpImage *gimage;
|
||||
gint width, height;
|
||||
gint off_x, off_y;
|
||||
gint width, height;
|
||||
gint off_x, off_y;
|
||||
|
||||
gimage = layersD->gimage;
|
||||
|
||||
|
@ -1944,7 +1956,7 @@ layers_dialog_drag_duplicate_layer_callback (GtkWidget *widget,
|
|||
guint time)
|
||||
{
|
||||
GtkWidget *src_widget;
|
||||
gboolean return_val = FALSE;
|
||||
gboolean return_val = FALSE;
|
||||
|
||||
if ((src_widget = gtk_drag_get_source_widget (context)))
|
||||
{
|
||||
|
@ -1976,7 +1988,7 @@ layers_dialog_drag_trashcan_callback (GtkWidget *widget,
|
|||
guint time)
|
||||
{
|
||||
GtkWidget *src_widget;
|
||||
gboolean return_val = FALSE;
|
||||
gboolean return_val = FALSE;
|
||||
|
||||
if ((src_widget = gtk_drag_get_source_widget (context)))
|
||||
{
|
||||
|
@ -2017,7 +2029,7 @@ static LayerWidget *
|
|||
layer_widget_get_ID (Layer *ID)
|
||||
{
|
||||
LayerWidget *lw;
|
||||
GSList *list;
|
||||
GSList *list;
|
||||
|
||||
if (! layersD)
|
||||
return NULL;
|
||||
|
@ -2038,10 +2050,10 @@ layer_widget_create (GimpImage *gimage,
|
|||
Layer *layer)
|
||||
{
|
||||
LayerWidget *layer_widget;
|
||||
GtkWidget *list_item;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *alignment;
|
||||
GtkWidget *list_item;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *alignment;
|
||||
|
||||
list_item = gtk_list_item_new ();
|
||||
|
||||
|
@ -2127,9 +2139,10 @@ layer_widget_create (GimpImage *gimage,
|
|||
gtk_drawing_area_size (GTK_DRAWING_AREA (layer_widget->layer_preview),
|
||||
layersD->image_width + 4, layersD->image_height + 4);
|
||||
gtk_widget_set_events (layer_widget->layer_preview, PREVIEW_EVENT_MASK);
|
||||
gtk_signal_connect (GTK_OBJECT (layer_widget->layer_preview), "event",
|
||||
GTK_SIGNAL_FUNC (layer_widget_preview_events),
|
||||
layer_widget);
|
||||
gtk_signal_connect_while_alive (GTK_OBJECT (layer_widget->layer_preview), "event",
|
||||
GTK_SIGNAL_FUNC (layer_widget_preview_events),
|
||||
layer_widget,
|
||||
GTK_OBJECT (layer));
|
||||
gtk_object_set_user_data (GTK_OBJECT (layer_widget->layer_preview),
|
||||
layer_widget);
|
||||
gtk_container_add (GTK_CONTAINER (alignment), layer_widget->layer_preview);
|
||||
|
@ -2240,16 +2253,15 @@ layer_widget_drag_motion_callback (GtkWidget *widget,
|
|||
gint y,
|
||||
guint time)
|
||||
{
|
||||
LayerWidget *dest;
|
||||
gint dest_index;
|
||||
GtkWidget *src_widget;
|
||||
LayerWidget *src;
|
||||
gint src_index;
|
||||
gint difference;
|
||||
|
||||
GimpDropType drop_type = GIMP_DROP_NONE;
|
||||
GdkDragAction drag_action = GDK_ACTION_DEFAULT;
|
||||
gboolean return_val = FALSE;
|
||||
LayerWidget *dest;
|
||||
gint dest_index;
|
||||
GtkWidget *src_widget;
|
||||
LayerWidget *src;
|
||||
gint src_index;
|
||||
gint difference;
|
||||
GimpDropType drop_type = GIMP_DROP_NONE;
|
||||
GdkDragAction drag_action = GDK_ACTION_DEFAULT;
|
||||
gboolean return_val = FALSE;
|
||||
|
||||
dest = (LayerWidget *) gtk_object_get_user_data (GTK_OBJECT (widget));
|
||||
|
||||
|
@ -2314,7 +2326,8 @@ layer_widget_drag_begin_callback (GtkWidget *widget,
|
|||
{
|
||||
LayerWidget *layer_widget;
|
||||
|
||||
layer_widget = (LayerWidget *) gtk_object_get_user_data (GTK_OBJECT (widget));
|
||||
layer_widget =
|
||||
(LayerWidget *) gtk_object_get_user_data (GTK_OBJECT (widget));
|
||||
|
||||
gimp_dnd_set_drawable_preview_icon (widget, context,
|
||||
GIMP_DRAWABLE (layer_widget->layer));
|
||||
|
@ -2326,7 +2339,8 @@ layer_mask_drag_begin_callback (GtkWidget *widget,
|
|||
{
|
||||
LayerWidget *layer_widget;
|
||||
|
||||
layer_widget = (LayerWidget *) gtk_object_get_user_data (GTK_OBJECT (widget));
|
||||
layer_widget =
|
||||
(LayerWidget *) gtk_object_get_user_data (GTK_OBJECT (widget));
|
||||
|
||||
gimp_dnd_set_drawable_preview_icon
|
||||
(widget, context,
|
||||
|
@ -2362,15 +2376,14 @@ layer_widget_drag_drop_callback (GtkWidget *widget,
|
|||
gint y,
|
||||
guint time)
|
||||
{
|
||||
LayerWidget *dest;
|
||||
gint dest_index;
|
||||
GtkWidget *src_widget;
|
||||
LayerWidget *src;
|
||||
gint src_index;
|
||||
gint difference;
|
||||
|
||||
GimpDropType drop_type = GIMP_DROP_NONE;
|
||||
gboolean return_val = FALSE;
|
||||
LayerWidget *dest;
|
||||
gint dest_index;
|
||||
GtkWidget *src_widget;
|
||||
LayerWidget *src;
|
||||
gint src_index;
|
||||
gint difference;
|
||||
GimpDropType drop_type = GIMP_DROP_NONE;
|
||||
gboolean return_val = FALSE;
|
||||
|
||||
dest = (LayerWidget *) gtk_object_get_user_data (GTK_OBJECT (widget));
|
||||
|
||||
|
@ -2378,16 +2391,18 @@ layer_widget_drag_drop_callback (GtkWidget *widget,
|
|||
layer_has_alpha (dest->layer) &&
|
||||
(src_widget = gtk_drag_get_source_widget (context)))
|
||||
{
|
||||
src
|
||||
= (LayerWidget *) gtk_object_get_user_data (GTK_OBJECT (src_widget));
|
||||
src =
|
||||
(LayerWidget *) gtk_object_get_user_data (GTK_OBJECT (src_widget));
|
||||
|
||||
if (src &&
|
||||
layer_has_alpha (src->layer) &&
|
||||
! layer_is_floating_sel (src->layer) &&
|
||||
src->layer == layersD->active_layer)
|
||||
{
|
||||
src_index = gimp_image_get_layer_index (layersD->gimage, src->layer);
|
||||
dest_index = gimp_image_get_layer_index (layersD->gimage, dest->layer);
|
||||
src_index =
|
||||
gimp_image_get_layer_index (layersD->gimage, src->layer);
|
||||
dest_index =
|
||||
gimp_image_get_layer_index (layersD->gimage, dest->layer);
|
||||
|
||||
difference = dest_index - src_index;
|
||||
|
||||
|
@ -2441,7 +2456,8 @@ layer_widget_drag_leave_callback (GtkWidget *widget,
|
|||
{
|
||||
LayerWidget *layer_widget;
|
||||
|
||||
layer_widget = (LayerWidget *) gtk_object_get_user_data (GTK_OBJECT (widget));
|
||||
layer_widget =
|
||||
(LayerWidget *) gtk_object_get_user_data (GTK_OBJECT (widget));
|
||||
|
||||
layer_widget->drop_type = GIMP_DROP_NONE;
|
||||
}
|
||||
|
@ -2452,7 +2468,8 @@ layer_widget_drag_indicator_callback (GtkWidget *widget,
|
|||
{
|
||||
LayerWidget *layer_widget;
|
||||
|
||||
layer_widget = (LayerWidget *) gtk_object_get_user_data (GTK_OBJECT (widget));
|
||||
layer_widget =
|
||||
(LayerWidget *) gtk_object_get_user_data (GTK_OBJECT (widget));
|
||||
|
||||
layer_widget_draw_drop_indicator (layer_widget, layer_widget->drop_type);
|
||||
}
|
||||
|
@ -2462,7 +2479,7 @@ layer_widget_draw_drop_indicator (LayerWidget *layer_widget,
|
|||
GimpDropType drop_type)
|
||||
{
|
||||
static GdkGC *gc = NULL;
|
||||
gint y = 0;
|
||||
gint y = 0;
|
||||
|
||||
if (!gc)
|
||||
{
|
||||
|
@ -2534,15 +2551,15 @@ layer_widget_button_events (GtkWidget *widget,
|
|||
GdkEvent *event,
|
||||
gpointer data)
|
||||
{
|
||||
LayerWidget *layer_widget;
|
||||
GtkWidget *event_widget;
|
||||
GdkEventButton *bevent;
|
||||
gint return_val;
|
||||
LayerWidget *layer_widget;
|
||||
GtkWidget *event_widget;
|
||||
GdkEventButton *bevent;
|
||||
gint return_val;
|
||||
|
||||
static gboolean button_down = FALSE;
|
||||
static GtkWidget *click_widget = NULL;
|
||||
static gint old_state;
|
||||
static gint exclusive;
|
||||
static gint old_state;
|
||||
static gint exclusive;
|
||||
|
||||
layer_widget = (LayerWidget *) gtk_object_get_user_data (GTK_OBJECT (widget));
|
||||
return_val = FALSE;
|
||||
|
@ -2678,14 +2695,16 @@ layer_widget_preview_events (GtkWidget *widget,
|
|||
GdkEventExpose *eevent;
|
||||
GdkEventButton *bevent;
|
||||
GdkPixmap **pixmap;
|
||||
gboolean valid;
|
||||
gint preview_type;
|
||||
gint sx, sy, dx, dy, w, h;
|
||||
gboolean valid;
|
||||
gint preview_type;
|
||||
gint sx, sy, dx, dy, w, h;
|
||||
|
||||
pixmap = NULL;
|
||||
valid = FALSE;
|
||||
|
||||
layer_widget = (LayerWidget *) gtk_object_get_user_data (GTK_OBJECT (widget));
|
||||
layer_widget =
|
||||
(LayerWidget *) gtk_object_get_user_data (GTK_OBJECT (widget));
|
||||
|
||||
if (!GIMP_IS_DRAWABLE (layer_widget->layer))
|
||||
return FALSE;
|
||||
|
||||
|
@ -2704,7 +2723,8 @@ layer_widget_preview_events (GtkWidget *widget,
|
|||
break;
|
||||
case MASK_PREVIEW:
|
||||
pixmap = &layer_widget->mask_pixmap;
|
||||
valid = GIMP_DRAWABLE (layer_get_mask (layer_widget->layer))->preview_valid;
|
||||
valid =
|
||||
GIMP_DRAWABLE (layer_get_mask (layer_widget->layer))->preview_valid;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -2808,19 +2828,23 @@ layer_widget_preview_events (GtkWidget *widget,
|
|||
|
||||
if ((w > 0) && (h > 0))
|
||||
{
|
||||
/* Expose events are optimzed away by GTK+ if the widget is not
|
||||
visible. Therefore, previews not visible in the layers_dialog
|
||||
are not redrawn when they invalidate. Later the preview gets
|
||||
validated by the image_preview in lc_dialog but is never
|
||||
propagated to the layer_pixmap. We work around this by using an
|
||||
additional flag "layer_pixmap_valid" so that the pixmap gets
|
||||
updated once the preview scrolls into sight.
|
||||
We should probably do the same for all drawables (masks,
|
||||
channels), but it is much more difficult to change one of these
|
||||
when it's not visible.
|
||||
*/
|
||||
if (preview_type == LAYER_PREVIEW && ! layer_widget->layer_pixmap_valid)
|
||||
layer_widget_preview_redraw (layer_widget, preview_type);
|
||||
/*
|
||||
Expose events are optimzed away by GTK+ if the widget is not
|
||||
visible. Therefore, previews not visible in the layers_dialog
|
||||
are not redrawn when they invalidate. Later the preview gets
|
||||
validated by the image_preview in lc_dialog but is never
|
||||
propagated to the layer_pixmap. We work around this by using an
|
||||
additional flag "layer_pixmap_valid" so that the pixmap gets
|
||||
updated once the preview scrolls into sight.
|
||||
We should probably do the same for all drawables (masks,
|
||||
channels), but it is much more difficult to change one of these
|
||||
when it's not visible.
|
||||
*/
|
||||
if (preview_type == LAYER_PREVIEW &&
|
||||
! layer_widget->layer_pixmap_valid)
|
||||
{
|
||||
layer_widget_preview_redraw (layer_widget, preview_type);
|
||||
}
|
||||
|
||||
gdk_draw_pixmap (widget->window,
|
||||
widget->style->black_gc,
|
||||
|
@ -2845,9 +2869,10 @@ static void
|
|||
layer_widget_boundary_redraw (LayerWidget *layer_widget,
|
||||
gint preview_type)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
GdkGC *gc1, *gc2;
|
||||
GtkStateType state;
|
||||
GtkWidget *widget;
|
||||
GdkGC *gc1;
|
||||
GdkGC *gc2;
|
||||
GtkStateType state;
|
||||
|
||||
if (preview_type == LAYER_PREVIEW)
|
||||
widget = layer_widget->layer_preview;
|
||||
|
@ -2883,6 +2908,7 @@ layer_widget_boundary_redraw (LayerWidget *layer_widget,
|
|||
layersD->green_gc = gdk_gc_new (widget->window);
|
||||
gdk_gc_set_foreground (layersD->green_gc, &green);
|
||||
}
|
||||
|
||||
if (layersD->red_gc == NULL)
|
||||
{
|
||||
GdkColor red;
|
||||
|
@ -2916,7 +2942,7 @@ layer_widget_preview_redraw (LayerWidget *layer_widget,
|
|||
TempBuf *preview_buf;
|
||||
GdkPixmap **pixmap;
|
||||
GtkWidget *widget;
|
||||
gint offx, offy;
|
||||
gint offx, offy;
|
||||
|
||||
preview_buf = NULL;
|
||||
pixmap = NULL;
|
||||
|
@ -2953,8 +2979,12 @@ layer_widget_preview_redraw (LayerWidget *layer_widget,
|
|||
(gint) (layersD->ratio * GIMP_DRAWABLE (layer_widget->layer)->width);
|
||||
layer_widget->height =
|
||||
(gint) (layersD->ratio * GIMP_DRAWABLE (layer_widget->layer)->height);
|
||||
if (layer_widget->width < 1) layer_widget->width = 1;
|
||||
if (layer_widget->height < 1) layer_widget->height = 1;
|
||||
|
||||
if (layer_widget->width < 1)
|
||||
layer_widget->width = 1;
|
||||
if (layer_widget->height < 1)
|
||||
layer_widget->height = 1;
|
||||
|
||||
offx = (gint) (layersD->ratio *
|
||||
GIMP_DRAWABLE (layer_widget->layer)->offset_x);
|
||||
offy = (gint) (layersD->ratio *
|
||||
|
@ -3005,15 +3035,15 @@ static void
|
|||
layer_widget_no_preview_redraw (LayerWidget *layer_widget,
|
||||
gint preview_type)
|
||||
{
|
||||
GdkPixmap *pixmap;
|
||||
GdkPixmap **pixmap_normal;
|
||||
GdkPixmap **pixmap_selected;
|
||||
GdkPixmap **pixmap_insensitive;
|
||||
GdkColor *color;
|
||||
GtkWidget *widget;
|
||||
GtkStateType state;
|
||||
gchar *bits;
|
||||
gint width, height;
|
||||
GdkPixmap *pixmap;
|
||||
GdkPixmap **pixmap_normal;
|
||||
GdkPixmap **pixmap_selected;
|
||||
GdkPixmap **pixmap_insensitive;
|
||||
GdkColor *color;
|
||||
GtkWidget *widget;
|
||||
GtkStateType state;
|
||||
gchar *bits;
|
||||
gint width, height;
|
||||
|
||||
pixmap_normal = NULL;
|
||||
pixmap_selected = NULL;
|
||||
|
@ -3097,9 +3127,9 @@ layer_widget_no_preview_redraw (LayerWidget *layer_widget,
|
|||
static void
|
||||
layer_widget_eye_redraw (LayerWidget *layer_widget)
|
||||
{
|
||||
GdkPixmap *pixmap;
|
||||
GdkColor *color;
|
||||
GtkStateType state;
|
||||
GdkPixmap *pixmap;
|
||||
GdkColor *color;
|
||||
GtkStateType state;
|
||||
|
||||
state = layer_widget->list_item->state;
|
||||
|
||||
|
@ -3162,9 +3192,9 @@ layer_widget_eye_redraw (LayerWidget *layer_widget)
|
|||
static void
|
||||
layer_widget_linked_redraw (LayerWidget *layer_widget)
|
||||
{
|
||||
GdkPixmap *pixmap;
|
||||
GdkColor *color;
|
||||
GtkStateType state;
|
||||
GdkPixmap *pixmap;
|
||||
GdkColor *color;
|
||||
GtkStateType state;
|
||||
|
||||
state = layer_widget->list_item->state;
|
||||
|
||||
|
@ -3272,11 +3302,11 @@ layer_widget_layer_flush (GtkWidget *widget,
|
|||
gpointer data)
|
||||
{
|
||||
LayerWidget *layer_widget;
|
||||
Layer *layer;
|
||||
gchar *name;
|
||||
gchar *label_name;
|
||||
gboolean update_layer_preview = FALSE;
|
||||
gboolean update_mask_preview = FALSE;
|
||||
Layer *layer;
|
||||
gchar *name;
|
||||
gchar *label_name;
|
||||
gboolean update_layer_preview = FALSE;
|
||||
gboolean update_mask_preview = FALSE;
|
||||
|
||||
layer_widget = (LayerWidget *) gtk_object_get_user_data (GTK_OBJECT (widget));
|
||||
layer = layer_widget->layer;
|
||||
|
@ -3354,7 +3384,8 @@ layer_widget_layer_flush (GtkWidget *widget,
|
|||
|
||||
if (layer_get_mask (layer))
|
||||
{
|
||||
update_mask_preview = (! GIMP_DRAWABLE (layer_get_mask (layer))->preview_valid);
|
||||
update_mask_preview =
|
||||
(! GIMP_DRAWABLE (layer_get_mask (layer))->preview_valid);
|
||||
|
||||
if (layer->apply_mask != layer_widget->apply_mask)
|
||||
{
|
||||
|
@ -3414,8 +3445,8 @@ new_layer_query_ok_callback (GtkWidget *widget,
|
|||
gpointer data)
|
||||
{
|
||||
NewLayerOptions *options;
|
||||
Layer *layer;
|
||||
GimpImage *gimage;
|
||||
Layer *layer;
|
||||
GimpImage *gimage;
|
||||
|
||||
options = (NewLayerOptions *) data;
|
||||
|
||||
|
@ -3462,12 +3493,12 @@ static void
|
|||
layers_dialog_new_layer_query (GimpImage* gimage)
|
||||
{
|
||||
NewLayerOptions *options;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *table;
|
||||
GtkWidget *label;
|
||||
GtkObject *adjustment;
|
||||
GtkWidget *spinbutton;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *table;
|
||||
GtkWidget *label;
|
||||
GtkObject *adjustment;
|
||||
GtkWidget *spinbutton;
|
||||
GtkWidget *frame;
|
||||
|
||||
/* The new options structure */
|
||||
options = g_new (NewLayerOptions, 1);
|
||||
|
@ -3513,7 +3544,8 @@ layers_dialog_new_layer_query (GimpImage* gimage)
|
|||
|
||||
options->name_entry = gtk_entry_new ();
|
||||
gtk_widget_set_usize (options->name_entry, 75, 0);
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), options->name_entry, 1, 2, 0, 1);
|
||||
gtk_table_attach_defaults (GTK_TABLE (table),
|
||||
options->name_entry, 1, 2, 0, 1);
|
||||
gtk_entry_set_text (GTK_ENTRY (options->name_entry),
|
||||
(layer_name ? layer_name : _("New Layer")));
|
||||
gtk_widget_show (options->name_entry);
|
||||
|
@ -3551,7 +3583,8 @@ layers_dialog_new_layer_query (GimpImage* gimage)
|
|||
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
|
||||
gtk_widget_show (options->size_se);
|
||||
|
||||
gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (options->size_se), GIMP_UNIT_PIXEL);
|
||||
gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (options->size_se),
|
||||
GIMP_UNIT_PIXEL);
|
||||
|
||||
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (options->size_se), 0,
|
||||
gimage->xresolution, FALSE);
|
||||
|
@ -3616,7 +3649,7 @@ edit_layer_query_ok_callback (GtkWidget *widget,
|
|||
gpointer data)
|
||||
{
|
||||
EditLayerOptions *options;
|
||||
Layer *layer;
|
||||
Layer *layer;
|
||||
|
||||
options = (EditLayerOptions *) data;
|
||||
|
||||
|
@ -3647,9 +3680,9 @@ static void
|
|||
layers_dialog_edit_layer_query (LayerWidget *layer_widget)
|
||||
{
|
||||
EditLayerOptions *options;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *label;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *label;
|
||||
|
||||
/* The new options structure */
|
||||
options = g_new (EditLayerOptions, 1);
|
||||
|
@ -3724,9 +3757,9 @@ add_mask_query_ok_callback (GtkWidget *widget,
|
|||
gpointer data)
|
||||
{
|
||||
AddMaskOptions *options;
|
||||
GimpImage *gimage;
|
||||
LayerMask *mask;
|
||||
Layer *layer;
|
||||
GimpImage *gimage;
|
||||
LayerMask *mask;
|
||||
Layer *layer;
|
||||
|
||||
options = (AddMaskOptions *) data;
|
||||
if ((layer = (options->layer)) &&
|
||||
|
@ -3744,7 +3777,7 @@ static void
|
|||
layers_dialog_add_mask_query (Layer *layer)
|
||||
{
|
||||
AddMaskOptions *options;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *frame;
|
||||
|
||||
/* The new options structure */
|
||||
options = g_new (AddMaskOptions, 1);
|
||||
|
@ -3810,8 +3843,8 @@ scale_layer_query_ok_callback (GtkWidget *widget,
|
|||
gpointer data)
|
||||
{
|
||||
ScaleLayerOptions *options;
|
||||
GimpImage *gimage;
|
||||
Layer *layer;
|
||||
GimpImage *gimage;
|
||||
Layer *layer;
|
||||
|
||||
options = (ScaleLayerOptions *) data;
|
||||
|
||||
|
@ -3827,7 +3860,8 @@ scale_layer_query_ok_callback (GtkWidget *widget,
|
|||
if (layer_is_floating_sel (layer))
|
||||
floating_sel_relax (layer, TRUE);
|
||||
|
||||
layer_scale (layer, options->resize->width, options->resize->height, TRUE);
|
||||
layer_scale (layer,
|
||||
options->resize->width, options->resize->height, TRUE);
|
||||
|
||||
if (layer_is_floating_sel (layer))
|
||||
floating_sel_rigor (layer, TRUE);
|
||||
|
@ -3894,8 +3928,8 @@ resize_layer_query_ok_callback (GtkWidget *widget,
|
|||
gpointer data)
|
||||
{
|
||||
ResizeLayerOptions *options;
|
||||
GimpImage *gimage;
|
||||
Layer *layer;
|
||||
GimpImage *gimage;
|
||||
Layer *layer;
|
||||
|
||||
options = (ResizeLayerOptions *) data;
|
||||
|
||||
|
@ -4002,8 +4036,8 @@ layers_dialog_layer_merge_query (GimpImage *gimage,
|
|||
gboolean merge_visible)
|
||||
{
|
||||
LayerMergeOptions *options;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *frame;
|
||||
|
||||
/* The new options structure */
|
||||
options = g_new (LayerMergeOptions, 1);
|
||||
|
|
|
@ -194,7 +194,7 @@ typedef struct
|
|||
struct jpeg_compress_struct cinfo;
|
||||
gint tile_height;
|
||||
FILE *outfile;
|
||||
gint has_alpha;
|
||||
gboolean has_alpha;
|
||||
gint rowstride;
|
||||
guchar *temp;
|
||||
guchar *data;
|
||||
|
@ -210,37 +210,37 @@ static gboolean *abort_me = NULL;
|
|||
|
||||
/* Declare local functions.
|
||||
*/
|
||||
static void query (void);
|
||||
static void run (gchar *name,
|
||||
gint nparams,
|
||||
GimpParam *param,
|
||||
gint *nreturn_vals,
|
||||
GimpParam **return_vals);
|
||||
static gint32 load_image (gchar *filename,
|
||||
GimpRunModeType runmode,
|
||||
gboolean preview);
|
||||
static gint save_image (gchar *filename,
|
||||
gint32 image_ID,
|
||||
gint32 drawable_ID,
|
||||
gint32 orig_image_ID,
|
||||
gboolean preview);
|
||||
static void query (void);
|
||||
static void run (gchar *name,
|
||||
gint nparams,
|
||||
GimpParam *param,
|
||||
gint *nreturn_vals,
|
||||
GimpParam **return_vals);
|
||||
static gint32 load_image (gchar *filename,
|
||||
GimpRunModeType runmode,
|
||||
gboolean preview);
|
||||
static gboolean save_image (gchar *filename,
|
||||
gint32 image_ID,
|
||||
gint32 drawable_ID,
|
||||
gint32 orig_image_ID,
|
||||
gboolean preview);
|
||||
|
||||
static gint save_dialog (void);
|
||||
static gboolean save_dialog (void);
|
||||
|
||||
static void save_close_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void save_ok_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void save_restart_toggle_update (GtkWidget *toggle,
|
||||
GtkAdjustment *adjustment);
|
||||
static void save_restart_update (GtkAdjustment *adjustment,
|
||||
GtkWidget *toggle);
|
||||
static void save_close_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void save_ok_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void save_restart_toggle_update (GtkWidget *toggle,
|
||||
GtkAdjustment *adjustment);
|
||||
static void save_restart_update (GtkAdjustment *adjustment,
|
||||
GtkWidget *toggle);
|
||||
|
||||
static void make_preview (void);
|
||||
static void destroy_preview (void);
|
||||
static void make_preview (void);
|
||||
static void destroy_preview (void);
|
||||
|
||||
static void menu_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void menu_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
|
||||
|
||||
GimpPlugInInfo PLUG_IN_INFO =
|
||||
|
@ -347,24 +347,24 @@ query (void)
|
|||
}
|
||||
|
||||
static void
|
||||
run (gchar *name,
|
||||
gint nparams,
|
||||
run (gchar *name,
|
||||
gint nparams,
|
||||
GimpParam *param,
|
||||
gint *nreturn_vals,
|
||||
gint *nreturn_vals,
|
||||
GimpParam **return_vals)
|
||||
{
|
||||
static GimpParam values[2];
|
||||
GimpRunModeType run_mode;
|
||||
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
||||
gint32 image_ID;
|
||||
gint32 drawable_ID;
|
||||
gint32 orig_image_ID;
|
||||
gint32 display_ID = -1;
|
||||
static GimpParam values[2];
|
||||
GimpRunModeType run_mode;
|
||||
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
||||
gint32 image_ID;
|
||||
gint32 drawable_ID;
|
||||
gint32 orig_image_ID;
|
||||
gint32 display_ID = -1;
|
||||
#ifdef GIMP_HAVE_PARASITES
|
||||
GimpParasite *parasite;
|
||||
GimpParasite *parasite;
|
||||
#endif /* GIMP_HAVE_PARASITES */
|
||||
gint err;
|
||||
GimpExportReturnType export = GIMP_EXPORT_CANCEL;
|
||||
gboolean err;
|
||||
GimpExportReturnType export = GIMP_EXPORT_CANCEL;
|
||||
|
||||
run_mode = param[0].data.d_int32;
|
||||
|
||||
|
@ -622,7 +622,7 @@ run (gchar *name,
|
|||
static guint
|
||||
jpeg_getc (j_decompress_ptr cinfo)
|
||||
{
|
||||
struct jpeg_source_mgr * datasrc = cinfo->src;
|
||||
struct jpeg_source_mgr *datasrc = cinfo->src;
|
||||
|
||||
if (datasrc->bytes_in_buffer == 0)
|
||||
{
|
||||
|
@ -630,6 +630,7 @@ jpeg_getc (j_decompress_ptr cinfo)
|
|||
ERREXIT (cinfo, JERR_CANT_SUSPEND);
|
||||
}
|
||||
datasrc->bytes_in_buffer--;
|
||||
|
||||
return *datasrc->next_input_byte++;
|
||||
}
|
||||
|
||||
|
@ -647,8 +648,8 @@ static GString *local_image_comments = NULL;
|
|||
static boolean
|
||||
COM_handler (j_decompress_ptr cinfo)
|
||||
{
|
||||
int length;
|
||||
unsigned int ch;
|
||||
gint length;
|
||||
guint ch;
|
||||
|
||||
length = jpeg_getc (cinfo) << 8;
|
||||
length += jpeg_getc (cinfo);
|
||||
|
@ -700,22 +701,22 @@ load_image (gchar *filename,
|
|||
GimpRunModeType runmode,
|
||||
gboolean preview)
|
||||
{
|
||||
GimpPixelRgn pixel_rgn;
|
||||
GimpDrawable *drawable;
|
||||
gint32 volatile image_ID;
|
||||
gint32 layer_ID;
|
||||
GimpPixelRgn pixel_rgn;
|
||||
GimpDrawable *drawable;
|
||||
gint32 volatile image_ID;
|
||||
gint32 layer_ID;
|
||||
struct jpeg_decompress_struct cinfo;
|
||||
struct my_error_mgr jerr;
|
||||
FILE *infile;
|
||||
guchar *buf;
|
||||
guchar * volatile padded_buf = NULL;
|
||||
struct my_error_mgr jerr;
|
||||
FILE *infile;
|
||||
guchar *buf;
|
||||
guchar * volatile padded_buf = NULL;
|
||||
guchar **rowbuf;
|
||||
gchar *name;
|
||||
gint image_type;
|
||||
gint layer_type;
|
||||
gint tile_height;
|
||||
gint scanlines;
|
||||
gint i, start, end;
|
||||
gchar *name;
|
||||
gint image_type;
|
||||
gint layer_type;
|
||||
gint tile_height;
|
||||
gint scanlines;
|
||||
gint i, start, end;
|
||||
|
||||
#ifdef GIMP_HAVE_PARASITES
|
||||
JpegSaveVals local_save_vals;
|
||||
|
@ -723,7 +724,6 @@ load_image (gchar *filename,
|
|||
GimpParasite * volatile vals_parasite = NULL;
|
||||
#endif /* GIMP_HAVE_PARASITES */
|
||||
|
||||
|
||||
/* We set up the normal JPEG error routines. */
|
||||
cinfo.err = jpeg_std_error (&jerr.pub);
|
||||
jerr.pub.error_exit = my_error_exit;
|
||||
|
@ -778,46 +778,47 @@ load_image (gchar *filename,
|
|||
*/
|
||||
|
||||
#ifdef GIMP_HAVE_PARASITES
|
||||
if (!preview) {
|
||||
/* if we had any comments then make a parasite for them */
|
||||
if (local_image_comments && local_image_comments->len)
|
||||
{
|
||||
gchar *string = local_image_comments->str;
|
||||
g_string_free (local_image_comments, FALSE);
|
||||
local_image_comments = NULL;
|
||||
comment_parasite = gimp_parasite_new ("gimp-comment",
|
||||
GIMP_PARASITE_PERSISTENT,
|
||||
strlen (string) + 1, string);
|
||||
}
|
||||
else
|
||||
{
|
||||
comment_parasite = NULL;
|
||||
}
|
||||
|
||||
/* pw - figuring out what the saved values were is non-trivial.
|
||||
* They don't seem to be in the cinfo structure. For now, I will
|
||||
* just use the defaults, but if someone figures out how to derive
|
||||
* them this is the place to store them. */
|
||||
|
||||
local_save_vals.quality = DEFAULT_QUALITY;
|
||||
local_save_vals.smoothing = DEFAULT_SMOOTHING;
|
||||
local_save_vals.optimize = DEFAULT_OPTIMIZE;
|
||||
|
||||
if (!preview)
|
||||
{
|
||||
/* if we had any comments then make a parasite for them */
|
||||
if (local_image_comments && local_image_comments->len)
|
||||
{
|
||||
gchar *string = local_image_comments->str;
|
||||
g_string_free (local_image_comments, FALSE);
|
||||
local_image_comments = NULL;
|
||||
comment_parasite = gimp_parasite_new ("gimp-comment",
|
||||
GIMP_PARASITE_PERSISTENT,
|
||||
strlen (string) + 1, string);
|
||||
}
|
||||
else
|
||||
{
|
||||
comment_parasite = NULL;
|
||||
}
|
||||
|
||||
/* pw - figuring out what the saved values were is non-trivial.
|
||||
* They don't seem to be in the cinfo structure. For now, I will
|
||||
* just use the defaults, but if someone figures out how to derive
|
||||
* them this is the place to store them. */
|
||||
|
||||
local_save_vals.quality = DEFAULT_QUALITY;
|
||||
local_save_vals.smoothing = DEFAULT_SMOOTHING;
|
||||
local_save_vals.optimize = DEFAULT_OPTIMIZE;
|
||||
|
||||
#ifdef HAVE_PROGRESSIVE_JPEG
|
||||
local_save_vals.progressive = cinfo.progressive_mode;
|
||||
local_save_vals.progressive = cinfo.progressive_mode;
|
||||
#else
|
||||
local_save_vals.progressive = 0;
|
||||
local_save_vals.progressive = 0;
|
||||
#endif /* HAVE_PROGRESSIVE_JPEG */
|
||||
local_save_vals.baseline = DEFAULT_BASELINE;
|
||||
local_save_vals.subsmp = DEFAULT_SUBSMP; /* sg - this _is_ there, but I'm too lazy */
|
||||
local_save_vals.restart = DEFAULT_RESTART;
|
||||
local_save_vals.dct = DEFAULT_DCT;
|
||||
local_save_vals.preview = DEFAULT_PREVIEW;
|
||||
|
||||
vals_parasite = gimp_parasite_new ("jpeg-save-options", 0,
|
||||
sizeof (local_save_vals),
|
||||
&local_save_vals);
|
||||
}
|
||||
local_save_vals.baseline = DEFAULT_BASELINE;
|
||||
local_save_vals.subsmp = DEFAULT_SUBSMP; /* sg - this _is_ there, but I'm too lazy */
|
||||
local_save_vals.restart = DEFAULT_RESTART;
|
||||
local_save_vals.dct = DEFAULT_DCT;
|
||||
local_save_vals.preview = DEFAULT_PREVIEW;
|
||||
|
||||
vals_parasite = gimp_parasite_new ("jpeg-save-options", 0,
|
||||
sizeof (local_save_vals),
|
||||
&local_save_vals);
|
||||
}
|
||||
#endif /* GIMP_HAVE_PARASITES */
|
||||
|
||||
|
||||
|
@ -862,14 +863,17 @@ load_image (gchar *filename,
|
|||
image_type = GIMP_GRAY;
|
||||
layer_type = preview ? GIMP_GRAYA_IMAGE : GIMP_GRAY_IMAGE;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
image_type = GIMP_RGB;
|
||||
layer_type = preview ? GIMP_RGBA_IMAGE : GIMP_RGB_IMAGE;
|
||||
break;
|
||||
|
||||
default:
|
||||
g_message ("don't know how to load JPEGs\nwith %d color channels",
|
||||
cinfo.output_components);
|
||||
cinfo.output_components);
|
||||
gimp_quit ();
|
||||
break;
|
||||
}
|
||||
|
||||
if (preview)
|
||||
|
@ -885,10 +889,11 @@ load_image (gchar *filename,
|
|||
|
||||
if (preview)
|
||||
{
|
||||
layer_ID_global = layer_ID = gimp_layer_new (image_ID, _("JPEG preview"),
|
||||
cinfo.output_width,
|
||||
cinfo.output_height,
|
||||
layer_type, 100, GIMP_NORMAL_MODE);
|
||||
layer_ID_global = layer_ID =
|
||||
gimp_layer_new (image_ID, _("JPEG preview"),
|
||||
cinfo.output_width,
|
||||
cinfo.output_height,
|
||||
layer_type, 100, GIMP_NORMAL_MODE);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -951,23 +956,18 @@ load_image (gchar *filename,
|
|||
while (cinfo.output_scanline < cinfo.output_height)
|
||||
{
|
||||
start = cinfo.output_scanline;
|
||||
end = cinfo.output_scanline + tile_height;
|
||||
end = MIN (end, cinfo.output_height);
|
||||
end = cinfo.output_scanline + tile_height;
|
||||
end = MIN (end, cinfo.output_height);
|
||||
scanlines = end - start;
|
||||
|
||||
for (i = 0; i < scanlines; i++)
|
||||
jpeg_read_scanlines (&cinfo, (JSAMPARRAY) &rowbuf[i], 1);
|
||||
|
||||
/*
|
||||
for (i = start; i < end; i++)
|
||||
gimp_pixel_rgn_set_row (&pixel_rgn, tilerow[i - start], 0, i, drawable->width);
|
||||
*/
|
||||
|
||||
if (preview) /* Add a dummy alpha channel -- convert buf to padded_buf */
|
||||
{
|
||||
guchar *dest = padded_buf;
|
||||
guchar *src = buf;
|
||||
gint num = drawable->width * scanlines;
|
||||
gint num = drawable->width * scanlines;
|
||||
|
||||
switch (cinfo.output_components)
|
||||
{
|
||||
|
@ -978,6 +978,7 @@ load_image (gchar *filename,
|
|||
*(dest++) = 255;
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
for (i=0; i<num; i++)
|
||||
{
|
||||
|
@ -987,8 +988,10 @@ load_image (gchar *filename,
|
|||
*(dest++) = 255;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
g_warning ("JPEG - shouldn't have gotten here. Report to adam@gimp.org");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -997,7 +1000,8 @@ load_image (gchar *filename,
|
|||
|
||||
if (runmode != GIMP_RUN_NONINTERACTIVE)
|
||||
{
|
||||
gimp_progress_update ((double) cinfo.output_scanline / (double) cinfo.output_height);
|
||||
gimp_progress_update ((gdouble) cinfo.output_scanline /
|
||||
(gdouble) cinfo.output_height);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1046,6 +1050,7 @@ load_image (gchar *filename,
|
|||
gimp_image_parasite_attach (image_ID, comment_parasite);
|
||||
gimp_parasite_free (comment_parasite);
|
||||
}
|
||||
|
||||
if (vals_parasite)
|
||||
{
|
||||
gimp_image_parasite_attach (image_ID, vals_parasite);
|
||||
|
@ -1070,19 +1075,16 @@ background_error_exit (j_common_ptr cinfo)
|
|||
(*cinfo->err->output_message) (cinfo);
|
||||
}
|
||||
|
||||
static gint
|
||||
static gboolean
|
||||
background_jpeg_save (PreviewPersistent *pp)
|
||||
{
|
||||
guchar *t;
|
||||
guchar *s;
|
||||
gint i, j;
|
||||
gint yend;
|
||||
gint i, j;
|
||||
gint yend;
|
||||
|
||||
if (pp->abort_me || (pp->cinfo.next_scanline >= pp->cinfo.image_height))
|
||||
{
|
||||
struct stat buf;
|
||||
gchar temp[256];
|
||||
|
||||
/* clean up... */
|
||||
if (pp->abort_me)
|
||||
{
|
||||
|
@ -1099,11 +1101,15 @@ background_jpeg_save (PreviewPersistent *pp)
|
|||
g_free (pp->temp);
|
||||
g_free (pp->data);
|
||||
|
||||
if (pp->drawable) gimp_drawable_detach (pp->drawable);
|
||||
if (pp->drawable)
|
||||
gimp_drawable_detach (pp->drawable);
|
||||
|
||||
/* display the preview stuff */
|
||||
if (!pp->abort_me)
|
||||
{
|
||||
struct stat buf;
|
||||
gchar temp[128];
|
||||
|
||||
stat (pp->file_name, &buf);
|
||||
g_snprintf (temp, sizeof (temp),
|
||||
_("Size: %lu bytes (%02.01f kB)"),
|
||||
|
@ -1160,26 +1166,26 @@ background_jpeg_save (PreviewPersistent *pp)
|
|||
}
|
||||
}
|
||||
|
||||
static gint
|
||||
static gboolean
|
||||
save_image (gchar *filename,
|
||||
gint32 image_ID,
|
||||
gint32 drawable_ID,
|
||||
gint32 orig_image_ID,
|
||||
gboolean preview)
|
||||
{
|
||||
GimpPixelRgn pixel_rgn;
|
||||
GimpDrawable *drawable;
|
||||
GimpImageType drawable_type;
|
||||
GimpPixelRgn pixel_rgn;
|
||||
GimpDrawable *drawable;
|
||||
GimpImageType drawable_type;
|
||||
struct jpeg_compress_struct cinfo;
|
||||
struct my_error_mgr jerr;
|
||||
FILE * volatile outfile;
|
||||
guchar *temp, *t;
|
||||
guchar *data;
|
||||
guchar *src, *s;
|
||||
gchar *name;
|
||||
gint has_alpha;
|
||||
gint rowstride, yend;
|
||||
gint i, j;
|
||||
struct my_error_mgr jerr;
|
||||
FILE * volatile outfile;
|
||||
guchar *temp, *t;
|
||||
guchar *data;
|
||||
guchar *src, *s;
|
||||
gchar *name;
|
||||
gboolean has_alpha;
|
||||
gint rowstride, yend;
|
||||
gint i, j;
|
||||
|
||||
drawable = gimp_drawable_get (drawable_ID);
|
||||
drawable_type = gimp_drawable_type (drawable_ID);
|
||||
|
@ -1245,19 +1251,22 @@ save_image (gchar *filename,
|
|||
case GIMP_GRAY_IMAGE:
|
||||
/* # of color components per pixel */
|
||||
cinfo.input_components = drawable->bpp;
|
||||
has_alpha = 0;
|
||||
has_alpha = FALSE;
|
||||
break;
|
||||
|
||||
case GIMP_RGBA_IMAGE:
|
||||
case GIMP_GRAYA_IMAGE:
|
||||
/*gimp_message ("jpeg: image contains a-channel info which will be lost");*/
|
||||
/* # of color components per pixel (minus the GIMP alpha channel) */
|
||||
cinfo.input_components = drawable->bpp - 1;
|
||||
has_alpha = 1;
|
||||
has_alpha = TRUE;
|
||||
break;
|
||||
|
||||
case GIMP_INDEXED_IMAGE:
|
||||
/*gimp_message ("jpeg: cannot operate on indexed color images");*/
|
||||
return FALSE;
|
||||
break;
|
||||
|
||||
default:
|
||||
/*gimp_message ("jpeg: cannot operate on unknown image types");*/
|
||||
return FALSE;
|
||||
|
@ -1282,8 +1291,8 @@ save_image (gchar *filename,
|
|||
*/
|
||||
jpeg_set_defaults (&cinfo);
|
||||
|
||||
jpeg_set_quality (&cinfo, (int) (jsvals.quality * 100), jsvals.baseline);
|
||||
cinfo.smoothing_factor = (int) (jsvals.smoothing * 100);
|
||||
jpeg_set_quality (&cinfo, (gint) (jsvals.quality * 100), jsvals.baseline);
|
||||
cinfo.smoothing_factor = (gint) (jsvals.smoothing * 100);
|
||||
cinfo.optimize_coding = jsvals.optimize;
|
||||
|
||||
#ifdef HAVE_PROGRESSIVE_JPEG
|
||||
|
@ -1304,6 +1313,7 @@ save_image (gchar *filename,
|
|||
cinfo.comp_info[2].h_samp_factor = 1;
|
||||
cinfo.comp_info[2].v_samp_factor = 1;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
cinfo.comp_info[0].h_samp_factor = 2;
|
||||
cinfo.comp_info[0].v_samp_factor = 1;
|
||||
|
@ -1312,6 +1322,7 @@ save_image (gchar *filename,
|
|||
cinfo.comp_info[2].h_samp_factor = 1;
|
||||
cinfo.comp_info[2].v_samp_factor = 1;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
cinfo.comp_info[0].h_samp_factor = 1;
|
||||
cinfo.comp_info[0].v_samp_factor = 1;
|
||||
|
@ -1331,9 +1342,11 @@ save_image (gchar *filename,
|
|||
default:
|
||||
cinfo.dct_method = JDCT_ISLOW;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
cinfo.dct_method = JDCT_IFAST;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
cinfo.dct_method = JDCT_FLOAT;
|
||||
break;
|
||||
|
@ -1432,7 +1445,7 @@ save_image (gchar *filename,
|
|||
|
||||
jerr.pub.error_exit = background_error_exit;
|
||||
|
||||
gtk_idle_add ((GtkFunction) background_jpeg_save, (gpointer *)pp);
|
||||
gtk_idle_add ((GtkFunction) background_jpeg_save, (gpointer) pp);
|
||||
|
||||
/* background_jpeg_save() will cleanup as needed */
|
||||
return TRUE;
|
||||
|
@ -1525,21 +1538,25 @@ destroy_preview (void)
|
|||
{
|
||||
*abort_me = TRUE; /* signal the background save to stop */
|
||||
}
|
||||
|
||||
if (drawable_global)
|
||||
{
|
||||
gimp_drawable_detach (drawable_global);
|
||||
drawable_global = NULL;
|
||||
}
|
||||
|
||||
if (layer_ID_global != -1 && image_ID_global != -1)
|
||||
{
|
||||
/* assuming that reference counting is working correctly,
|
||||
we do not need to delete the layer, removing it from
|
||||
the image should be sufficient */
|
||||
gimp_image_remove_layer (image_ID_global, layer_ID_global);
|
||||
|
||||
/* gimp_layer_delete(layer_ID_global); */
|
||||
layer_ID_global = -1;
|
||||
}
|
||||
}
|
||||
|
||||
static gint
|
||||
static gboolean
|
||||
save_dialog (void)
|
||||
{
|
||||
GtkWidget *dlg;
|
||||
|
@ -1858,6 +1875,7 @@ save_ok_callback (GtkWidget *widget,
|
|||
gpointer data)
|
||||
{
|
||||
GtkWidget *text;
|
||||
|
||||
jsint.run = TRUE;
|
||||
|
||||
/* pw - get the comment text object and grab it's data */
|
||||
|
@ -1898,7 +1916,7 @@ save_restart_update (GtkAdjustment *adjustment,
|
|||
|
||||
static void
|
||||
menu_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
gpointer data)
|
||||
{
|
||||
gimp_menu_item_update (widget, data);
|
||||
make_preview ();
|
||||
|
|
|
@ -194,7 +194,7 @@ typedef struct
|
|||
struct jpeg_compress_struct cinfo;
|
||||
gint tile_height;
|
||||
FILE *outfile;
|
||||
gint has_alpha;
|
||||
gboolean has_alpha;
|
||||
gint rowstride;
|
||||
guchar *temp;
|
||||
guchar *data;
|
||||
|
@ -210,37 +210,37 @@ static gboolean *abort_me = NULL;
|
|||
|
||||
/* Declare local functions.
|
||||
*/
|
||||
static void query (void);
|
||||
static void run (gchar *name,
|
||||
gint nparams,
|
||||
GimpParam *param,
|
||||
gint *nreturn_vals,
|
||||
GimpParam **return_vals);
|
||||
static gint32 load_image (gchar *filename,
|
||||
GimpRunModeType runmode,
|
||||
gboolean preview);
|
||||
static gint save_image (gchar *filename,
|
||||
gint32 image_ID,
|
||||
gint32 drawable_ID,
|
||||
gint32 orig_image_ID,
|
||||
gboolean preview);
|
||||
static void query (void);
|
||||
static void run (gchar *name,
|
||||
gint nparams,
|
||||
GimpParam *param,
|
||||
gint *nreturn_vals,
|
||||
GimpParam **return_vals);
|
||||
static gint32 load_image (gchar *filename,
|
||||
GimpRunModeType runmode,
|
||||
gboolean preview);
|
||||
static gboolean save_image (gchar *filename,
|
||||
gint32 image_ID,
|
||||
gint32 drawable_ID,
|
||||
gint32 orig_image_ID,
|
||||
gboolean preview);
|
||||
|
||||
static gint save_dialog (void);
|
||||
static gboolean save_dialog (void);
|
||||
|
||||
static void save_close_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void save_ok_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void save_restart_toggle_update (GtkWidget *toggle,
|
||||
GtkAdjustment *adjustment);
|
||||
static void save_restart_update (GtkAdjustment *adjustment,
|
||||
GtkWidget *toggle);
|
||||
static void save_close_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void save_ok_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void save_restart_toggle_update (GtkWidget *toggle,
|
||||
GtkAdjustment *adjustment);
|
||||
static void save_restart_update (GtkAdjustment *adjustment,
|
||||
GtkWidget *toggle);
|
||||
|
||||
static void make_preview (void);
|
||||
static void destroy_preview (void);
|
||||
static void make_preview (void);
|
||||
static void destroy_preview (void);
|
||||
|
||||
static void menu_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void menu_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
|
||||
|
||||
GimpPlugInInfo PLUG_IN_INFO =
|
||||
|
@ -347,24 +347,24 @@ query (void)
|
|||
}
|
||||
|
||||
static void
|
||||
run (gchar *name,
|
||||
gint nparams,
|
||||
run (gchar *name,
|
||||
gint nparams,
|
||||
GimpParam *param,
|
||||
gint *nreturn_vals,
|
||||
gint *nreturn_vals,
|
||||
GimpParam **return_vals)
|
||||
{
|
||||
static GimpParam values[2];
|
||||
GimpRunModeType run_mode;
|
||||
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
||||
gint32 image_ID;
|
||||
gint32 drawable_ID;
|
||||
gint32 orig_image_ID;
|
||||
gint32 display_ID = -1;
|
||||
static GimpParam values[2];
|
||||
GimpRunModeType run_mode;
|
||||
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
||||
gint32 image_ID;
|
||||
gint32 drawable_ID;
|
||||
gint32 orig_image_ID;
|
||||
gint32 display_ID = -1;
|
||||
#ifdef GIMP_HAVE_PARASITES
|
||||
GimpParasite *parasite;
|
||||
GimpParasite *parasite;
|
||||
#endif /* GIMP_HAVE_PARASITES */
|
||||
gint err;
|
||||
GimpExportReturnType export = GIMP_EXPORT_CANCEL;
|
||||
gboolean err;
|
||||
GimpExportReturnType export = GIMP_EXPORT_CANCEL;
|
||||
|
||||
run_mode = param[0].data.d_int32;
|
||||
|
||||
|
@ -622,7 +622,7 @@ run (gchar *name,
|
|||
static guint
|
||||
jpeg_getc (j_decompress_ptr cinfo)
|
||||
{
|
||||
struct jpeg_source_mgr * datasrc = cinfo->src;
|
||||
struct jpeg_source_mgr *datasrc = cinfo->src;
|
||||
|
||||
if (datasrc->bytes_in_buffer == 0)
|
||||
{
|
||||
|
@ -630,6 +630,7 @@ jpeg_getc (j_decompress_ptr cinfo)
|
|||
ERREXIT (cinfo, JERR_CANT_SUSPEND);
|
||||
}
|
||||
datasrc->bytes_in_buffer--;
|
||||
|
||||
return *datasrc->next_input_byte++;
|
||||
}
|
||||
|
||||
|
@ -647,8 +648,8 @@ static GString *local_image_comments = NULL;
|
|||
static boolean
|
||||
COM_handler (j_decompress_ptr cinfo)
|
||||
{
|
||||
int length;
|
||||
unsigned int ch;
|
||||
gint length;
|
||||
guint ch;
|
||||
|
||||
length = jpeg_getc (cinfo) << 8;
|
||||
length += jpeg_getc (cinfo);
|
||||
|
@ -700,22 +701,22 @@ load_image (gchar *filename,
|
|||
GimpRunModeType runmode,
|
||||
gboolean preview)
|
||||
{
|
||||
GimpPixelRgn pixel_rgn;
|
||||
GimpDrawable *drawable;
|
||||
gint32 volatile image_ID;
|
||||
gint32 layer_ID;
|
||||
GimpPixelRgn pixel_rgn;
|
||||
GimpDrawable *drawable;
|
||||
gint32 volatile image_ID;
|
||||
gint32 layer_ID;
|
||||
struct jpeg_decompress_struct cinfo;
|
||||
struct my_error_mgr jerr;
|
||||
FILE *infile;
|
||||
guchar *buf;
|
||||
guchar * volatile padded_buf = NULL;
|
||||
struct my_error_mgr jerr;
|
||||
FILE *infile;
|
||||
guchar *buf;
|
||||
guchar * volatile padded_buf = NULL;
|
||||
guchar **rowbuf;
|
||||
gchar *name;
|
||||
gint image_type;
|
||||
gint layer_type;
|
||||
gint tile_height;
|
||||
gint scanlines;
|
||||
gint i, start, end;
|
||||
gchar *name;
|
||||
gint image_type;
|
||||
gint layer_type;
|
||||
gint tile_height;
|
||||
gint scanlines;
|
||||
gint i, start, end;
|
||||
|
||||
#ifdef GIMP_HAVE_PARASITES
|
||||
JpegSaveVals local_save_vals;
|
||||
|
@ -723,7 +724,6 @@ load_image (gchar *filename,
|
|||
GimpParasite * volatile vals_parasite = NULL;
|
||||
#endif /* GIMP_HAVE_PARASITES */
|
||||
|
||||
|
||||
/* We set up the normal JPEG error routines. */
|
||||
cinfo.err = jpeg_std_error (&jerr.pub);
|
||||
jerr.pub.error_exit = my_error_exit;
|
||||
|
@ -778,46 +778,47 @@ load_image (gchar *filename,
|
|||
*/
|
||||
|
||||
#ifdef GIMP_HAVE_PARASITES
|
||||
if (!preview) {
|
||||
/* if we had any comments then make a parasite for them */
|
||||
if (local_image_comments && local_image_comments->len)
|
||||
{
|
||||
gchar *string = local_image_comments->str;
|
||||
g_string_free (local_image_comments, FALSE);
|
||||
local_image_comments = NULL;
|
||||
comment_parasite = gimp_parasite_new ("gimp-comment",
|
||||
GIMP_PARASITE_PERSISTENT,
|
||||
strlen (string) + 1, string);
|
||||
}
|
||||
else
|
||||
{
|
||||
comment_parasite = NULL;
|
||||
}
|
||||
|
||||
/* pw - figuring out what the saved values were is non-trivial.
|
||||
* They don't seem to be in the cinfo structure. For now, I will
|
||||
* just use the defaults, but if someone figures out how to derive
|
||||
* them this is the place to store them. */
|
||||
|
||||
local_save_vals.quality = DEFAULT_QUALITY;
|
||||
local_save_vals.smoothing = DEFAULT_SMOOTHING;
|
||||
local_save_vals.optimize = DEFAULT_OPTIMIZE;
|
||||
|
||||
if (!preview)
|
||||
{
|
||||
/* if we had any comments then make a parasite for them */
|
||||
if (local_image_comments && local_image_comments->len)
|
||||
{
|
||||
gchar *string = local_image_comments->str;
|
||||
g_string_free (local_image_comments, FALSE);
|
||||
local_image_comments = NULL;
|
||||
comment_parasite = gimp_parasite_new ("gimp-comment",
|
||||
GIMP_PARASITE_PERSISTENT,
|
||||
strlen (string) + 1, string);
|
||||
}
|
||||
else
|
||||
{
|
||||
comment_parasite = NULL;
|
||||
}
|
||||
|
||||
/* pw - figuring out what the saved values were is non-trivial.
|
||||
* They don't seem to be in the cinfo structure. For now, I will
|
||||
* just use the defaults, but if someone figures out how to derive
|
||||
* them this is the place to store them. */
|
||||
|
||||
local_save_vals.quality = DEFAULT_QUALITY;
|
||||
local_save_vals.smoothing = DEFAULT_SMOOTHING;
|
||||
local_save_vals.optimize = DEFAULT_OPTIMIZE;
|
||||
|
||||
#ifdef HAVE_PROGRESSIVE_JPEG
|
||||
local_save_vals.progressive = cinfo.progressive_mode;
|
||||
local_save_vals.progressive = cinfo.progressive_mode;
|
||||
#else
|
||||
local_save_vals.progressive = 0;
|
||||
local_save_vals.progressive = 0;
|
||||
#endif /* HAVE_PROGRESSIVE_JPEG */
|
||||
local_save_vals.baseline = DEFAULT_BASELINE;
|
||||
local_save_vals.subsmp = DEFAULT_SUBSMP; /* sg - this _is_ there, but I'm too lazy */
|
||||
local_save_vals.restart = DEFAULT_RESTART;
|
||||
local_save_vals.dct = DEFAULT_DCT;
|
||||
local_save_vals.preview = DEFAULT_PREVIEW;
|
||||
|
||||
vals_parasite = gimp_parasite_new ("jpeg-save-options", 0,
|
||||
sizeof (local_save_vals),
|
||||
&local_save_vals);
|
||||
}
|
||||
local_save_vals.baseline = DEFAULT_BASELINE;
|
||||
local_save_vals.subsmp = DEFAULT_SUBSMP; /* sg - this _is_ there, but I'm too lazy */
|
||||
local_save_vals.restart = DEFAULT_RESTART;
|
||||
local_save_vals.dct = DEFAULT_DCT;
|
||||
local_save_vals.preview = DEFAULT_PREVIEW;
|
||||
|
||||
vals_parasite = gimp_parasite_new ("jpeg-save-options", 0,
|
||||
sizeof (local_save_vals),
|
||||
&local_save_vals);
|
||||
}
|
||||
#endif /* GIMP_HAVE_PARASITES */
|
||||
|
||||
|
||||
|
@ -862,14 +863,17 @@ load_image (gchar *filename,
|
|||
image_type = GIMP_GRAY;
|
||||
layer_type = preview ? GIMP_GRAYA_IMAGE : GIMP_GRAY_IMAGE;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
image_type = GIMP_RGB;
|
||||
layer_type = preview ? GIMP_RGBA_IMAGE : GIMP_RGB_IMAGE;
|
||||
break;
|
||||
|
||||
default:
|
||||
g_message ("don't know how to load JPEGs\nwith %d color channels",
|
||||
cinfo.output_components);
|
||||
cinfo.output_components);
|
||||
gimp_quit ();
|
||||
break;
|
||||
}
|
||||
|
||||
if (preview)
|
||||
|
@ -885,10 +889,11 @@ load_image (gchar *filename,
|
|||
|
||||
if (preview)
|
||||
{
|
||||
layer_ID_global = layer_ID = gimp_layer_new (image_ID, _("JPEG preview"),
|
||||
cinfo.output_width,
|
||||
cinfo.output_height,
|
||||
layer_type, 100, GIMP_NORMAL_MODE);
|
||||
layer_ID_global = layer_ID =
|
||||
gimp_layer_new (image_ID, _("JPEG preview"),
|
||||
cinfo.output_width,
|
||||
cinfo.output_height,
|
||||
layer_type, 100, GIMP_NORMAL_MODE);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -951,23 +956,18 @@ load_image (gchar *filename,
|
|||
while (cinfo.output_scanline < cinfo.output_height)
|
||||
{
|
||||
start = cinfo.output_scanline;
|
||||
end = cinfo.output_scanline + tile_height;
|
||||
end = MIN (end, cinfo.output_height);
|
||||
end = cinfo.output_scanline + tile_height;
|
||||
end = MIN (end, cinfo.output_height);
|
||||
scanlines = end - start;
|
||||
|
||||
for (i = 0; i < scanlines; i++)
|
||||
jpeg_read_scanlines (&cinfo, (JSAMPARRAY) &rowbuf[i], 1);
|
||||
|
||||
/*
|
||||
for (i = start; i < end; i++)
|
||||
gimp_pixel_rgn_set_row (&pixel_rgn, tilerow[i - start], 0, i, drawable->width);
|
||||
*/
|
||||
|
||||
if (preview) /* Add a dummy alpha channel -- convert buf to padded_buf */
|
||||
{
|
||||
guchar *dest = padded_buf;
|
||||
guchar *src = buf;
|
||||
gint num = drawable->width * scanlines;
|
||||
gint num = drawable->width * scanlines;
|
||||
|
||||
switch (cinfo.output_components)
|
||||
{
|
||||
|
@ -978,6 +978,7 @@ load_image (gchar *filename,
|
|||
*(dest++) = 255;
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
for (i=0; i<num; i++)
|
||||
{
|
||||
|
@ -987,8 +988,10 @@ load_image (gchar *filename,
|
|||
*(dest++) = 255;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
g_warning ("JPEG - shouldn't have gotten here. Report to adam@gimp.org");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -997,7 +1000,8 @@ load_image (gchar *filename,
|
|||
|
||||
if (runmode != GIMP_RUN_NONINTERACTIVE)
|
||||
{
|
||||
gimp_progress_update ((double) cinfo.output_scanline / (double) cinfo.output_height);
|
||||
gimp_progress_update ((gdouble) cinfo.output_scanline /
|
||||
(gdouble) cinfo.output_height);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1046,6 +1050,7 @@ load_image (gchar *filename,
|
|||
gimp_image_parasite_attach (image_ID, comment_parasite);
|
||||
gimp_parasite_free (comment_parasite);
|
||||
}
|
||||
|
||||
if (vals_parasite)
|
||||
{
|
||||
gimp_image_parasite_attach (image_ID, vals_parasite);
|
||||
|
@ -1070,19 +1075,16 @@ background_error_exit (j_common_ptr cinfo)
|
|||
(*cinfo->err->output_message) (cinfo);
|
||||
}
|
||||
|
||||
static gint
|
||||
static gboolean
|
||||
background_jpeg_save (PreviewPersistent *pp)
|
||||
{
|
||||
guchar *t;
|
||||
guchar *s;
|
||||
gint i, j;
|
||||
gint yend;
|
||||
gint i, j;
|
||||
gint yend;
|
||||
|
||||
if (pp->abort_me || (pp->cinfo.next_scanline >= pp->cinfo.image_height))
|
||||
{
|
||||
struct stat buf;
|
||||
gchar temp[256];
|
||||
|
||||
/* clean up... */
|
||||
if (pp->abort_me)
|
||||
{
|
||||
|
@ -1099,11 +1101,15 @@ background_jpeg_save (PreviewPersistent *pp)
|
|||
g_free (pp->temp);
|
||||
g_free (pp->data);
|
||||
|
||||
if (pp->drawable) gimp_drawable_detach (pp->drawable);
|
||||
if (pp->drawable)
|
||||
gimp_drawable_detach (pp->drawable);
|
||||
|
||||
/* display the preview stuff */
|
||||
if (!pp->abort_me)
|
||||
{
|
||||
struct stat buf;
|
||||
gchar temp[128];
|
||||
|
||||
stat (pp->file_name, &buf);
|
||||
g_snprintf (temp, sizeof (temp),
|
||||
_("Size: %lu bytes (%02.01f kB)"),
|
||||
|
@ -1160,26 +1166,26 @@ background_jpeg_save (PreviewPersistent *pp)
|
|||
}
|
||||
}
|
||||
|
||||
static gint
|
||||
static gboolean
|
||||
save_image (gchar *filename,
|
||||
gint32 image_ID,
|
||||
gint32 drawable_ID,
|
||||
gint32 orig_image_ID,
|
||||
gboolean preview)
|
||||
{
|
||||
GimpPixelRgn pixel_rgn;
|
||||
GimpDrawable *drawable;
|
||||
GimpImageType drawable_type;
|
||||
GimpPixelRgn pixel_rgn;
|
||||
GimpDrawable *drawable;
|
||||
GimpImageType drawable_type;
|
||||
struct jpeg_compress_struct cinfo;
|
||||
struct my_error_mgr jerr;
|
||||
FILE * volatile outfile;
|
||||
guchar *temp, *t;
|
||||
guchar *data;
|
||||
guchar *src, *s;
|
||||
gchar *name;
|
||||
gint has_alpha;
|
||||
gint rowstride, yend;
|
||||
gint i, j;
|
||||
struct my_error_mgr jerr;
|
||||
FILE * volatile outfile;
|
||||
guchar *temp, *t;
|
||||
guchar *data;
|
||||
guchar *src, *s;
|
||||
gchar *name;
|
||||
gboolean has_alpha;
|
||||
gint rowstride, yend;
|
||||
gint i, j;
|
||||
|
||||
drawable = gimp_drawable_get (drawable_ID);
|
||||
drawable_type = gimp_drawable_type (drawable_ID);
|
||||
|
@ -1245,19 +1251,22 @@ save_image (gchar *filename,
|
|||
case GIMP_GRAY_IMAGE:
|
||||
/* # of color components per pixel */
|
||||
cinfo.input_components = drawable->bpp;
|
||||
has_alpha = 0;
|
||||
has_alpha = FALSE;
|
||||
break;
|
||||
|
||||
case GIMP_RGBA_IMAGE:
|
||||
case GIMP_GRAYA_IMAGE:
|
||||
/*gimp_message ("jpeg: image contains a-channel info which will be lost");*/
|
||||
/* # of color components per pixel (minus the GIMP alpha channel) */
|
||||
cinfo.input_components = drawable->bpp - 1;
|
||||
has_alpha = 1;
|
||||
has_alpha = TRUE;
|
||||
break;
|
||||
|
||||
case GIMP_INDEXED_IMAGE:
|
||||
/*gimp_message ("jpeg: cannot operate on indexed color images");*/
|
||||
return FALSE;
|
||||
break;
|
||||
|
||||
default:
|
||||
/*gimp_message ("jpeg: cannot operate on unknown image types");*/
|
||||
return FALSE;
|
||||
|
@ -1282,8 +1291,8 @@ save_image (gchar *filename,
|
|||
*/
|
||||
jpeg_set_defaults (&cinfo);
|
||||
|
||||
jpeg_set_quality (&cinfo, (int) (jsvals.quality * 100), jsvals.baseline);
|
||||
cinfo.smoothing_factor = (int) (jsvals.smoothing * 100);
|
||||
jpeg_set_quality (&cinfo, (gint) (jsvals.quality * 100), jsvals.baseline);
|
||||
cinfo.smoothing_factor = (gint) (jsvals.smoothing * 100);
|
||||
cinfo.optimize_coding = jsvals.optimize;
|
||||
|
||||
#ifdef HAVE_PROGRESSIVE_JPEG
|
||||
|
@ -1304,6 +1313,7 @@ save_image (gchar *filename,
|
|||
cinfo.comp_info[2].h_samp_factor = 1;
|
||||
cinfo.comp_info[2].v_samp_factor = 1;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
cinfo.comp_info[0].h_samp_factor = 2;
|
||||
cinfo.comp_info[0].v_samp_factor = 1;
|
||||
|
@ -1312,6 +1322,7 @@ save_image (gchar *filename,
|
|||
cinfo.comp_info[2].h_samp_factor = 1;
|
||||
cinfo.comp_info[2].v_samp_factor = 1;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
cinfo.comp_info[0].h_samp_factor = 1;
|
||||
cinfo.comp_info[0].v_samp_factor = 1;
|
||||
|
@ -1331,9 +1342,11 @@ save_image (gchar *filename,
|
|||
default:
|
||||
cinfo.dct_method = JDCT_ISLOW;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
cinfo.dct_method = JDCT_IFAST;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
cinfo.dct_method = JDCT_FLOAT;
|
||||
break;
|
||||
|
@ -1432,7 +1445,7 @@ save_image (gchar *filename,
|
|||
|
||||
jerr.pub.error_exit = background_error_exit;
|
||||
|
||||
gtk_idle_add ((GtkFunction) background_jpeg_save, (gpointer *)pp);
|
||||
gtk_idle_add ((GtkFunction) background_jpeg_save, (gpointer) pp);
|
||||
|
||||
/* background_jpeg_save() will cleanup as needed */
|
||||
return TRUE;
|
||||
|
@ -1525,21 +1538,25 @@ destroy_preview (void)
|
|||
{
|
||||
*abort_me = TRUE; /* signal the background save to stop */
|
||||
}
|
||||
|
||||
if (drawable_global)
|
||||
{
|
||||
gimp_drawable_detach (drawable_global);
|
||||
drawable_global = NULL;
|
||||
}
|
||||
|
||||
if (layer_ID_global != -1 && image_ID_global != -1)
|
||||
{
|
||||
/* assuming that reference counting is working correctly,
|
||||
we do not need to delete the layer, removing it from
|
||||
the image should be sufficient */
|
||||
gimp_image_remove_layer (image_ID_global, layer_ID_global);
|
||||
|
||||
/* gimp_layer_delete(layer_ID_global); */
|
||||
layer_ID_global = -1;
|
||||
}
|
||||
}
|
||||
|
||||
static gint
|
||||
static gboolean
|
||||
save_dialog (void)
|
||||
{
|
||||
GtkWidget *dlg;
|
||||
|
@ -1858,6 +1875,7 @@ save_ok_callback (GtkWidget *widget,
|
|||
gpointer data)
|
||||
{
|
||||
GtkWidget *text;
|
||||
|
||||
jsint.run = TRUE;
|
||||
|
||||
/* pw - get the comment text object and grab it's data */
|
||||
|
@ -1898,7 +1916,7 @@ save_restart_update (GtkAdjustment *adjustment,
|
|||
|
||||
static void
|
||||
menu_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
gpointer data)
|
||||
{
|
||||
gimp_menu_item_update (widget, data);
|
||||
make_preview ();
|
||||
|
|
|
@ -194,7 +194,7 @@ typedef struct
|
|||
struct jpeg_compress_struct cinfo;
|
||||
gint tile_height;
|
||||
FILE *outfile;
|
||||
gint has_alpha;
|
||||
gboolean has_alpha;
|
||||
gint rowstride;
|
||||
guchar *temp;
|
||||
guchar *data;
|
||||
|
@ -210,37 +210,37 @@ static gboolean *abort_me = NULL;
|
|||
|
||||
/* Declare local functions.
|
||||
*/
|
||||
static void query (void);
|
||||
static void run (gchar *name,
|
||||
gint nparams,
|
||||
GimpParam *param,
|
||||
gint *nreturn_vals,
|
||||
GimpParam **return_vals);
|
||||
static gint32 load_image (gchar *filename,
|
||||
GimpRunModeType runmode,
|
||||
gboolean preview);
|
||||
static gint save_image (gchar *filename,
|
||||
gint32 image_ID,
|
||||
gint32 drawable_ID,
|
||||
gint32 orig_image_ID,
|
||||
gboolean preview);
|
||||
static void query (void);
|
||||
static void run (gchar *name,
|
||||
gint nparams,
|
||||
GimpParam *param,
|
||||
gint *nreturn_vals,
|
||||
GimpParam **return_vals);
|
||||
static gint32 load_image (gchar *filename,
|
||||
GimpRunModeType runmode,
|
||||
gboolean preview);
|
||||
static gboolean save_image (gchar *filename,
|
||||
gint32 image_ID,
|
||||
gint32 drawable_ID,
|
||||
gint32 orig_image_ID,
|
||||
gboolean preview);
|
||||
|
||||
static gint save_dialog (void);
|
||||
static gboolean save_dialog (void);
|
||||
|
||||
static void save_close_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void save_ok_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void save_restart_toggle_update (GtkWidget *toggle,
|
||||
GtkAdjustment *adjustment);
|
||||
static void save_restart_update (GtkAdjustment *adjustment,
|
||||
GtkWidget *toggle);
|
||||
static void save_close_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void save_ok_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void save_restart_toggle_update (GtkWidget *toggle,
|
||||
GtkAdjustment *adjustment);
|
||||
static void save_restart_update (GtkAdjustment *adjustment,
|
||||
GtkWidget *toggle);
|
||||
|
||||
static void make_preview (void);
|
||||
static void destroy_preview (void);
|
||||
static void make_preview (void);
|
||||
static void destroy_preview (void);
|
||||
|
||||
static void menu_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void menu_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
|
||||
|
||||
GimpPlugInInfo PLUG_IN_INFO =
|
||||
|
@ -347,24 +347,24 @@ query (void)
|
|||
}
|
||||
|
||||
static void
|
||||
run (gchar *name,
|
||||
gint nparams,
|
||||
run (gchar *name,
|
||||
gint nparams,
|
||||
GimpParam *param,
|
||||
gint *nreturn_vals,
|
||||
gint *nreturn_vals,
|
||||
GimpParam **return_vals)
|
||||
{
|
||||
static GimpParam values[2];
|
||||
GimpRunModeType run_mode;
|
||||
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
||||
gint32 image_ID;
|
||||
gint32 drawable_ID;
|
||||
gint32 orig_image_ID;
|
||||
gint32 display_ID = -1;
|
||||
static GimpParam values[2];
|
||||
GimpRunModeType run_mode;
|
||||
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
||||
gint32 image_ID;
|
||||
gint32 drawable_ID;
|
||||
gint32 orig_image_ID;
|
||||
gint32 display_ID = -1;
|
||||
#ifdef GIMP_HAVE_PARASITES
|
||||
GimpParasite *parasite;
|
||||
GimpParasite *parasite;
|
||||
#endif /* GIMP_HAVE_PARASITES */
|
||||
gint err;
|
||||
GimpExportReturnType export = GIMP_EXPORT_CANCEL;
|
||||
gboolean err;
|
||||
GimpExportReturnType export = GIMP_EXPORT_CANCEL;
|
||||
|
||||
run_mode = param[0].data.d_int32;
|
||||
|
||||
|
@ -622,7 +622,7 @@ run (gchar *name,
|
|||
static guint
|
||||
jpeg_getc (j_decompress_ptr cinfo)
|
||||
{
|
||||
struct jpeg_source_mgr * datasrc = cinfo->src;
|
||||
struct jpeg_source_mgr *datasrc = cinfo->src;
|
||||
|
||||
if (datasrc->bytes_in_buffer == 0)
|
||||
{
|
||||
|
@ -630,6 +630,7 @@ jpeg_getc (j_decompress_ptr cinfo)
|
|||
ERREXIT (cinfo, JERR_CANT_SUSPEND);
|
||||
}
|
||||
datasrc->bytes_in_buffer--;
|
||||
|
||||
return *datasrc->next_input_byte++;
|
||||
}
|
||||
|
||||
|
@ -647,8 +648,8 @@ static GString *local_image_comments = NULL;
|
|||
static boolean
|
||||
COM_handler (j_decompress_ptr cinfo)
|
||||
{
|
||||
int length;
|
||||
unsigned int ch;
|
||||
gint length;
|
||||
guint ch;
|
||||
|
||||
length = jpeg_getc (cinfo) << 8;
|
||||
length += jpeg_getc (cinfo);
|
||||
|
@ -700,22 +701,22 @@ load_image (gchar *filename,
|
|||
GimpRunModeType runmode,
|
||||
gboolean preview)
|
||||
{
|
||||
GimpPixelRgn pixel_rgn;
|
||||
GimpDrawable *drawable;
|
||||
gint32 volatile image_ID;
|
||||
gint32 layer_ID;
|
||||
GimpPixelRgn pixel_rgn;
|
||||
GimpDrawable *drawable;
|
||||
gint32 volatile image_ID;
|
||||
gint32 layer_ID;
|
||||
struct jpeg_decompress_struct cinfo;
|
||||
struct my_error_mgr jerr;
|
||||
FILE *infile;
|
||||
guchar *buf;
|
||||
guchar * volatile padded_buf = NULL;
|
||||
struct my_error_mgr jerr;
|
||||
FILE *infile;
|
||||
guchar *buf;
|
||||
guchar * volatile padded_buf = NULL;
|
||||
guchar **rowbuf;
|
||||
gchar *name;
|
||||
gint image_type;
|
||||
gint layer_type;
|
||||
gint tile_height;
|
||||
gint scanlines;
|
||||
gint i, start, end;
|
||||
gchar *name;
|
||||
gint image_type;
|
||||
gint layer_type;
|
||||
gint tile_height;
|
||||
gint scanlines;
|
||||
gint i, start, end;
|
||||
|
||||
#ifdef GIMP_HAVE_PARASITES
|
||||
JpegSaveVals local_save_vals;
|
||||
|
@ -723,7 +724,6 @@ load_image (gchar *filename,
|
|||
GimpParasite * volatile vals_parasite = NULL;
|
||||
#endif /* GIMP_HAVE_PARASITES */
|
||||
|
||||
|
||||
/* We set up the normal JPEG error routines. */
|
||||
cinfo.err = jpeg_std_error (&jerr.pub);
|
||||
jerr.pub.error_exit = my_error_exit;
|
||||
|
@ -778,46 +778,47 @@ load_image (gchar *filename,
|
|||
*/
|
||||
|
||||
#ifdef GIMP_HAVE_PARASITES
|
||||
if (!preview) {
|
||||
/* if we had any comments then make a parasite for them */
|
||||
if (local_image_comments && local_image_comments->len)
|
||||
{
|
||||
gchar *string = local_image_comments->str;
|
||||
g_string_free (local_image_comments, FALSE);
|
||||
local_image_comments = NULL;
|
||||
comment_parasite = gimp_parasite_new ("gimp-comment",
|
||||
GIMP_PARASITE_PERSISTENT,
|
||||
strlen (string) + 1, string);
|
||||
}
|
||||
else
|
||||
{
|
||||
comment_parasite = NULL;
|
||||
}
|
||||
|
||||
/* pw - figuring out what the saved values were is non-trivial.
|
||||
* They don't seem to be in the cinfo structure. For now, I will
|
||||
* just use the defaults, but if someone figures out how to derive
|
||||
* them this is the place to store them. */
|
||||
|
||||
local_save_vals.quality = DEFAULT_QUALITY;
|
||||
local_save_vals.smoothing = DEFAULT_SMOOTHING;
|
||||
local_save_vals.optimize = DEFAULT_OPTIMIZE;
|
||||
|
||||
if (!preview)
|
||||
{
|
||||
/* if we had any comments then make a parasite for them */
|
||||
if (local_image_comments && local_image_comments->len)
|
||||
{
|
||||
gchar *string = local_image_comments->str;
|
||||
g_string_free (local_image_comments, FALSE);
|
||||
local_image_comments = NULL;
|
||||
comment_parasite = gimp_parasite_new ("gimp-comment",
|
||||
GIMP_PARASITE_PERSISTENT,
|
||||
strlen (string) + 1, string);
|
||||
}
|
||||
else
|
||||
{
|
||||
comment_parasite = NULL;
|
||||
}
|
||||
|
||||
/* pw - figuring out what the saved values were is non-trivial.
|
||||
* They don't seem to be in the cinfo structure. For now, I will
|
||||
* just use the defaults, but if someone figures out how to derive
|
||||
* them this is the place to store them. */
|
||||
|
||||
local_save_vals.quality = DEFAULT_QUALITY;
|
||||
local_save_vals.smoothing = DEFAULT_SMOOTHING;
|
||||
local_save_vals.optimize = DEFAULT_OPTIMIZE;
|
||||
|
||||
#ifdef HAVE_PROGRESSIVE_JPEG
|
||||
local_save_vals.progressive = cinfo.progressive_mode;
|
||||
local_save_vals.progressive = cinfo.progressive_mode;
|
||||
#else
|
||||
local_save_vals.progressive = 0;
|
||||
local_save_vals.progressive = 0;
|
||||
#endif /* HAVE_PROGRESSIVE_JPEG */
|
||||
local_save_vals.baseline = DEFAULT_BASELINE;
|
||||
local_save_vals.subsmp = DEFAULT_SUBSMP; /* sg - this _is_ there, but I'm too lazy */
|
||||
local_save_vals.restart = DEFAULT_RESTART;
|
||||
local_save_vals.dct = DEFAULT_DCT;
|
||||
local_save_vals.preview = DEFAULT_PREVIEW;
|
||||
|
||||
vals_parasite = gimp_parasite_new ("jpeg-save-options", 0,
|
||||
sizeof (local_save_vals),
|
||||
&local_save_vals);
|
||||
}
|
||||
local_save_vals.baseline = DEFAULT_BASELINE;
|
||||
local_save_vals.subsmp = DEFAULT_SUBSMP; /* sg - this _is_ there, but I'm too lazy */
|
||||
local_save_vals.restart = DEFAULT_RESTART;
|
||||
local_save_vals.dct = DEFAULT_DCT;
|
||||
local_save_vals.preview = DEFAULT_PREVIEW;
|
||||
|
||||
vals_parasite = gimp_parasite_new ("jpeg-save-options", 0,
|
||||
sizeof (local_save_vals),
|
||||
&local_save_vals);
|
||||
}
|
||||
#endif /* GIMP_HAVE_PARASITES */
|
||||
|
||||
|
||||
|
@ -862,14 +863,17 @@ load_image (gchar *filename,
|
|||
image_type = GIMP_GRAY;
|
||||
layer_type = preview ? GIMP_GRAYA_IMAGE : GIMP_GRAY_IMAGE;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
image_type = GIMP_RGB;
|
||||
layer_type = preview ? GIMP_RGBA_IMAGE : GIMP_RGB_IMAGE;
|
||||
break;
|
||||
|
||||
default:
|
||||
g_message ("don't know how to load JPEGs\nwith %d color channels",
|
||||
cinfo.output_components);
|
||||
cinfo.output_components);
|
||||
gimp_quit ();
|
||||
break;
|
||||
}
|
||||
|
||||
if (preview)
|
||||
|
@ -885,10 +889,11 @@ load_image (gchar *filename,
|
|||
|
||||
if (preview)
|
||||
{
|
||||
layer_ID_global = layer_ID = gimp_layer_new (image_ID, _("JPEG preview"),
|
||||
cinfo.output_width,
|
||||
cinfo.output_height,
|
||||
layer_type, 100, GIMP_NORMAL_MODE);
|
||||
layer_ID_global = layer_ID =
|
||||
gimp_layer_new (image_ID, _("JPEG preview"),
|
||||
cinfo.output_width,
|
||||
cinfo.output_height,
|
||||
layer_type, 100, GIMP_NORMAL_MODE);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -951,23 +956,18 @@ load_image (gchar *filename,
|
|||
while (cinfo.output_scanline < cinfo.output_height)
|
||||
{
|
||||
start = cinfo.output_scanline;
|
||||
end = cinfo.output_scanline + tile_height;
|
||||
end = MIN (end, cinfo.output_height);
|
||||
end = cinfo.output_scanline + tile_height;
|
||||
end = MIN (end, cinfo.output_height);
|
||||
scanlines = end - start;
|
||||
|
||||
for (i = 0; i < scanlines; i++)
|
||||
jpeg_read_scanlines (&cinfo, (JSAMPARRAY) &rowbuf[i], 1);
|
||||
|
||||
/*
|
||||
for (i = start; i < end; i++)
|
||||
gimp_pixel_rgn_set_row (&pixel_rgn, tilerow[i - start], 0, i, drawable->width);
|
||||
*/
|
||||
|
||||
if (preview) /* Add a dummy alpha channel -- convert buf to padded_buf */
|
||||
{
|
||||
guchar *dest = padded_buf;
|
||||
guchar *src = buf;
|
||||
gint num = drawable->width * scanlines;
|
||||
gint num = drawable->width * scanlines;
|
||||
|
||||
switch (cinfo.output_components)
|
||||
{
|
||||
|
@ -978,6 +978,7 @@ load_image (gchar *filename,
|
|||
*(dest++) = 255;
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
for (i=0; i<num; i++)
|
||||
{
|
||||
|
@ -987,8 +988,10 @@ load_image (gchar *filename,
|
|||
*(dest++) = 255;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
g_warning ("JPEG - shouldn't have gotten here. Report to adam@gimp.org");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -997,7 +1000,8 @@ load_image (gchar *filename,
|
|||
|
||||
if (runmode != GIMP_RUN_NONINTERACTIVE)
|
||||
{
|
||||
gimp_progress_update ((double) cinfo.output_scanline / (double) cinfo.output_height);
|
||||
gimp_progress_update ((gdouble) cinfo.output_scanline /
|
||||
(gdouble) cinfo.output_height);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1046,6 +1050,7 @@ load_image (gchar *filename,
|
|||
gimp_image_parasite_attach (image_ID, comment_parasite);
|
||||
gimp_parasite_free (comment_parasite);
|
||||
}
|
||||
|
||||
if (vals_parasite)
|
||||
{
|
||||
gimp_image_parasite_attach (image_ID, vals_parasite);
|
||||
|
@ -1070,19 +1075,16 @@ background_error_exit (j_common_ptr cinfo)
|
|||
(*cinfo->err->output_message) (cinfo);
|
||||
}
|
||||
|
||||
static gint
|
||||
static gboolean
|
||||
background_jpeg_save (PreviewPersistent *pp)
|
||||
{
|
||||
guchar *t;
|
||||
guchar *s;
|
||||
gint i, j;
|
||||
gint yend;
|
||||
gint i, j;
|
||||
gint yend;
|
||||
|
||||
if (pp->abort_me || (pp->cinfo.next_scanline >= pp->cinfo.image_height))
|
||||
{
|
||||
struct stat buf;
|
||||
gchar temp[256];
|
||||
|
||||
/* clean up... */
|
||||
if (pp->abort_me)
|
||||
{
|
||||
|
@ -1099,11 +1101,15 @@ background_jpeg_save (PreviewPersistent *pp)
|
|||
g_free (pp->temp);
|
||||
g_free (pp->data);
|
||||
|
||||
if (pp->drawable) gimp_drawable_detach (pp->drawable);
|
||||
if (pp->drawable)
|
||||
gimp_drawable_detach (pp->drawable);
|
||||
|
||||
/* display the preview stuff */
|
||||
if (!pp->abort_me)
|
||||
{
|
||||
struct stat buf;
|
||||
gchar temp[128];
|
||||
|
||||
stat (pp->file_name, &buf);
|
||||
g_snprintf (temp, sizeof (temp),
|
||||
_("Size: %lu bytes (%02.01f kB)"),
|
||||
|
@ -1160,26 +1166,26 @@ background_jpeg_save (PreviewPersistent *pp)
|
|||
}
|
||||
}
|
||||
|
||||
static gint
|
||||
static gboolean
|
||||
save_image (gchar *filename,
|
||||
gint32 image_ID,
|
||||
gint32 drawable_ID,
|
||||
gint32 orig_image_ID,
|
||||
gboolean preview)
|
||||
{
|
||||
GimpPixelRgn pixel_rgn;
|
||||
GimpDrawable *drawable;
|
||||
GimpImageType drawable_type;
|
||||
GimpPixelRgn pixel_rgn;
|
||||
GimpDrawable *drawable;
|
||||
GimpImageType drawable_type;
|
||||
struct jpeg_compress_struct cinfo;
|
||||
struct my_error_mgr jerr;
|
||||
FILE * volatile outfile;
|
||||
guchar *temp, *t;
|
||||
guchar *data;
|
||||
guchar *src, *s;
|
||||
gchar *name;
|
||||
gint has_alpha;
|
||||
gint rowstride, yend;
|
||||
gint i, j;
|
||||
struct my_error_mgr jerr;
|
||||
FILE * volatile outfile;
|
||||
guchar *temp, *t;
|
||||
guchar *data;
|
||||
guchar *src, *s;
|
||||
gchar *name;
|
||||
gboolean has_alpha;
|
||||
gint rowstride, yend;
|
||||
gint i, j;
|
||||
|
||||
drawable = gimp_drawable_get (drawable_ID);
|
||||
drawable_type = gimp_drawable_type (drawable_ID);
|
||||
|
@ -1245,19 +1251,22 @@ save_image (gchar *filename,
|
|||
case GIMP_GRAY_IMAGE:
|
||||
/* # of color components per pixel */
|
||||
cinfo.input_components = drawable->bpp;
|
||||
has_alpha = 0;
|
||||
has_alpha = FALSE;
|
||||
break;
|
||||
|
||||
case GIMP_RGBA_IMAGE:
|
||||
case GIMP_GRAYA_IMAGE:
|
||||
/*gimp_message ("jpeg: image contains a-channel info which will be lost");*/
|
||||
/* # of color components per pixel (minus the GIMP alpha channel) */
|
||||
cinfo.input_components = drawable->bpp - 1;
|
||||
has_alpha = 1;
|
||||
has_alpha = TRUE;
|
||||
break;
|
||||
|
||||
case GIMP_INDEXED_IMAGE:
|
||||
/*gimp_message ("jpeg: cannot operate on indexed color images");*/
|
||||
return FALSE;
|
||||
break;
|
||||
|
||||
default:
|
||||
/*gimp_message ("jpeg: cannot operate on unknown image types");*/
|
||||
return FALSE;
|
||||
|
@ -1282,8 +1291,8 @@ save_image (gchar *filename,
|
|||
*/
|
||||
jpeg_set_defaults (&cinfo);
|
||||
|
||||
jpeg_set_quality (&cinfo, (int) (jsvals.quality * 100), jsvals.baseline);
|
||||
cinfo.smoothing_factor = (int) (jsvals.smoothing * 100);
|
||||
jpeg_set_quality (&cinfo, (gint) (jsvals.quality * 100), jsvals.baseline);
|
||||
cinfo.smoothing_factor = (gint) (jsvals.smoothing * 100);
|
||||
cinfo.optimize_coding = jsvals.optimize;
|
||||
|
||||
#ifdef HAVE_PROGRESSIVE_JPEG
|
||||
|
@ -1304,6 +1313,7 @@ save_image (gchar *filename,
|
|||
cinfo.comp_info[2].h_samp_factor = 1;
|
||||
cinfo.comp_info[2].v_samp_factor = 1;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
cinfo.comp_info[0].h_samp_factor = 2;
|
||||
cinfo.comp_info[0].v_samp_factor = 1;
|
||||
|
@ -1312,6 +1322,7 @@ save_image (gchar *filename,
|
|||
cinfo.comp_info[2].h_samp_factor = 1;
|
||||
cinfo.comp_info[2].v_samp_factor = 1;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
cinfo.comp_info[0].h_samp_factor = 1;
|
||||
cinfo.comp_info[0].v_samp_factor = 1;
|
||||
|
@ -1331,9 +1342,11 @@ save_image (gchar *filename,
|
|||
default:
|
||||
cinfo.dct_method = JDCT_ISLOW;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
cinfo.dct_method = JDCT_IFAST;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
cinfo.dct_method = JDCT_FLOAT;
|
||||
break;
|
||||
|
@ -1432,7 +1445,7 @@ save_image (gchar *filename,
|
|||
|
||||
jerr.pub.error_exit = background_error_exit;
|
||||
|
||||
gtk_idle_add ((GtkFunction) background_jpeg_save, (gpointer *)pp);
|
||||
gtk_idle_add ((GtkFunction) background_jpeg_save, (gpointer) pp);
|
||||
|
||||
/* background_jpeg_save() will cleanup as needed */
|
||||
return TRUE;
|
||||
|
@ -1525,21 +1538,25 @@ destroy_preview (void)
|
|||
{
|
||||
*abort_me = TRUE; /* signal the background save to stop */
|
||||
}
|
||||
|
||||
if (drawable_global)
|
||||
{
|
||||
gimp_drawable_detach (drawable_global);
|
||||
drawable_global = NULL;
|
||||
}
|
||||
|
||||
if (layer_ID_global != -1 && image_ID_global != -1)
|
||||
{
|
||||
/* assuming that reference counting is working correctly,
|
||||
we do not need to delete the layer, removing it from
|
||||
the image should be sufficient */
|
||||
gimp_image_remove_layer (image_ID_global, layer_ID_global);
|
||||
|
||||
/* gimp_layer_delete(layer_ID_global); */
|
||||
layer_ID_global = -1;
|
||||
}
|
||||
}
|
||||
|
||||
static gint
|
||||
static gboolean
|
||||
save_dialog (void)
|
||||
{
|
||||
GtkWidget *dlg;
|
||||
|
@ -1858,6 +1875,7 @@ save_ok_callback (GtkWidget *widget,
|
|||
gpointer data)
|
||||
{
|
||||
GtkWidget *text;
|
||||
|
||||
jsint.run = TRUE;
|
||||
|
||||
/* pw - get the comment text object and grab it's data */
|
||||
|
@ -1898,7 +1916,7 @@ save_restart_update (GtkAdjustment *adjustment,
|
|||
|
||||
static void
|
||||
menu_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
gpointer data)
|
||||
{
|
||||
gimp_menu_item_update (widget, data);
|
||||
make_preview ();
|
||||
|
|
|
@ -194,7 +194,7 @@ typedef struct
|
|||
struct jpeg_compress_struct cinfo;
|
||||
gint tile_height;
|
||||
FILE *outfile;
|
||||
gint has_alpha;
|
||||
gboolean has_alpha;
|
||||
gint rowstride;
|
||||
guchar *temp;
|
||||
guchar *data;
|
||||
|
@ -210,37 +210,37 @@ static gboolean *abort_me = NULL;
|
|||
|
||||
/* Declare local functions.
|
||||
*/
|
||||
static void query (void);
|
||||
static void run (gchar *name,
|
||||
gint nparams,
|
||||
GimpParam *param,
|
||||
gint *nreturn_vals,
|
||||
GimpParam **return_vals);
|
||||
static gint32 load_image (gchar *filename,
|
||||
GimpRunModeType runmode,
|
||||
gboolean preview);
|
||||
static gint save_image (gchar *filename,
|
||||
gint32 image_ID,
|
||||
gint32 drawable_ID,
|
||||
gint32 orig_image_ID,
|
||||
gboolean preview);
|
||||
static void query (void);
|
||||
static void run (gchar *name,
|
||||
gint nparams,
|
||||
GimpParam *param,
|
||||
gint *nreturn_vals,
|
||||
GimpParam **return_vals);
|
||||
static gint32 load_image (gchar *filename,
|
||||
GimpRunModeType runmode,
|
||||
gboolean preview);
|
||||
static gboolean save_image (gchar *filename,
|
||||
gint32 image_ID,
|
||||
gint32 drawable_ID,
|
||||
gint32 orig_image_ID,
|
||||
gboolean preview);
|
||||
|
||||
static gint save_dialog (void);
|
||||
static gboolean save_dialog (void);
|
||||
|
||||
static void save_close_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void save_ok_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void save_restart_toggle_update (GtkWidget *toggle,
|
||||
GtkAdjustment *adjustment);
|
||||
static void save_restart_update (GtkAdjustment *adjustment,
|
||||
GtkWidget *toggle);
|
||||
static void save_close_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void save_ok_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void save_restart_toggle_update (GtkWidget *toggle,
|
||||
GtkAdjustment *adjustment);
|
||||
static void save_restart_update (GtkAdjustment *adjustment,
|
||||
GtkWidget *toggle);
|
||||
|
||||
static void make_preview (void);
|
||||
static void destroy_preview (void);
|
||||
static void make_preview (void);
|
||||
static void destroy_preview (void);
|
||||
|
||||
static void menu_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void menu_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
|
||||
|
||||
GimpPlugInInfo PLUG_IN_INFO =
|
||||
|
@ -347,24 +347,24 @@ query (void)
|
|||
}
|
||||
|
||||
static void
|
||||
run (gchar *name,
|
||||
gint nparams,
|
||||
run (gchar *name,
|
||||
gint nparams,
|
||||
GimpParam *param,
|
||||
gint *nreturn_vals,
|
||||
gint *nreturn_vals,
|
||||
GimpParam **return_vals)
|
||||
{
|
||||
static GimpParam values[2];
|
||||
GimpRunModeType run_mode;
|
||||
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
||||
gint32 image_ID;
|
||||
gint32 drawable_ID;
|
||||
gint32 orig_image_ID;
|
||||
gint32 display_ID = -1;
|
||||
static GimpParam values[2];
|
||||
GimpRunModeType run_mode;
|
||||
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
||||
gint32 image_ID;
|
||||
gint32 drawable_ID;
|
||||
gint32 orig_image_ID;
|
||||
gint32 display_ID = -1;
|
||||
#ifdef GIMP_HAVE_PARASITES
|
||||
GimpParasite *parasite;
|
||||
GimpParasite *parasite;
|
||||
#endif /* GIMP_HAVE_PARASITES */
|
||||
gint err;
|
||||
GimpExportReturnType export = GIMP_EXPORT_CANCEL;
|
||||
gboolean err;
|
||||
GimpExportReturnType export = GIMP_EXPORT_CANCEL;
|
||||
|
||||
run_mode = param[0].data.d_int32;
|
||||
|
||||
|
@ -622,7 +622,7 @@ run (gchar *name,
|
|||
static guint
|
||||
jpeg_getc (j_decompress_ptr cinfo)
|
||||
{
|
||||
struct jpeg_source_mgr * datasrc = cinfo->src;
|
||||
struct jpeg_source_mgr *datasrc = cinfo->src;
|
||||
|
||||
if (datasrc->bytes_in_buffer == 0)
|
||||
{
|
||||
|
@ -630,6 +630,7 @@ jpeg_getc (j_decompress_ptr cinfo)
|
|||
ERREXIT (cinfo, JERR_CANT_SUSPEND);
|
||||
}
|
||||
datasrc->bytes_in_buffer--;
|
||||
|
||||
return *datasrc->next_input_byte++;
|
||||
}
|
||||
|
||||
|
@ -647,8 +648,8 @@ static GString *local_image_comments = NULL;
|
|||
static boolean
|
||||
COM_handler (j_decompress_ptr cinfo)
|
||||
{
|
||||
int length;
|
||||
unsigned int ch;
|
||||
gint length;
|
||||
guint ch;
|
||||
|
||||
length = jpeg_getc (cinfo) << 8;
|
||||
length += jpeg_getc (cinfo);
|
||||
|
@ -700,22 +701,22 @@ load_image (gchar *filename,
|
|||
GimpRunModeType runmode,
|
||||
gboolean preview)
|
||||
{
|
||||
GimpPixelRgn pixel_rgn;
|
||||
GimpDrawable *drawable;
|
||||
gint32 volatile image_ID;
|
||||
gint32 layer_ID;
|
||||
GimpPixelRgn pixel_rgn;
|
||||
GimpDrawable *drawable;
|
||||
gint32 volatile image_ID;
|
||||
gint32 layer_ID;
|
||||
struct jpeg_decompress_struct cinfo;
|
||||
struct my_error_mgr jerr;
|
||||
FILE *infile;
|
||||
guchar *buf;
|
||||
guchar * volatile padded_buf = NULL;
|
||||
struct my_error_mgr jerr;
|
||||
FILE *infile;
|
||||
guchar *buf;
|
||||
guchar * volatile padded_buf = NULL;
|
||||
guchar **rowbuf;
|
||||
gchar *name;
|
||||
gint image_type;
|
||||
gint layer_type;
|
||||
gint tile_height;
|
||||
gint scanlines;
|
||||
gint i, start, end;
|
||||
gchar *name;
|
||||
gint image_type;
|
||||
gint layer_type;
|
||||
gint tile_height;
|
||||
gint scanlines;
|
||||
gint i, start, end;
|
||||
|
||||
#ifdef GIMP_HAVE_PARASITES
|
||||
JpegSaveVals local_save_vals;
|
||||
|
@ -723,7 +724,6 @@ load_image (gchar *filename,
|
|||
GimpParasite * volatile vals_parasite = NULL;
|
||||
#endif /* GIMP_HAVE_PARASITES */
|
||||
|
||||
|
||||
/* We set up the normal JPEG error routines. */
|
||||
cinfo.err = jpeg_std_error (&jerr.pub);
|
||||
jerr.pub.error_exit = my_error_exit;
|
||||
|
@ -778,46 +778,47 @@ load_image (gchar *filename,
|
|||
*/
|
||||
|
||||
#ifdef GIMP_HAVE_PARASITES
|
||||
if (!preview) {
|
||||
/* if we had any comments then make a parasite for them */
|
||||
if (local_image_comments && local_image_comments->len)
|
||||
{
|
||||
gchar *string = local_image_comments->str;
|
||||
g_string_free (local_image_comments, FALSE);
|
||||
local_image_comments = NULL;
|
||||
comment_parasite = gimp_parasite_new ("gimp-comment",
|
||||
GIMP_PARASITE_PERSISTENT,
|
||||
strlen (string) + 1, string);
|
||||
}
|
||||
else
|
||||
{
|
||||
comment_parasite = NULL;
|
||||
}
|
||||
|
||||
/* pw - figuring out what the saved values were is non-trivial.
|
||||
* They don't seem to be in the cinfo structure. For now, I will
|
||||
* just use the defaults, but if someone figures out how to derive
|
||||
* them this is the place to store them. */
|
||||
|
||||
local_save_vals.quality = DEFAULT_QUALITY;
|
||||
local_save_vals.smoothing = DEFAULT_SMOOTHING;
|
||||
local_save_vals.optimize = DEFAULT_OPTIMIZE;
|
||||
|
||||
if (!preview)
|
||||
{
|
||||
/* if we had any comments then make a parasite for them */
|
||||
if (local_image_comments && local_image_comments->len)
|
||||
{
|
||||
gchar *string = local_image_comments->str;
|
||||
g_string_free (local_image_comments, FALSE);
|
||||
local_image_comments = NULL;
|
||||
comment_parasite = gimp_parasite_new ("gimp-comment",
|
||||
GIMP_PARASITE_PERSISTENT,
|
||||
strlen (string) + 1, string);
|
||||
}
|
||||
else
|
||||
{
|
||||
comment_parasite = NULL;
|
||||
}
|
||||
|
||||
/* pw - figuring out what the saved values were is non-trivial.
|
||||
* They don't seem to be in the cinfo structure. For now, I will
|
||||
* just use the defaults, but if someone figures out how to derive
|
||||
* them this is the place to store them. */
|
||||
|
||||
local_save_vals.quality = DEFAULT_QUALITY;
|
||||
local_save_vals.smoothing = DEFAULT_SMOOTHING;
|
||||
local_save_vals.optimize = DEFAULT_OPTIMIZE;
|
||||
|
||||
#ifdef HAVE_PROGRESSIVE_JPEG
|
||||
local_save_vals.progressive = cinfo.progressive_mode;
|
||||
local_save_vals.progressive = cinfo.progressive_mode;
|
||||
#else
|
||||
local_save_vals.progressive = 0;
|
||||
local_save_vals.progressive = 0;
|
||||
#endif /* HAVE_PROGRESSIVE_JPEG */
|
||||
local_save_vals.baseline = DEFAULT_BASELINE;
|
||||
local_save_vals.subsmp = DEFAULT_SUBSMP; /* sg - this _is_ there, but I'm too lazy */
|
||||
local_save_vals.restart = DEFAULT_RESTART;
|
||||
local_save_vals.dct = DEFAULT_DCT;
|
||||
local_save_vals.preview = DEFAULT_PREVIEW;
|
||||
|
||||
vals_parasite = gimp_parasite_new ("jpeg-save-options", 0,
|
||||
sizeof (local_save_vals),
|
||||
&local_save_vals);
|
||||
}
|
||||
local_save_vals.baseline = DEFAULT_BASELINE;
|
||||
local_save_vals.subsmp = DEFAULT_SUBSMP; /* sg - this _is_ there, but I'm too lazy */
|
||||
local_save_vals.restart = DEFAULT_RESTART;
|
||||
local_save_vals.dct = DEFAULT_DCT;
|
||||
local_save_vals.preview = DEFAULT_PREVIEW;
|
||||
|
||||
vals_parasite = gimp_parasite_new ("jpeg-save-options", 0,
|
||||
sizeof (local_save_vals),
|
||||
&local_save_vals);
|
||||
}
|
||||
#endif /* GIMP_HAVE_PARASITES */
|
||||
|
||||
|
||||
|
@ -862,14 +863,17 @@ load_image (gchar *filename,
|
|||
image_type = GIMP_GRAY;
|
||||
layer_type = preview ? GIMP_GRAYA_IMAGE : GIMP_GRAY_IMAGE;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
image_type = GIMP_RGB;
|
||||
layer_type = preview ? GIMP_RGBA_IMAGE : GIMP_RGB_IMAGE;
|
||||
break;
|
||||
|
||||
default:
|
||||
g_message ("don't know how to load JPEGs\nwith %d color channels",
|
||||
cinfo.output_components);
|
||||
cinfo.output_components);
|
||||
gimp_quit ();
|
||||
break;
|
||||
}
|
||||
|
||||
if (preview)
|
||||
|
@ -885,10 +889,11 @@ load_image (gchar *filename,
|
|||
|
||||
if (preview)
|
||||
{
|
||||
layer_ID_global = layer_ID = gimp_layer_new (image_ID, _("JPEG preview"),
|
||||
cinfo.output_width,
|
||||
cinfo.output_height,
|
||||
layer_type, 100, GIMP_NORMAL_MODE);
|
||||
layer_ID_global = layer_ID =
|
||||
gimp_layer_new (image_ID, _("JPEG preview"),
|
||||
cinfo.output_width,
|
||||
cinfo.output_height,
|
||||
layer_type, 100, GIMP_NORMAL_MODE);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -951,23 +956,18 @@ load_image (gchar *filename,
|
|||
while (cinfo.output_scanline < cinfo.output_height)
|
||||
{
|
||||
start = cinfo.output_scanline;
|
||||
end = cinfo.output_scanline + tile_height;
|
||||
end = MIN (end, cinfo.output_height);
|
||||
end = cinfo.output_scanline + tile_height;
|
||||
end = MIN (end, cinfo.output_height);
|
||||
scanlines = end - start;
|
||||
|
||||
for (i = 0; i < scanlines; i++)
|
||||
jpeg_read_scanlines (&cinfo, (JSAMPARRAY) &rowbuf[i], 1);
|
||||
|
||||
/*
|
||||
for (i = start; i < end; i++)
|
||||
gimp_pixel_rgn_set_row (&pixel_rgn, tilerow[i - start], 0, i, drawable->width);
|
||||
*/
|
||||
|
||||
if (preview) /* Add a dummy alpha channel -- convert buf to padded_buf */
|
||||
{
|
||||
guchar *dest = padded_buf;
|
||||
guchar *src = buf;
|
||||
gint num = drawable->width * scanlines;
|
||||
gint num = drawable->width * scanlines;
|
||||
|
||||
switch (cinfo.output_components)
|
||||
{
|
||||
|
@ -978,6 +978,7 @@ load_image (gchar *filename,
|
|||
*(dest++) = 255;
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
for (i=0; i<num; i++)
|
||||
{
|
||||
|
@ -987,8 +988,10 @@ load_image (gchar *filename,
|
|||
*(dest++) = 255;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
g_warning ("JPEG - shouldn't have gotten here. Report to adam@gimp.org");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -997,7 +1000,8 @@ load_image (gchar *filename,
|
|||
|
||||
if (runmode != GIMP_RUN_NONINTERACTIVE)
|
||||
{
|
||||
gimp_progress_update ((double) cinfo.output_scanline / (double) cinfo.output_height);
|
||||
gimp_progress_update ((gdouble) cinfo.output_scanline /
|
||||
(gdouble) cinfo.output_height);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1046,6 +1050,7 @@ load_image (gchar *filename,
|
|||
gimp_image_parasite_attach (image_ID, comment_parasite);
|
||||
gimp_parasite_free (comment_parasite);
|
||||
}
|
||||
|
||||
if (vals_parasite)
|
||||
{
|
||||
gimp_image_parasite_attach (image_ID, vals_parasite);
|
||||
|
@ -1070,19 +1075,16 @@ background_error_exit (j_common_ptr cinfo)
|
|||
(*cinfo->err->output_message) (cinfo);
|
||||
}
|
||||
|
||||
static gint
|
||||
static gboolean
|
||||
background_jpeg_save (PreviewPersistent *pp)
|
||||
{
|
||||
guchar *t;
|
||||
guchar *s;
|
||||
gint i, j;
|
||||
gint yend;
|
||||
gint i, j;
|
||||
gint yend;
|
||||
|
||||
if (pp->abort_me || (pp->cinfo.next_scanline >= pp->cinfo.image_height))
|
||||
{
|
||||
struct stat buf;
|
||||
gchar temp[256];
|
||||
|
||||
/* clean up... */
|
||||
if (pp->abort_me)
|
||||
{
|
||||
|
@ -1099,11 +1101,15 @@ background_jpeg_save (PreviewPersistent *pp)
|
|||
g_free (pp->temp);
|
||||
g_free (pp->data);
|
||||
|
||||
if (pp->drawable) gimp_drawable_detach (pp->drawable);
|
||||
if (pp->drawable)
|
||||
gimp_drawable_detach (pp->drawable);
|
||||
|
||||
/* display the preview stuff */
|
||||
if (!pp->abort_me)
|
||||
{
|
||||
struct stat buf;
|
||||
gchar temp[128];
|
||||
|
||||
stat (pp->file_name, &buf);
|
||||
g_snprintf (temp, sizeof (temp),
|
||||
_("Size: %lu bytes (%02.01f kB)"),
|
||||
|
@ -1160,26 +1166,26 @@ background_jpeg_save (PreviewPersistent *pp)
|
|||
}
|
||||
}
|
||||
|
||||
static gint
|
||||
static gboolean
|
||||
save_image (gchar *filename,
|
||||
gint32 image_ID,
|
||||
gint32 drawable_ID,
|
||||
gint32 orig_image_ID,
|
||||
gboolean preview)
|
||||
{
|
||||
GimpPixelRgn pixel_rgn;
|
||||
GimpDrawable *drawable;
|
||||
GimpImageType drawable_type;
|
||||
GimpPixelRgn pixel_rgn;
|
||||
GimpDrawable *drawable;
|
||||
GimpImageType drawable_type;
|
||||
struct jpeg_compress_struct cinfo;
|
||||
struct my_error_mgr jerr;
|
||||
FILE * volatile outfile;
|
||||
guchar *temp, *t;
|
||||
guchar *data;
|
||||
guchar *src, *s;
|
||||
gchar *name;
|
||||
gint has_alpha;
|
||||
gint rowstride, yend;
|
||||
gint i, j;
|
||||
struct my_error_mgr jerr;
|
||||
FILE * volatile outfile;
|
||||
guchar *temp, *t;
|
||||
guchar *data;
|
||||
guchar *src, *s;
|
||||
gchar *name;
|
||||
gboolean has_alpha;
|
||||
gint rowstride, yend;
|
||||
gint i, j;
|
||||
|
||||
drawable = gimp_drawable_get (drawable_ID);
|
||||
drawable_type = gimp_drawable_type (drawable_ID);
|
||||
|
@ -1245,19 +1251,22 @@ save_image (gchar *filename,
|
|||
case GIMP_GRAY_IMAGE:
|
||||
/* # of color components per pixel */
|
||||
cinfo.input_components = drawable->bpp;
|
||||
has_alpha = 0;
|
||||
has_alpha = FALSE;
|
||||
break;
|
||||
|
||||
case GIMP_RGBA_IMAGE:
|
||||
case GIMP_GRAYA_IMAGE:
|
||||
/*gimp_message ("jpeg: image contains a-channel info which will be lost");*/
|
||||
/* # of color components per pixel (minus the GIMP alpha channel) */
|
||||
cinfo.input_components = drawable->bpp - 1;
|
||||
has_alpha = 1;
|
||||
has_alpha = TRUE;
|
||||
break;
|
||||
|
||||
case GIMP_INDEXED_IMAGE:
|
||||
/*gimp_message ("jpeg: cannot operate on indexed color images");*/
|
||||
return FALSE;
|
||||
break;
|
||||
|
||||
default:
|
||||
/*gimp_message ("jpeg: cannot operate on unknown image types");*/
|
||||
return FALSE;
|
||||
|
@ -1282,8 +1291,8 @@ save_image (gchar *filename,
|
|||
*/
|
||||
jpeg_set_defaults (&cinfo);
|
||||
|
||||
jpeg_set_quality (&cinfo, (int) (jsvals.quality * 100), jsvals.baseline);
|
||||
cinfo.smoothing_factor = (int) (jsvals.smoothing * 100);
|
||||
jpeg_set_quality (&cinfo, (gint) (jsvals.quality * 100), jsvals.baseline);
|
||||
cinfo.smoothing_factor = (gint) (jsvals.smoothing * 100);
|
||||
cinfo.optimize_coding = jsvals.optimize;
|
||||
|
||||
#ifdef HAVE_PROGRESSIVE_JPEG
|
||||
|
@ -1304,6 +1313,7 @@ save_image (gchar *filename,
|
|||
cinfo.comp_info[2].h_samp_factor = 1;
|
||||
cinfo.comp_info[2].v_samp_factor = 1;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
cinfo.comp_info[0].h_samp_factor = 2;
|
||||
cinfo.comp_info[0].v_samp_factor = 1;
|
||||
|
@ -1312,6 +1322,7 @@ save_image (gchar *filename,
|
|||
cinfo.comp_info[2].h_samp_factor = 1;
|
||||
cinfo.comp_info[2].v_samp_factor = 1;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
cinfo.comp_info[0].h_samp_factor = 1;
|
||||
cinfo.comp_info[0].v_samp_factor = 1;
|
||||
|
@ -1331,9 +1342,11 @@ save_image (gchar *filename,
|
|||
default:
|
||||
cinfo.dct_method = JDCT_ISLOW;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
cinfo.dct_method = JDCT_IFAST;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
cinfo.dct_method = JDCT_FLOAT;
|
||||
break;
|
||||
|
@ -1432,7 +1445,7 @@ save_image (gchar *filename,
|
|||
|
||||
jerr.pub.error_exit = background_error_exit;
|
||||
|
||||
gtk_idle_add ((GtkFunction) background_jpeg_save, (gpointer *)pp);
|
||||
gtk_idle_add ((GtkFunction) background_jpeg_save, (gpointer) pp);
|
||||
|
||||
/* background_jpeg_save() will cleanup as needed */
|
||||
return TRUE;
|
||||
|
@ -1525,21 +1538,25 @@ destroy_preview (void)
|
|||
{
|
||||
*abort_me = TRUE; /* signal the background save to stop */
|
||||
}
|
||||
|
||||
if (drawable_global)
|
||||
{
|
||||
gimp_drawable_detach (drawable_global);
|
||||
drawable_global = NULL;
|
||||
}
|
||||
|
||||
if (layer_ID_global != -1 && image_ID_global != -1)
|
||||
{
|
||||
/* assuming that reference counting is working correctly,
|
||||
we do not need to delete the layer, removing it from
|
||||
the image should be sufficient */
|
||||
gimp_image_remove_layer (image_ID_global, layer_ID_global);
|
||||
|
||||
/* gimp_layer_delete(layer_ID_global); */
|
||||
layer_ID_global = -1;
|
||||
}
|
||||
}
|
||||
|
||||
static gint
|
||||
static gboolean
|
||||
save_dialog (void)
|
||||
{
|
||||
GtkWidget *dlg;
|
||||
|
@ -1858,6 +1875,7 @@ save_ok_callback (GtkWidget *widget,
|
|||
gpointer data)
|
||||
{
|
||||
GtkWidget *text;
|
||||
|
||||
jsint.run = TRUE;
|
||||
|
||||
/* pw - get the comment text object and grab it's data */
|
||||
|
@ -1898,7 +1916,7 @@ save_restart_update (GtkAdjustment *adjustment,
|
|||
|
||||
static void
|
||||
menu_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
gpointer data)
|
||||
{
|
||||
gimp_menu_item_update (widget, data);
|
||||
make_preview ();
|
||||
|
|
|
@ -194,7 +194,7 @@ typedef struct
|
|||
struct jpeg_compress_struct cinfo;
|
||||
gint tile_height;
|
||||
FILE *outfile;
|
||||
gint has_alpha;
|
||||
gboolean has_alpha;
|
||||
gint rowstride;
|
||||
guchar *temp;
|
||||
guchar *data;
|
||||
|
@ -210,37 +210,37 @@ static gboolean *abort_me = NULL;
|
|||
|
||||
/* Declare local functions.
|
||||
*/
|
||||
static void query (void);
|
||||
static void run (gchar *name,
|
||||
gint nparams,
|
||||
GimpParam *param,
|
||||
gint *nreturn_vals,
|
||||
GimpParam **return_vals);
|
||||
static gint32 load_image (gchar *filename,
|
||||
GimpRunModeType runmode,
|
||||
gboolean preview);
|
||||
static gint save_image (gchar *filename,
|
||||
gint32 image_ID,
|
||||
gint32 drawable_ID,
|
||||
gint32 orig_image_ID,
|
||||
gboolean preview);
|
||||
static void query (void);
|
||||
static void run (gchar *name,
|
||||
gint nparams,
|
||||
GimpParam *param,
|
||||
gint *nreturn_vals,
|
||||
GimpParam **return_vals);
|
||||
static gint32 load_image (gchar *filename,
|
||||
GimpRunModeType runmode,
|
||||
gboolean preview);
|
||||
static gboolean save_image (gchar *filename,
|
||||
gint32 image_ID,
|
||||
gint32 drawable_ID,
|
||||
gint32 orig_image_ID,
|
||||
gboolean preview);
|
||||
|
||||
static gint save_dialog (void);
|
||||
static gboolean save_dialog (void);
|
||||
|
||||
static void save_close_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void save_ok_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void save_restart_toggle_update (GtkWidget *toggle,
|
||||
GtkAdjustment *adjustment);
|
||||
static void save_restart_update (GtkAdjustment *adjustment,
|
||||
GtkWidget *toggle);
|
||||
static void save_close_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void save_ok_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void save_restart_toggle_update (GtkWidget *toggle,
|
||||
GtkAdjustment *adjustment);
|
||||
static void save_restart_update (GtkAdjustment *adjustment,
|
||||
GtkWidget *toggle);
|
||||
|
||||
static void make_preview (void);
|
||||
static void destroy_preview (void);
|
||||
static void make_preview (void);
|
||||
static void destroy_preview (void);
|
||||
|
||||
static void menu_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void menu_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
|
||||
|
||||
GimpPlugInInfo PLUG_IN_INFO =
|
||||
|
@ -347,24 +347,24 @@ query (void)
|
|||
}
|
||||
|
||||
static void
|
||||
run (gchar *name,
|
||||
gint nparams,
|
||||
run (gchar *name,
|
||||
gint nparams,
|
||||
GimpParam *param,
|
||||
gint *nreturn_vals,
|
||||
gint *nreturn_vals,
|
||||
GimpParam **return_vals)
|
||||
{
|
||||
static GimpParam values[2];
|
||||
GimpRunModeType run_mode;
|
||||
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
||||
gint32 image_ID;
|
||||
gint32 drawable_ID;
|
||||
gint32 orig_image_ID;
|
||||
gint32 display_ID = -1;
|
||||
static GimpParam values[2];
|
||||
GimpRunModeType run_mode;
|
||||
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
||||
gint32 image_ID;
|
||||
gint32 drawable_ID;
|
||||
gint32 orig_image_ID;
|
||||
gint32 display_ID = -1;
|
||||
#ifdef GIMP_HAVE_PARASITES
|
||||
GimpParasite *parasite;
|
||||
GimpParasite *parasite;
|
||||
#endif /* GIMP_HAVE_PARASITES */
|
||||
gint err;
|
||||
GimpExportReturnType export = GIMP_EXPORT_CANCEL;
|
||||
gboolean err;
|
||||
GimpExportReturnType export = GIMP_EXPORT_CANCEL;
|
||||
|
||||
run_mode = param[0].data.d_int32;
|
||||
|
||||
|
@ -622,7 +622,7 @@ run (gchar *name,
|
|||
static guint
|
||||
jpeg_getc (j_decompress_ptr cinfo)
|
||||
{
|
||||
struct jpeg_source_mgr * datasrc = cinfo->src;
|
||||
struct jpeg_source_mgr *datasrc = cinfo->src;
|
||||
|
||||
if (datasrc->bytes_in_buffer == 0)
|
||||
{
|
||||
|
@ -630,6 +630,7 @@ jpeg_getc (j_decompress_ptr cinfo)
|
|||
ERREXIT (cinfo, JERR_CANT_SUSPEND);
|
||||
}
|
||||
datasrc->bytes_in_buffer--;
|
||||
|
||||
return *datasrc->next_input_byte++;
|
||||
}
|
||||
|
||||
|
@ -647,8 +648,8 @@ static GString *local_image_comments = NULL;
|
|||
static boolean
|
||||
COM_handler (j_decompress_ptr cinfo)
|
||||
{
|
||||
int length;
|
||||
unsigned int ch;
|
||||
gint length;
|
||||
guint ch;
|
||||
|
||||
length = jpeg_getc (cinfo) << 8;
|
||||
length += jpeg_getc (cinfo);
|
||||
|
@ -700,22 +701,22 @@ load_image (gchar *filename,
|
|||
GimpRunModeType runmode,
|
||||
gboolean preview)
|
||||
{
|
||||
GimpPixelRgn pixel_rgn;
|
||||
GimpDrawable *drawable;
|
||||
gint32 volatile image_ID;
|
||||
gint32 layer_ID;
|
||||
GimpPixelRgn pixel_rgn;
|
||||
GimpDrawable *drawable;
|
||||
gint32 volatile image_ID;
|
||||
gint32 layer_ID;
|
||||
struct jpeg_decompress_struct cinfo;
|
||||
struct my_error_mgr jerr;
|
||||
FILE *infile;
|
||||
guchar *buf;
|
||||
guchar * volatile padded_buf = NULL;
|
||||
struct my_error_mgr jerr;
|
||||
FILE *infile;
|
||||
guchar *buf;
|
||||
guchar * volatile padded_buf = NULL;
|
||||
guchar **rowbuf;
|
||||
gchar *name;
|
||||
gint image_type;
|
||||
gint layer_type;
|
||||
gint tile_height;
|
||||
gint scanlines;
|
||||
gint i, start, end;
|
||||
gchar *name;
|
||||
gint image_type;
|
||||
gint layer_type;
|
||||
gint tile_height;
|
||||
gint scanlines;
|
||||
gint i, start, end;
|
||||
|
||||
#ifdef GIMP_HAVE_PARASITES
|
||||
JpegSaveVals local_save_vals;
|
||||
|
@ -723,7 +724,6 @@ load_image (gchar *filename,
|
|||
GimpParasite * volatile vals_parasite = NULL;
|
||||
#endif /* GIMP_HAVE_PARASITES */
|
||||
|
||||
|
||||
/* We set up the normal JPEG error routines. */
|
||||
cinfo.err = jpeg_std_error (&jerr.pub);
|
||||
jerr.pub.error_exit = my_error_exit;
|
||||
|
@ -778,46 +778,47 @@ load_image (gchar *filename,
|
|||
*/
|
||||
|
||||
#ifdef GIMP_HAVE_PARASITES
|
||||
if (!preview) {
|
||||
/* if we had any comments then make a parasite for them */
|
||||
if (local_image_comments && local_image_comments->len)
|
||||
{
|
||||
gchar *string = local_image_comments->str;
|
||||
g_string_free (local_image_comments, FALSE);
|
||||
local_image_comments = NULL;
|
||||
comment_parasite = gimp_parasite_new ("gimp-comment",
|
||||
GIMP_PARASITE_PERSISTENT,
|
||||
strlen (string) + 1, string);
|
||||
}
|
||||
else
|
||||
{
|
||||
comment_parasite = NULL;
|
||||
}
|
||||
|
||||
/* pw - figuring out what the saved values were is non-trivial.
|
||||
* They don't seem to be in the cinfo structure. For now, I will
|
||||
* just use the defaults, but if someone figures out how to derive
|
||||
* them this is the place to store them. */
|
||||
|
||||
local_save_vals.quality = DEFAULT_QUALITY;
|
||||
local_save_vals.smoothing = DEFAULT_SMOOTHING;
|
||||
local_save_vals.optimize = DEFAULT_OPTIMIZE;
|
||||
|
||||
if (!preview)
|
||||
{
|
||||
/* if we had any comments then make a parasite for them */
|
||||
if (local_image_comments && local_image_comments->len)
|
||||
{
|
||||
gchar *string = local_image_comments->str;
|
||||
g_string_free (local_image_comments, FALSE);
|
||||
local_image_comments = NULL;
|
||||
comment_parasite = gimp_parasite_new ("gimp-comment",
|
||||
GIMP_PARASITE_PERSISTENT,
|
||||
strlen (string) + 1, string);
|
||||
}
|
||||
else
|
||||
{
|
||||
comment_parasite = NULL;
|
||||
}
|
||||
|
||||
/* pw - figuring out what the saved values were is non-trivial.
|
||||
* They don't seem to be in the cinfo structure. For now, I will
|
||||
* just use the defaults, but if someone figures out how to derive
|
||||
* them this is the place to store them. */
|
||||
|
||||
local_save_vals.quality = DEFAULT_QUALITY;
|
||||
local_save_vals.smoothing = DEFAULT_SMOOTHING;
|
||||
local_save_vals.optimize = DEFAULT_OPTIMIZE;
|
||||
|
||||
#ifdef HAVE_PROGRESSIVE_JPEG
|
||||
local_save_vals.progressive = cinfo.progressive_mode;
|
||||
local_save_vals.progressive = cinfo.progressive_mode;
|
||||
#else
|
||||
local_save_vals.progressive = 0;
|
||||
local_save_vals.progressive = 0;
|
||||
#endif /* HAVE_PROGRESSIVE_JPEG */
|
||||
local_save_vals.baseline = DEFAULT_BASELINE;
|
||||
local_save_vals.subsmp = DEFAULT_SUBSMP; /* sg - this _is_ there, but I'm too lazy */
|
||||
local_save_vals.restart = DEFAULT_RESTART;
|
||||
local_save_vals.dct = DEFAULT_DCT;
|
||||
local_save_vals.preview = DEFAULT_PREVIEW;
|
||||
|
||||
vals_parasite = gimp_parasite_new ("jpeg-save-options", 0,
|
||||
sizeof (local_save_vals),
|
||||
&local_save_vals);
|
||||
}
|
||||
local_save_vals.baseline = DEFAULT_BASELINE;
|
||||
local_save_vals.subsmp = DEFAULT_SUBSMP; /* sg - this _is_ there, but I'm too lazy */
|
||||
local_save_vals.restart = DEFAULT_RESTART;
|
||||
local_save_vals.dct = DEFAULT_DCT;
|
||||
local_save_vals.preview = DEFAULT_PREVIEW;
|
||||
|
||||
vals_parasite = gimp_parasite_new ("jpeg-save-options", 0,
|
||||
sizeof (local_save_vals),
|
||||
&local_save_vals);
|
||||
}
|
||||
#endif /* GIMP_HAVE_PARASITES */
|
||||
|
||||
|
||||
|
@ -862,14 +863,17 @@ load_image (gchar *filename,
|
|||
image_type = GIMP_GRAY;
|
||||
layer_type = preview ? GIMP_GRAYA_IMAGE : GIMP_GRAY_IMAGE;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
image_type = GIMP_RGB;
|
||||
layer_type = preview ? GIMP_RGBA_IMAGE : GIMP_RGB_IMAGE;
|
||||
break;
|
||||
|
||||
default:
|
||||
g_message ("don't know how to load JPEGs\nwith %d color channels",
|
||||
cinfo.output_components);
|
||||
cinfo.output_components);
|
||||
gimp_quit ();
|
||||
break;
|
||||
}
|
||||
|
||||
if (preview)
|
||||
|
@ -885,10 +889,11 @@ load_image (gchar *filename,
|
|||
|
||||
if (preview)
|
||||
{
|
||||
layer_ID_global = layer_ID = gimp_layer_new (image_ID, _("JPEG preview"),
|
||||
cinfo.output_width,
|
||||
cinfo.output_height,
|
||||
layer_type, 100, GIMP_NORMAL_MODE);
|
||||
layer_ID_global = layer_ID =
|
||||
gimp_layer_new (image_ID, _("JPEG preview"),
|
||||
cinfo.output_width,
|
||||
cinfo.output_height,
|
||||
layer_type, 100, GIMP_NORMAL_MODE);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -951,23 +956,18 @@ load_image (gchar *filename,
|
|||
while (cinfo.output_scanline < cinfo.output_height)
|
||||
{
|
||||
start = cinfo.output_scanline;
|
||||
end = cinfo.output_scanline + tile_height;
|
||||
end = MIN (end, cinfo.output_height);
|
||||
end = cinfo.output_scanline + tile_height;
|
||||
end = MIN (end, cinfo.output_height);
|
||||
scanlines = end - start;
|
||||
|
||||
for (i = 0; i < scanlines; i++)
|
||||
jpeg_read_scanlines (&cinfo, (JSAMPARRAY) &rowbuf[i], 1);
|
||||
|
||||
/*
|
||||
for (i = start; i < end; i++)
|
||||
gimp_pixel_rgn_set_row (&pixel_rgn, tilerow[i - start], 0, i, drawable->width);
|
||||
*/
|
||||
|
||||
if (preview) /* Add a dummy alpha channel -- convert buf to padded_buf */
|
||||
{
|
||||
guchar *dest = padded_buf;
|
||||
guchar *src = buf;
|
||||
gint num = drawable->width * scanlines;
|
||||
gint num = drawable->width * scanlines;
|
||||
|
||||
switch (cinfo.output_components)
|
||||
{
|
||||
|
@ -978,6 +978,7 @@ load_image (gchar *filename,
|
|||
*(dest++) = 255;
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
for (i=0; i<num; i++)
|
||||
{
|
||||
|
@ -987,8 +988,10 @@ load_image (gchar *filename,
|
|||
*(dest++) = 255;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
g_warning ("JPEG - shouldn't have gotten here. Report to adam@gimp.org");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -997,7 +1000,8 @@ load_image (gchar *filename,
|
|||
|
||||
if (runmode != GIMP_RUN_NONINTERACTIVE)
|
||||
{
|
||||
gimp_progress_update ((double) cinfo.output_scanline / (double) cinfo.output_height);
|
||||
gimp_progress_update ((gdouble) cinfo.output_scanline /
|
||||
(gdouble) cinfo.output_height);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1046,6 +1050,7 @@ load_image (gchar *filename,
|
|||
gimp_image_parasite_attach (image_ID, comment_parasite);
|
||||
gimp_parasite_free (comment_parasite);
|
||||
}
|
||||
|
||||
if (vals_parasite)
|
||||
{
|
||||
gimp_image_parasite_attach (image_ID, vals_parasite);
|
||||
|
@ -1070,19 +1075,16 @@ background_error_exit (j_common_ptr cinfo)
|
|||
(*cinfo->err->output_message) (cinfo);
|
||||
}
|
||||
|
||||
static gint
|
||||
static gboolean
|
||||
background_jpeg_save (PreviewPersistent *pp)
|
||||
{
|
||||
guchar *t;
|
||||
guchar *s;
|
||||
gint i, j;
|
||||
gint yend;
|
||||
gint i, j;
|
||||
gint yend;
|
||||
|
||||
if (pp->abort_me || (pp->cinfo.next_scanline >= pp->cinfo.image_height))
|
||||
{
|
||||
struct stat buf;
|
||||
gchar temp[256];
|
||||
|
||||
/* clean up... */
|
||||
if (pp->abort_me)
|
||||
{
|
||||
|
@ -1099,11 +1101,15 @@ background_jpeg_save (PreviewPersistent *pp)
|
|||
g_free (pp->temp);
|
||||
g_free (pp->data);
|
||||
|
||||
if (pp->drawable) gimp_drawable_detach (pp->drawable);
|
||||
if (pp->drawable)
|
||||
gimp_drawable_detach (pp->drawable);
|
||||
|
||||
/* display the preview stuff */
|
||||
if (!pp->abort_me)
|
||||
{
|
||||
struct stat buf;
|
||||
gchar temp[128];
|
||||
|
||||
stat (pp->file_name, &buf);
|
||||
g_snprintf (temp, sizeof (temp),
|
||||
_("Size: %lu bytes (%02.01f kB)"),
|
||||
|
@ -1160,26 +1166,26 @@ background_jpeg_save (PreviewPersistent *pp)
|
|||
}
|
||||
}
|
||||
|
||||
static gint
|
||||
static gboolean
|
||||
save_image (gchar *filename,
|
||||
gint32 image_ID,
|
||||
gint32 drawable_ID,
|
||||
gint32 orig_image_ID,
|
||||
gboolean preview)
|
||||
{
|
||||
GimpPixelRgn pixel_rgn;
|
||||
GimpDrawable *drawable;
|
||||
GimpImageType drawable_type;
|
||||
GimpPixelRgn pixel_rgn;
|
||||
GimpDrawable *drawable;
|
||||
GimpImageType drawable_type;
|
||||
struct jpeg_compress_struct cinfo;
|
||||
struct my_error_mgr jerr;
|
||||
FILE * volatile outfile;
|
||||
guchar *temp, *t;
|
||||
guchar *data;
|
||||
guchar *src, *s;
|
||||
gchar *name;
|
||||
gint has_alpha;
|
||||
gint rowstride, yend;
|
||||
gint i, j;
|
||||
struct my_error_mgr jerr;
|
||||
FILE * volatile outfile;
|
||||
guchar *temp, *t;
|
||||
guchar *data;
|
||||
guchar *src, *s;
|
||||
gchar *name;
|
||||
gboolean has_alpha;
|
||||
gint rowstride, yend;
|
||||
gint i, j;
|
||||
|
||||
drawable = gimp_drawable_get (drawable_ID);
|
||||
drawable_type = gimp_drawable_type (drawable_ID);
|
||||
|
@ -1245,19 +1251,22 @@ save_image (gchar *filename,
|
|||
case GIMP_GRAY_IMAGE:
|
||||
/* # of color components per pixel */
|
||||
cinfo.input_components = drawable->bpp;
|
||||
has_alpha = 0;
|
||||
has_alpha = FALSE;
|
||||
break;
|
||||
|
||||
case GIMP_RGBA_IMAGE:
|
||||
case GIMP_GRAYA_IMAGE:
|
||||
/*gimp_message ("jpeg: image contains a-channel info which will be lost");*/
|
||||
/* # of color components per pixel (minus the GIMP alpha channel) */
|
||||
cinfo.input_components = drawable->bpp - 1;
|
||||
has_alpha = 1;
|
||||
has_alpha = TRUE;
|
||||
break;
|
||||
|
||||
case GIMP_INDEXED_IMAGE:
|
||||
/*gimp_message ("jpeg: cannot operate on indexed color images");*/
|
||||
return FALSE;
|
||||
break;
|
||||
|
||||
default:
|
||||
/*gimp_message ("jpeg: cannot operate on unknown image types");*/
|
||||
return FALSE;
|
||||
|
@ -1282,8 +1291,8 @@ save_image (gchar *filename,
|
|||
*/
|
||||
jpeg_set_defaults (&cinfo);
|
||||
|
||||
jpeg_set_quality (&cinfo, (int) (jsvals.quality * 100), jsvals.baseline);
|
||||
cinfo.smoothing_factor = (int) (jsvals.smoothing * 100);
|
||||
jpeg_set_quality (&cinfo, (gint) (jsvals.quality * 100), jsvals.baseline);
|
||||
cinfo.smoothing_factor = (gint) (jsvals.smoothing * 100);
|
||||
cinfo.optimize_coding = jsvals.optimize;
|
||||
|
||||
#ifdef HAVE_PROGRESSIVE_JPEG
|
||||
|
@ -1304,6 +1313,7 @@ save_image (gchar *filename,
|
|||
cinfo.comp_info[2].h_samp_factor = 1;
|
||||
cinfo.comp_info[2].v_samp_factor = 1;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
cinfo.comp_info[0].h_samp_factor = 2;
|
||||
cinfo.comp_info[0].v_samp_factor = 1;
|
||||
|
@ -1312,6 +1322,7 @@ save_image (gchar *filename,
|
|||
cinfo.comp_info[2].h_samp_factor = 1;
|
||||
cinfo.comp_info[2].v_samp_factor = 1;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
cinfo.comp_info[0].h_samp_factor = 1;
|
||||
cinfo.comp_info[0].v_samp_factor = 1;
|
||||
|
@ -1331,9 +1342,11 @@ save_image (gchar *filename,
|
|||
default:
|
||||
cinfo.dct_method = JDCT_ISLOW;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
cinfo.dct_method = JDCT_IFAST;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
cinfo.dct_method = JDCT_FLOAT;
|
||||
break;
|
||||
|
@ -1432,7 +1445,7 @@ save_image (gchar *filename,
|
|||
|
||||
jerr.pub.error_exit = background_error_exit;
|
||||
|
||||
gtk_idle_add ((GtkFunction) background_jpeg_save, (gpointer *)pp);
|
||||
gtk_idle_add ((GtkFunction) background_jpeg_save, (gpointer) pp);
|
||||
|
||||
/* background_jpeg_save() will cleanup as needed */
|
||||
return TRUE;
|
||||
|
@ -1525,21 +1538,25 @@ destroy_preview (void)
|
|||
{
|
||||
*abort_me = TRUE; /* signal the background save to stop */
|
||||
}
|
||||
|
||||
if (drawable_global)
|
||||
{
|
||||
gimp_drawable_detach (drawable_global);
|
||||
drawable_global = NULL;
|
||||
}
|
||||
|
||||
if (layer_ID_global != -1 && image_ID_global != -1)
|
||||
{
|
||||
/* assuming that reference counting is working correctly,
|
||||
we do not need to delete the layer, removing it from
|
||||
the image should be sufficient */
|
||||
gimp_image_remove_layer (image_ID_global, layer_ID_global);
|
||||
|
||||
/* gimp_layer_delete(layer_ID_global); */
|
||||
layer_ID_global = -1;
|
||||
}
|
||||
}
|
||||
|
||||
static gint
|
||||
static gboolean
|
||||
save_dialog (void)
|
||||
{
|
||||
GtkWidget *dlg;
|
||||
|
@ -1858,6 +1875,7 @@ save_ok_callback (GtkWidget *widget,
|
|||
gpointer data)
|
||||
{
|
||||
GtkWidget *text;
|
||||
|
||||
jsint.run = TRUE;
|
||||
|
||||
/* pw - get the comment text object and grab it's data */
|
||||
|
@ -1898,7 +1916,7 @@ save_restart_update (GtkAdjustment *adjustment,
|
|||
|
||||
static void
|
||||
menu_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
gpointer data)
|
||||
{
|
||||
gimp_menu_item_update (widget, data);
|
||||
make_preview ();
|
||||
|
|
|
@ -194,7 +194,7 @@ typedef struct
|
|||
struct jpeg_compress_struct cinfo;
|
||||
gint tile_height;
|
||||
FILE *outfile;
|
||||
gint has_alpha;
|
||||
gboolean has_alpha;
|
||||
gint rowstride;
|
||||
guchar *temp;
|
||||
guchar *data;
|
||||
|
@ -210,37 +210,37 @@ static gboolean *abort_me = NULL;
|
|||
|
||||
/* Declare local functions.
|
||||
*/
|
||||
static void query (void);
|
||||
static void run (gchar *name,
|
||||
gint nparams,
|
||||
GimpParam *param,
|
||||
gint *nreturn_vals,
|
||||
GimpParam **return_vals);
|
||||
static gint32 load_image (gchar *filename,
|
||||
GimpRunModeType runmode,
|
||||
gboolean preview);
|
||||
static gint save_image (gchar *filename,
|
||||
gint32 image_ID,
|
||||
gint32 drawable_ID,
|
||||
gint32 orig_image_ID,
|
||||
gboolean preview);
|
||||
static void query (void);
|
||||
static void run (gchar *name,
|
||||
gint nparams,
|
||||
GimpParam *param,
|
||||
gint *nreturn_vals,
|
||||
GimpParam **return_vals);
|
||||
static gint32 load_image (gchar *filename,
|
||||
GimpRunModeType runmode,
|
||||
gboolean preview);
|
||||
static gboolean save_image (gchar *filename,
|
||||
gint32 image_ID,
|
||||
gint32 drawable_ID,
|
||||
gint32 orig_image_ID,
|
||||
gboolean preview);
|
||||
|
||||
static gint save_dialog (void);
|
||||
static gboolean save_dialog (void);
|
||||
|
||||
static void save_close_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void save_ok_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void save_restart_toggle_update (GtkWidget *toggle,
|
||||
GtkAdjustment *adjustment);
|
||||
static void save_restart_update (GtkAdjustment *adjustment,
|
||||
GtkWidget *toggle);
|
||||
static void save_close_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void save_ok_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void save_restart_toggle_update (GtkWidget *toggle,
|
||||
GtkAdjustment *adjustment);
|
||||
static void save_restart_update (GtkAdjustment *adjustment,
|
||||
GtkWidget *toggle);
|
||||
|
||||
static void make_preview (void);
|
||||
static void destroy_preview (void);
|
||||
static void make_preview (void);
|
||||
static void destroy_preview (void);
|
||||
|
||||
static void menu_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void menu_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
|
||||
|
||||
GimpPlugInInfo PLUG_IN_INFO =
|
||||
|
@ -347,24 +347,24 @@ query (void)
|
|||
}
|
||||
|
||||
static void
|
||||
run (gchar *name,
|
||||
gint nparams,
|
||||
run (gchar *name,
|
||||
gint nparams,
|
||||
GimpParam *param,
|
||||
gint *nreturn_vals,
|
||||
gint *nreturn_vals,
|
||||
GimpParam **return_vals)
|
||||
{
|
||||
static GimpParam values[2];
|
||||
GimpRunModeType run_mode;
|
||||
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
||||
gint32 image_ID;
|
||||
gint32 drawable_ID;
|
||||
gint32 orig_image_ID;
|
||||
gint32 display_ID = -1;
|
||||
static GimpParam values[2];
|
||||
GimpRunModeType run_mode;
|
||||
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
||||
gint32 image_ID;
|
||||
gint32 drawable_ID;
|
||||
gint32 orig_image_ID;
|
||||
gint32 display_ID = -1;
|
||||
#ifdef GIMP_HAVE_PARASITES
|
||||
GimpParasite *parasite;
|
||||
GimpParasite *parasite;
|
||||
#endif /* GIMP_HAVE_PARASITES */
|
||||
gint err;
|
||||
GimpExportReturnType export = GIMP_EXPORT_CANCEL;
|
||||
gboolean err;
|
||||
GimpExportReturnType export = GIMP_EXPORT_CANCEL;
|
||||
|
||||
run_mode = param[0].data.d_int32;
|
||||
|
||||
|
@ -622,7 +622,7 @@ run (gchar *name,
|
|||
static guint
|
||||
jpeg_getc (j_decompress_ptr cinfo)
|
||||
{
|
||||
struct jpeg_source_mgr * datasrc = cinfo->src;
|
||||
struct jpeg_source_mgr *datasrc = cinfo->src;
|
||||
|
||||
if (datasrc->bytes_in_buffer == 0)
|
||||
{
|
||||
|
@ -630,6 +630,7 @@ jpeg_getc (j_decompress_ptr cinfo)
|
|||
ERREXIT (cinfo, JERR_CANT_SUSPEND);
|
||||
}
|
||||
datasrc->bytes_in_buffer--;
|
||||
|
||||
return *datasrc->next_input_byte++;
|
||||
}
|
||||
|
||||
|
@ -647,8 +648,8 @@ static GString *local_image_comments = NULL;
|
|||
static boolean
|
||||
COM_handler (j_decompress_ptr cinfo)
|
||||
{
|
||||
int length;
|
||||
unsigned int ch;
|
||||
gint length;
|
||||
guint ch;
|
||||
|
||||
length = jpeg_getc (cinfo) << 8;
|
||||
length += jpeg_getc (cinfo);
|
||||
|
@ -700,22 +701,22 @@ load_image (gchar *filename,
|
|||
GimpRunModeType runmode,
|
||||
gboolean preview)
|
||||
{
|
||||
GimpPixelRgn pixel_rgn;
|
||||
GimpDrawable *drawable;
|
||||
gint32 volatile image_ID;
|
||||
gint32 layer_ID;
|
||||
GimpPixelRgn pixel_rgn;
|
||||
GimpDrawable *drawable;
|
||||
gint32 volatile image_ID;
|
||||
gint32 layer_ID;
|
||||
struct jpeg_decompress_struct cinfo;
|
||||
struct my_error_mgr jerr;
|
||||
FILE *infile;
|
||||
guchar *buf;
|
||||
guchar * volatile padded_buf = NULL;
|
||||
struct my_error_mgr jerr;
|
||||
FILE *infile;
|
||||
guchar *buf;
|
||||
guchar * volatile padded_buf = NULL;
|
||||
guchar **rowbuf;
|
||||
gchar *name;
|
||||
gint image_type;
|
||||
gint layer_type;
|
||||
gint tile_height;
|
||||
gint scanlines;
|
||||
gint i, start, end;
|
||||
gchar *name;
|
||||
gint image_type;
|
||||
gint layer_type;
|
||||
gint tile_height;
|
||||
gint scanlines;
|
||||
gint i, start, end;
|
||||
|
||||
#ifdef GIMP_HAVE_PARASITES
|
||||
JpegSaveVals local_save_vals;
|
||||
|
@ -723,7 +724,6 @@ load_image (gchar *filename,
|
|||
GimpParasite * volatile vals_parasite = NULL;
|
||||
#endif /* GIMP_HAVE_PARASITES */
|
||||
|
||||
|
||||
/* We set up the normal JPEG error routines. */
|
||||
cinfo.err = jpeg_std_error (&jerr.pub);
|
||||
jerr.pub.error_exit = my_error_exit;
|
||||
|
@ -778,46 +778,47 @@ load_image (gchar *filename,
|
|||
*/
|
||||
|
||||
#ifdef GIMP_HAVE_PARASITES
|
||||
if (!preview) {
|
||||
/* if we had any comments then make a parasite for them */
|
||||
if (local_image_comments && local_image_comments->len)
|
||||
{
|
||||
gchar *string = local_image_comments->str;
|
||||
g_string_free (local_image_comments, FALSE);
|
||||
local_image_comments = NULL;
|
||||
comment_parasite = gimp_parasite_new ("gimp-comment",
|
||||
GIMP_PARASITE_PERSISTENT,
|
||||
strlen (string) + 1, string);
|
||||
}
|
||||
else
|
||||
{
|
||||
comment_parasite = NULL;
|
||||
}
|
||||
|
||||
/* pw - figuring out what the saved values were is non-trivial.
|
||||
* They don't seem to be in the cinfo structure. For now, I will
|
||||
* just use the defaults, but if someone figures out how to derive
|
||||
* them this is the place to store them. */
|
||||
|
||||
local_save_vals.quality = DEFAULT_QUALITY;
|
||||
local_save_vals.smoothing = DEFAULT_SMOOTHING;
|
||||
local_save_vals.optimize = DEFAULT_OPTIMIZE;
|
||||
|
||||
if (!preview)
|
||||
{
|
||||
/* if we had any comments then make a parasite for them */
|
||||
if (local_image_comments && local_image_comments->len)
|
||||
{
|
||||
gchar *string = local_image_comments->str;
|
||||
g_string_free (local_image_comments, FALSE);
|
||||
local_image_comments = NULL;
|
||||
comment_parasite = gimp_parasite_new ("gimp-comment",
|
||||
GIMP_PARASITE_PERSISTENT,
|
||||
strlen (string) + 1, string);
|
||||
}
|
||||
else
|
||||
{
|
||||
comment_parasite = NULL;
|
||||
}
|
||||
|
||||
/* pw - figuring out what the saved values were is non-trivial.
|
||||
* They don't seem to be in the cinfo structure. For now, I will
|
||||
* just use the defaults, but if someone figures out how to derive
|
||||
* them this is the place to store them. */
|
||||
|
||||
local_save_vals.quality = DEFAULT_QUALITY;
|
||||
local_save_vals.smoothing = DEFAULT_SMOOTHING;
|
||||
local_save_vals.optimize = DEFAULT_OPTIMIZE;
|
||||
|
||||
#ifdef HAVE_PROGRESSIVE_JPEG
|
||||
local_save_vals.progressive = cinfo.progressive_mode;
|
||||
local_save_vals.progressive = cinfo.progressive_mode;
|
||||
#else
|
||||
local_save_vals.progressive = 0;
|
||||
local_save_vals.progressive = 0;
|
||||
#endif /* HAVE_PROGRESSIVE_JPEG */
|
||||
local_save_vals.baseline = DEFAULT_BASELINE;
|
||||
local_save_vals.subsmp = DEFAULT_SUBSMP; /* sg - this _is_ there, but I'm too lazy */
|
||||
local_save_vals.restart = DEFAULT_RESTART;
|
||||
local_save_vals.dct = DEFAULT_DCT;
|
||||
local_save_vals.preview = DEFAULT_PREVIEW;
|
||||
|
||||
vals_parasite = gimp_parasite_new ("jpeg-save-options", 0,
|
||||
sizeof (local_save_vals),
|
||||
&local_save_vals);
|
||||
}
|
||||
local_save_vals.baseline = DEFAULT_BASELINE;
|
||||
local_save_vals.subsmp = DEFAULT_SUBSMP; /* sg - this _is_ there, but I'm too lazy */
|
||||
local_save_vals.restart = DEFAULT_RESTART;
|
||||
local_save_vals.dct = DEFAULT_DCT;
|
||||
local_save_vals.preview = DEFAULT_PREVIEW;
|
||||
|
||||
vals_parasite = gimp_parasite_new ("jpeg-save-options", 0,
|
||||
sizeof (local_save_vals),
|
||||
&local_save_vals);
|
||||
}
|
||||
#endif /* GIMP_HAVE_PARASITES */
|
||||
|
||||
|
||||
|
@ -862,14 +863,17 @@ load_image (gchar *filename,
|
|||
image_type = GIMP_GRAY;
|
||||
layer_type = preview ? GIMP_GRAYA_IMAGE : GIMP_GRAY_IMAGE;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
image_type = GIMP_RGB;
|
||||
layer_type = preview ? GIMP_RGBA_IMAGE : GIMP_RGB_IMAGE;
|
||||
break;
|
||||
|
||||
default:
|
||||
g_message ("don't know how to load JPEGs\nwith %d color channels",
|
||||
cinfo.output_components);
|
||||
cinfo.output_components);
|
||||
gimp_quit ();
|
||||
break;
|
||||
}
|
||||
|
||||
if (preview)
|
||||
|
@ -885,10 +889,11 @@ load_image (gchar *filename,
|
|||
|
||||
if (preview)
|
||||
{
|
||||
layer_ID_global = layer_ID = gimp_layer_new (image_ID, _("JPEG preview"),
|
||||
cinfo.output_width,
|
||||
cinfo.output_height,
|
||||
layer_type, 100, GIMP_NORMAL_MODE);
|
||||
layer_ID_global = layer_ID =
|
||||
gimp_layer_new (image_ID, _("JPEG preview"),
|
||||
cinfo.output_width,
|
||||
cinfo.output_height,
|
||||
layer_type, 100, GIMP_NORMAL_MODE);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -951,23 +956,18 @@ load_image (gchar *filename,
|
|||
while (cinfo.output_scanline < cinfo.output_height)
|
||||
{
|
||||
start = cinfo.output_scanline;
|
||||
end = cinfo.output_scanline + tile_height;
|
||||
end = MIN (end, cinfo.output_height);
|
||||
end = cinfo.output_scanline + tile_height;
|
||||
end = MIN (end, cinfo.output_height);
|
||||
scanlines = end - start;
|
||||
|
||||
for (i = 0; i < scanlines; i++)
|
||||
jpeg_read_scanlines (&cinfo, (JSAMPARRAY) &rowbuf[i], 1);
|
||||
|
||||
/*
|
||||
for (i = start; i < end; i++)
|
||||
gimp_pixel_rgn_set_row (&pixel_rgn, tilerow[i - start], 0, i, drawable->width);
|
||||
*/
|
||||
|
||||
if (preview) /* Add a dummy alpha channel -- convert buf to padded_buf */
|
||||
{
|
||||
guchar *dest = padded_buf;
|
||||
guchar *src = buf;
|
||||
gint num = drawable->width * scanlines;
|
||||
gint num = drawable->width * scanlines;
|
||||
|
||||
switch (cinfo.output_components)
|
||||
{
|
||||
|
@ -978,6 +978,7 @@ load_image (gchar *filename,
|
|||
*(dest++) = 255;
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
for (i=0; i<num; i++)
|
||||
{
|
||||
|
@ -987,8 +988,10 @@ load_image (gchar *filename,
|
|||
*(dest++) = 255;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
g_warning ("JPEG - shouldn't have gotten here. Report to adam@gimp.org");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -997,7 +1000,8 @@ load_image (gchar *filename,
|
|||
|
||||
if (runmode != GIMP_RUN_NONINTERACTIVE)
|
||||
{
|
||||
gimp_progress_update ((double) cinfo.output_scanline / (double) cinfo.output_height);
|
||||
gimp_progress_update ((gdouble) cinfo.output_scanline /
|
||||
(gdouble) cinfo.output_height);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1046,6 +1050,7 @@ load_image (gchar *filename,
|
|||
gimp_image_parasite_attach (image_ID, comment_parasite);
|
||||
gimp_parasite_free (comment_parasite);
|
||||
}
|
||||
|
||||
if (vals_parasite)
|
||||
{
|
||||
gimp_image_parasite_attach (image_ID, vals_parasite);
|
||||
|
@ -1070,19 +1075,16 @@ background_error_exit (j_common_ptr cinfo)
|
|||
(*cinfo->err->output_message) (cinfo);
|
||||
}
|
||||
|
||||
static gint
|
||||
static gboolean
|
||||
background_jpeg_save (PreviewPersistent *pp)
|
||||
{
|
||||
guchar *t;
|
||||
guchar *s;
|
||||
gint i, j;
|
||||
gint yend;
|
||||
gint i, j;
|
||||
gint yend;
|
||||
|
||||
if (pp->abort_me || (pp->cinfo.next_scanline >= pp->cinfo.image_height))
|
||||
{
|
||||
struct stat buf;
|
||||
gchar temp[256];
|
||||
|
||||
/* clean up... */
|
||||
if (pp->abort_me)
|
||||
{
|
||||
|
@ -1099,11 +1101,15 @@ background_jpeg_save (PreviewPersistent *pp)
|
|||
g_free (pp->temp);
|
||||
g_free (pp->data);
|
||||
|
||||
if (pp->drawable) gimp_drawable_detach (pp->drawable);
|
||||
if (pp->drawable)
|
||||
gimp_drawable_detach (pp->drawable);
|
||||
|
||||
/* display the preview stuff */
|
||||
if (!pp->abort_me)
|
||||
{
|
||||
struct stat buf;
|
||||
gchar temp[128];
|
||||
|
||||
stat (pp->file_name, &buf);
|
||||
g_snprintf (temp, sizeof (temp),
|
||||
_("Size: %lu bytes (%02.01f kB)"),
|
||||
|
@ -1160,26 +1166,26 @@ background_jpeg_save (PreviewPersistent *pp)
|
|||
}
|
||||
}
|
||||
|
||||
static gint
|
||||
static gboolean
|
||||
save_image (gchar *filename,
|
||||
gint32 image_ID,
|
||||
gint32 drawable_ID,
|
||||
gint32 orig_image_ID,
|
||||
gboolean preview)
|
||||
{
|
||||
GimpPixelRgn pixel_rgn;
|
||||
GimpDrawable *drawable;
|
||||
GimpImageType drawable_type;
|
||||
GimpPixelRgn pixel_rgn;
|
||||
GimpDrawable *drawable;
|
||||
GimpImageType drawable_type;
|
||||
struct jpeg_compress_struct cinfo;
|
||||
struct my_error_mgr jerr;
|
||||
FILE * volatile outfile;
|
||||
guchar *temp, *t;
|
||||
guchar *data;
|
||||
guchar *src, *s;
|
||||
gchar *name;
|
||||
gint has_alpha;
|
||||
gint rowstride, yend;
|
||||
gint i, j;
|
||||
struct my_error_mgr jerr;
|
||||
FILE * volatile outfile;
|
||||
guchar *temp, *t;
|
||||
guchar *data;
|
||||
guchar *src, *s;
|
||||
gchar *name;
|
||||
gboolean has_alpha;
|
||||
gint rowstride, yend;
|
||||
gint i, j;
|
||||
|
||||
drawable = gimp_drawable_get (drawable_ID);
|
||||
drawable_type = gimp_drawable_type (drawable_ID);
|
||||
|
@ -1245,19 +1251,22 @@ save_image (gchar *filename,
|
|||
case GIMP_GRAY_IMAGE:
|
||||
/* # of color components per pixel */
|
||||
cinfo.input_components = drawable->bpp;
|
||||
has_alpha = 0;
|
||||
has_alpha = FALSE;
|
||||
break;
|
||||
|
||||
case GIMP_RGBA_IMAGE:
|
||||
case GIMP_GRAYA_IMAGE:
|
||||
/*gimp_message ("jpeg: image contains a-channel info which will be lost");*/
|
||||
/* # of color components per pixel (minus the GIMP alpha channel) */
|
||||
cinfo.input_components = drawable->bpp - 1;
|
||||
has_alpha = 1;
|
||||
has_alpha = TRUE;
|
||||
break;
|
||||
|
||||
case GIMP_INDEXED_IMAGE:
|
||||
/*gimp_message ("jpeg: cannot operate on indexed color images");*/
|
||||
return FALSE;
|
||||
break;
|
||||
|
||||
default:
|
||||
/*gimp_message ("jpeg: cannot operate on unknown image types");*/
|
||||
return FALSE;
|
||||
|
@ -1282,8 +1291,8 @@ save_image (gchar *filename,
|
|||
*/
|
||||
jpeg_set_defaults (&cinfo);
|
||||
|
||||
jpeg_set_quality (&cinfo, (int) (jsvals.quality * 100), jsvals.baseline);
|
||||
cinfo.smoothing_factor = (int) (jsvals.smoothing * 100);
|
||||
jpeg_set_quality (&cinfo, (gint) (jsvals.quality * 100), jsvals.baseline);
|
||||
cinfo.smoothing_factor = (gint) (jsvals.smoothing * 100);
|
||||
cinfo.optimize_coding = jsvals.optimize;
|
||||
|
||||
#ifdef HAVE_PROGRESSIVE_JPEG
|
||||
|
@ -1304,6 +1313,7 @@ save_image (gchar *filename,
|
|||
cinfo.comp_info[2].h_samp_factor = 1;
|
||||
cinfo.comp_info[2].v_samp_factor = 1;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
cinfo.comp_info[0].h_samp_factor = 2;
|
||||
cinfo.comp_info[0].v_samp_factor = 1;
|
||||
|
@ -1312,6 +1322,7 @@ save_image (gchar *filename,
|
|||
cinfo.comp_info[2].h_samp_factor = 1;
|
||||
cinfo.comp_info[2].v_samp_factor = 1;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
cinfo.comp_info[0].h_samp_factor = 1;
|
||||
cinfo.comp_info[0].v_samp_factor = 1;
|
||||
|
@ -1331,9 +1342,11 @@ save_image (gchar *filename,
|
|||
default:
|
||||
cinfo.dct_method = JDCT_ISLOW;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
cinfo.dct_method = JDCT_IFAST;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
cinfo.dct_method = JDCT_FLOAT;
|
||||
break;
|
||||
|
@ -1432,7 +1445,7 @@ save_image (gchar *filename,
|
|||
|
||||
jerr.pub.error_exit = background_error_exit;
|
||||
|
||||
gtk_idle_add ((GtkFunction) background_jpeg_save, (gpointer *)pp);
|
||||
gtk_idle_add ((GtkFunction) background_jpeg_save, (gpointer) pp);
|
||||
|
||||
/* background_jpeg_save() will cleanup as needed */
|
||||
return TRUE;
|
||||
|
@ -1525,21 +1538,25 @@ destroy_preview (void)
|
|||
{
|
||||
*abort_me = TRUE; /* signal the background save to stop */
|
||||
}
|
||||
|
||||
if (drawable_global)
|
||||
{
|
||||
gimp_drawable_detach (drawable_global);
|
||||
drawable_global = NULL;
|
||||
}
|
||||
|
||||
if (layer_ID_global != -1 && image_ID_global != -1)
|
||||
{
|
||||
/* assuming that reference counting is working correctly,
|
||||
we do not need to delete the layer, removing it from
|
||||
the image should be sufficient */
|
||||
gimp_image_remove_layer (image_ID_global, layer_ID_global);
|
||||
|
||||
/* gimp_layer_delete(layer_ID_global); */
|
||||
layer_ID_global = -1;
|
||||
}
|
||||
}
|
||||
|
||||
static gint
|
||||
static gboolean
|
||||
save_dialog (void)
|
||||
{
|
||||
GtkWidget *dlg;
|
||||
|
@ -1858,6 +1875,7 @@ save_ok_callback (GtkWidget *widget,
|
|||
gpointer data)
|
||||
{
|
||||
GtkWidget *text;
|
||||
|
||||
jsint.run = TRUE;
|
||||
|
||||
/* pw - get the comment text object and grab it's data */
|
||||
|
@ -1898,7 +1916,7 @@ save_restart_update (GtkAdjustment *adjustment,
|
|||
|
||||
static void
|
||||
menu_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
gpointer data)
|
||||
{
|
||||
gimp_menu_item_update (widget, data);
|
||||
make_preview ();
|
||||
|
|
|
@ -194,7 +194,7 @@ typedef struct
|
|||
struct jpeg_compress_struct cinfo;
|
||||
gint tile_height;
|
||||
FILE *outfile;
|
||||
gint has_alpha;
|
||||
gboolean has_alpha;
|
||||
gint rowstride;
|
||||
guchar *temp;
|
||||
guchar *data;
|
||||
|
@ -210,37 +210,37 @@ static gboolean *abort_me = NULL;
|
|||
|
||||
/* Declare local functions.
|
||||
*/
|
||||
static void query (void);
|
||||
static void run (gchar *name,
|
||||
gint nparams,
|
||||
GimpParam *param,
|
||||
gint *nreturn_vals,
|
||||
GimpParam **return_vals);
|
||||
static gint32 load_image (gchar *filename,
|
||||
GimpRunModeType runmode,
|
||||
gboolean preview);
|
||||
static gint save_image (gchar *filename,
|
||||
gint32 image_ID,
|
||||
gint32 drawable_ID,
|
||||
gint32 orig_image_ID,
|
||||
gboolean preview);
|
||||
static void query (void);
|
||||
static void run (gchar *name,
|
||||
gint nparams,
|
||||
GimpParam *param,
|
||||
gint *nreturn_vals,
|
||||
GimpParam **return_vals);
|
||||
static gint32 load_image (gchar *filename,
|
||||
GimpRunModeType runmode,
|
||||
gboolean preview);
|
||||
static gboolean save_image (gchar *filename,
|
||||
gint32 image_ID,
|
||||
gint32 drawable_ID,
|
||||
gint32 orig_image_ID,
|
||||
gboolean preview);
|
||||
|
||||
static gint save_dialog (void);
|
||||
static gboolean save_dialog (void);
|
||||
|
||||
static void save_close_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void save_ok_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void save_restart_toggle_update (GtkWidget *toggle,
|
||||
GtkAdjustment *adjustment);
|
||||
static void save_restart_update (GtkAdjustment *adjustment,
|
||||
GtkWidget *toggle);
|
||||
static void save_close_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void save_ok_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void save_restart_toggle_update (GtkWidget *toggle,
|
||||
GtkAdjustment *adjustment);
|
||||
static void save_restart_update (GtkAdjustment *adjustment,
|
||||
GtkWidget *toggle);
|
||||
|
||||
static void make_preview (void);
|
||||
static void destroy_preview (void);
|
||||
static void make_preview (void);
|
||||
static void destroy_preview (void);
|
||||
|
||||
static void menu_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void menu_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
|
||||
|
||||
GimpPlugInInfo PLUG_IN_INFO =
|
||||
|
@ -347,24 +347,24 @@ query (void)
|
|||
}
|
||||
|
||||
static void
|
||||
run (gchar *name,
|
||||
gint nparams,
|
||||
run (gchar *name,
|
||||
gint nparams,
|
||||
GimpParam *param,
|
||||
gint *nreturn_vals,
|
||||
gint *nreturn_vals,
|
||||
GimpParam **return_vals)
|
||||
{
|
||||
static GimpParam values[2];
|
||||
GimpRunModeType run_mode;
|
||||
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
||||
gint32 image_ID;
|
||||
gint32 drawable_ID;
|
||||
gint32 orig_image_ID;
|
||||
gint32 display_ID = -1;
|
||||
static GimpParam values[2];
|
||||
GimpRunModeType run_mode;
|
||||
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
||||
gint32 image_ID;
|
||||
gint32 drawable_ID;
|
||||
gint32 orig_image_ID;
|
||||
gint32 display_ID = -1;
|
||||
#ifdef GIMP_HAVE_PARASITES
|
||||
GimpParasite *parasite;
|
||||
GimpParasite *parasite;
|
||||
#endif /* GIMP_HAVE_PARASITES */
|
||||
gint err;
|
||||
GimpExportReturnType export = GIMP_EXPORT_CANCEL;
|
||||
gboolean err;
|
||||
GimpExportReturnType export = GIMP_EXPORT_CANCEL;
|
||||
|
||||
run_mode = param[0].data.d_int32;
|
||||
|
||||
|
@ -622,7 +622,7 @@ run (gchar *name,
|
|||
static guint
|
||||
jpeg_getc (j_decompress_ptr cinfo)
|
||||
{
|
||||
struct jpeg_source_mgr * datasrc = cinfo->src;
|
||||
struct jpeg_source_mgr *datasrc = cinfo->src;
|
||||
|
||||
if (datasrc->bytes_in_buffer == 0)
|
||||
{
|
||||
|
@ -630,6 +630,7 @@ jpeg_getc (j_decompress_ptr cinfo)
|
|||
ERREXIT (cinfo, JERR_CANT_SUSPEND);
|
||||
}
|
||||
datasrc->bytes_in_buffer--;
|
||||
|
||||
return *datasrc->next_input_byte++;
|
||||
}
|
||||
|
||||
|
@ -647,8 +648,8 @@ static GString *local_image_comments = NULL;
|
|||
static boolean
|
||||
COM_handler (j_decompress_ptr cinfo)
|
||||
{
|
||||
int length;
|
||||
unsigned int ch;
|
||||
gint length;
|
||||
guint ch;
|
||||
|
||||
length = jpeg_getc (cinfo) << 8;
|
||||
length += jpeg_getc (cinfo);
|
||||
|
@ -700,22 +701,22 @@ load_image (gchar *filename,
|
|||
GimpRunModeType runmode,
|
||||
gboolean preview)
|
||||
{
|
||||
GimpPixelRgn pixel_rgn;
|
||||
GimpDrawable *drawable;
|
||||
gint32 volatile image_ID;
|
||||
gint32 layer_ID;
|
||||
GimpPixelRgn pixel_rgn;
|
||||
GimpDrawable *drawable;
|
||||
gint32 volatile image_ID;
|
||||
gint32 layer_ID;
|
||||
struct jpeg_decompress_struct cinfo;
|
||||
struct my_error_mgr jerr;
|
||||
FILE *infile;
|
||||
guchar *buf;
|
||||
guchar * volatile padded_buf = NULL;
|
||||
struct my_error_mgr jerr;
|
||||
FILE *infile;
|
||||
guchar *buf;
|
||||
guchar * volatile padded_buf = NULL;
|
||||
guchar **rowbuf;
|
||||
gchar *name;
|
||||
gint image_type;
|
||||
gint layer_type;
|
||||
gint tile_height;
|
||||
gint scanlines;
|
||||
gint i, start, end;
|
||||
gchar *name;
|
||||
gint image_type;
|
||||
gint layer_type;
|
||||
gint tile_height;
|
||||
gint scanlines;
|
||||
gint i, start, end;
|
||||
|
||||
#ifdef GIMP_HAVE_PARASITES
|
||||
JpegSaveVals local_save_vals;
|
||||
|
@ -723,7 +724,6 @@ load_image (gchar *filename,
|
|||
GimpParasite * volatile vals_parasite = NULL;
|
||||
#endif /* GIMP_HAVE_PARASITES */
|
||||
|
||||
|
||||
/* We set up the normal JPEG error routines. */
|
||||
cinfo.err = jpeg_std_error (&jerr.pub);
|
||||
jerr.pub.error_exit = my_error_exit;
|
||||
|
@ -778,46 +778,47 @@ load_image (gchar *filename,
|
|||
*/
|
||||
|
||||
#ifdef GIMP_HAVE_PARASITES
|
||||
if (!preview) {
|
||||
/* if we had any comments then make a parasite for them */
|
||||
if (local_image_comments && local_image_comments->len)
|
||||
{
|
||||
gchar *string = local_image_comments->str;
|
||||
g_string_free (local_image_comments, FALSE);
|
||||
local_image_comments = NULL;
|
||||
comment_parasite = gimp_parasite_new ("gimp-comment",
|
||||
GIMP_PARASITE_PERSISTENT,
|
||||
strlen (string) + 1, string);
|
||||
}
|
||||
else
|
||||
{
|
||||
comment_parasite = NULL;
|
||||
}
|
||||
|
||||
/* pw - figuring out what the saved values were is non-trivial.
|
||||
* They don't seem to be in the cinfo structure. For now, I will
|
||||
* just use the defaults, but if someone figures out how to derive
|
||||
* them this is the place to store them. */
|
||||
|
||||
local_save_vals.quality = DEFAULT_QUALITY;
|
||||
local_save_vals.smoothing = DEFAULT_SMOOTHING;
|
||||
local_save_vals.optimize = DEFAULT_OPTIMIZE;
|
||||
|
||||
if (!preview)
|
||||
{
|
||||
/* if we had any comments then make a parasite for them */
|
||||
if (local_image_comments && local_image_comments->len)
|
||||
{
|
||||
gchar *string = local_image_comments->str;
|
||||
g_string_free (local_image_comments, FALSE);
|
||||
local_image_comments = NULL;
|
||||
comment_parasite = gimp_parasite_new ("gimp-comment",
|
||||
GIMP_PARASITE_PERSISTENT,
|
||||
strlen (string) + 1, string);
|
||||
}
|
||||
else
|
||||
{
|
||||
comment_parasite = NULL;
|
||||
}
|
||||
|
||||
/* pw - figuring out what the saved values were is non-trivial.
|
||||
* They don't seem to be in the cinfo structure. For now, I will
|
||||
* just use the defaults, but if someone figures out how to derive
|
||||
* them this is the place to store them. */
|
||||
|
||||
local_save_vals.quality = DEFAULT_QUALITY;
|
||||
local_save_vals.smoothing = DEFAULT_SMOOTHING;
|
||||
local_save_vals.optimize = DEFAULT_OPTIMIZE;
|
||||
|
||||
#ifdef HAVE_PROGRESSIVE_JPEG
|
||||
local_save_vals.progressive = cinfo.progressive_mode;
|
||||
local_save_vals.progressive = cinfo.progressive_mode;
|
||||
#else
|
||||
local_save_vals.progressive = 0;
|
||||
local_save_vals.progressive = 0;
|
||||
#endif /* HAVE_PROGRESSIVE_JPEG */
|
||||
local_save_vals.baseline = DEFAULT_BASELINE;
|
||||
local_save_vals.subsmp = DEFAULT_SUBSMP; /* sg - this _is_ there, but I'm too lazy */
|
||||
local_save_vals.restart = DEFAULT_RESTART;
|
||||
local_save_vals.dct = DEFAULT_DCT;
|
||||
local_save_vals.preview = DEFAULT_PREVIEW;
|
||||
|
||||
vals_parasite = gimp_parasite_new ("jpeg-save-options", 0,
|
||||
sizeof (local_save_vals),
|
||||
&local_save_vals);
|
||||
}
|
||||
local_save_vals.baseline = DEFAULT_BASELINE;
|
||||
local_save_vals.subsmp = DEFAULT_SUBSMP; /* sg - this _is_ there, but I'm too lazy */
|
||||
local_save_vals.restart = DEFAULT_RESTART;
|
||||
local_save_vals.dct = DEFAULT_DCT;
|
||||
local_save_vals.preview = DEFAULT_PREVIEW;
|
||||
|
||||
vals_parasite = gimp_parasite_new ("jpeg-save-options", 0,
|
||||
sizeof (local_save_vals),
|
||||
&local_save_vals);
|
||||
}
|
||||
#endif /* GIMP_HAVE_PARASITES */
|
||||
|
||||
|
||||
|
@ -862,14 +863,17 @@ load_image (gchar *filename,
|
|||
image_type = GIMP_GRAY;
|
||||
layer_type = preview ? GIMP_GRAYA_IMAGE : GIMP_GRAY_IMAGE;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
image_type = GIMP_RGB;
|
||||
layer_type = preview ? GIMP_RGBA_IMAGE : GIMP_RGB_IMAGE;
|
||||
break;
|
||||
|
||||
default:
|
||||
g_message ("don't know how to load JPEGs\nwith %d color channels",
|
||||
cinfo.output_components);
|
||||
cinfo.output_components);
|
||||
gimp_quit ();
|
||||
break;
|
||||
}
|
||||
|
||||
if (preview)
|
||||
|
@ -885,10 +889,11 @@ load_image (gchar *filename,
|
|||
|
||||
if (preview)
|
||||
{
|
||||
layer_ID_global = layer_ID = gimp_layer_new (image_ID, _("JPEG preview"),
|
||||
cinfo.output_width,
|
||||
cinfo.output_height,
|
||||
layer_type, 100, GIMP_NORMAL_MODE);
|
||||
layer_ID_global = layer_ID =
|
||||
gimp_layer_new (image_ID, _("JPEG preview"),
|
||||
cinfo.output_width,
|
||||
cinfo.output_height,
|
||||
layer_type, 100, GIMP_NORMAL_MODE);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -951,23 +956,18 @@ load_image (gchar *filename,
|
|||
while (cinfo.output_scanline < cinfo.output_height)
|
||||
{
|
||||
start = cinfo.output_scanline;
|
||||
end = cinfo.output_scanline + tile_height;
|
||||
end = MIN (end, cinfo.output_height);
|
||||
end = cinfo.output_scanline + tile_height;
|
||||
end = MIN (end, cinfo.output_height);
|
||||
scanlines = end - start;
|
||||
|
||||
for (i = 0; i < scanlines; i++)
|
||||
jpeg_read_scanlines (&cinfo, (JSAMPARRAY) &rowbuf[i], 1);
|
||||
|
||||
/*
|
||||
for (i = start; i < end; i++)
|
||||
gimp_pixel_rgn_set_row (&pixel_rgn, tilerow[i - start], 0, i, drawable->width);
|
||||
*/
|
||||
|
||||
if (preview) /* Add a dummy alpha channel -- convert buf to padded_buf */
|
||||
{
|
||||
guchar *dest = padded_buf;
|
||||
guchar *src = buf;
|
||||
gint num = drawable->width * scanlines;
|
||||
gint num = drawable->width * scanlines;
|
||||
|
||||
switch (cinfo.output_components)
|
||||
{
|
||||
|
@ -978,6 +978,7 @@ load_image (gchar *filename,
|
|||
*(dest++) = 255;
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
for (i=0; i<num; i++)
|
||||
{
|
||||
|
@ -987,8 +988,10 @@ load_image (gchar *filename,
|
|||
*(dest++) = 255;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
g_warning ("JPEG - shouldn't have gotten here. Report to adam@gimp.org");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -997,7 +1000,8 @@ load_image (gchar *filename,
|
|||
|
||||
if (runmode != GIMP_RUN_NONINTERACTIVE)
|
||||
{
|
||||
gimp_progress_update ((double) cinfo.output_scanline / (double) cinfo.output_height);
|
||||
gimp_progress_update ((gdouble) cinfo.output_scanline /
|
||||
(gdouble) cinfo.output_height);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1046,6 +1050,7 @@ load_image (gchar *filename,
|
|||
gimp_image_parasite_attach (image_ID, comment_parasite);
|
||||
gimp_parasite_free (comment_parasite);
|
||||
}
|
||||
|
||||
if (vals_parasite)
|
||||
{
|
||||
gimp_image_parasite_attach (image_ID, vals_parasite);
|
||||
|
@ -1070,19 +1075,16 @@ background_error_exit (j_common_ptr cinfo)
|
|||
(*cinfo->err->output_message) (cinfo);
|
||||
}
|
||||
|
||||
static gint
|
||||
static gboolean
|
||||
background_jpeg_save (PreviewPersistent *pp)
|
||||
{
|
||||
guchar *t;
|
||||
guchar *s;
|
||||
gint i, j;
|
||||
gint yend;
|
||||
gint i, j;
|
||||
gint yend;
|
||||
|
||||
if (pp->abort_me || (pp->cinfo.next_scanline >= pp->cinfo.image_height))
|
||||
{
|
||||
struct stat buf;
|
||||
gchar temp[256];
|
||||
|
||||
/* clean up... */
|
||||
if (pp->abort_me)
|
||||
{
|
||||
|
@ -1099,11 +1101,15 @@ background_jpeg_save (PreviewPersistent *pp)
|
|||
g_free (pp->temp);
|
||||
g_free (pp->data);
|
||||
|
||||
if (pp->drawable) gimp_drawable_detach (pp->drawable);
|
||||
if (pp->drawable)
|
||||
gimp_drawable_detach (pp->drawable);
|
||||
|
||||
/* display the preview stuff */
|
||||
if (!pp->abort_me)
|
||||
{
|
||||
struct stat buf;
|
||||
gchar temp[128];
|
||||
|
||||
stat (pp->file_name, &buf);
|
||||
g_snprintf (temp, sizeof (temp),
|
||||
_("Size: %lu bytes (%02.01f kB)"),
|
||||
|
@ -1160,26 +1166,26 @@ background_jpeg_save (PreviewPersistent *pp)
|
|||
}
|
||||
}
|
||||
|
||||
static gint
|
||||
static gboolean
|
||||
save_image (gchar *filename,
|
||||
gint32 image_ID,
|
||||
gint32 drawable_ID,
|
||||
gint32 orig_image_ID,
|
||||
gboolean preview)
|
||||
{
|
||||
GimpPixelRgn pixel_rgn;
|
||||
GimpDrawable *drawable;
|
||||
GimpImageType drawable_type;
|
||||
GimpPixelRgn pixel_rgn;
|
||||
GimpDrawable *drawable;
|
||||
GimpImageType drawable_type;
|
||||
struct jpeg_compress_struct cinfo;
|
||||
struct my_error_mgr jerr;
|
||||
FILE * volatile outfile;
|
||||
guchar *temp, *t;
|
||||
guchar *data;
|
||||
guchar *src, *s;
|
||||
gchar *name;
|
||||
gint has_alpha;
|
||||
gint rowstride, yend;
|
||||
gint i, j;
|
||||
struct my_error_mgr jerr;
|
||||
FILE * volatile outfile;
|
||||
guchar *temp, *t;
|
||||
guchar *data;
|
||||
guchar *src, *s;
|
||||
gchar *name;
|
||||
gboolean has_alpha;
|
||||
gint rowstride, yend;
|
||||
gint i, j;
|
||||
|
||||
drawable = gimp_drawable_get (drawable_ID);
|
||||
drawable_type = gimp_drawable_type (drawable_ID);
|
||||
|
@ -1245,19 +1251,22 @@ save_image (gchar *filename,
|
|||
case GIMP_GRAY_IMAGE:
|
||||
/* # of color components per pixel */
|
||||
cinfo.input_components = drawable->bpp;
|
||||
has_alpha = 0;
|
||||
has_alpha = FALSE;
|
||||
break;
|
||||
|
||||
case GIMP_RGBA_IMAGE:
|
||||
case GIMP_GRAYA_IMAGE:
|
||||
/*gimp_message ("jpeg: image contains a-channel info which will be lost");*/
|
||||
/* # of color components per pixel (minus the GIMP alpha channel) */
|
||||
cinfo.input_components = drawable->bpp - 1;
|
||||
has_alpha = 1;
|
||||
has_alpha = TRUE;
|
||||
break;
|
||||
|
||||
case GIMP_INDEXED_IMAGE:
|
||||
/*gimp_message ("jpeg: cannot operate on indexed color images");*/
|
||||
return FALSE;
|
||||
break;
|
||||
|
||||
default:
|
||||
/*gimp_message ("jpeg: cannot operate on unknown image types");*/
|
||||
return FALSE;
|
||||
|
@ -1282,8 +1291,8 @@ save_image (gchar *filename,
|
|||
*/
|
||||
jpeg_set_defaults (&cinfo);
|
||||
|
||||
jpeg_set_quality (&cinfo, (int) (jsvals.quality * 100), jsvals.baseline);
|
||||
cinfo.smoothing_factor = (int) (jsvals.smoothing * 100);
|
||||
jpeg_set_quality (&cinfo, (gint) (jsvals.quality * 100), jsvals.baseline);
|
||||
cinfo.smoothing_factor = (gint) (jsvals.smoothing * 100);
|
||||
cinfo.optimize_coding = jsvals.optimize;
|
||||
|
||||
#ifdef HAVE_PROGRESSIVE_JPEG
|
||||
|
@ -1304,6 +1313,7 @@ save_image (gchar *filename,
|
|||
cinfo.comp_info[2].h_samp_factor = 1;
|
||||
cinfo.comp_info[2].v_samp_factor = 1;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
cinfo.comp_info[0].h_samp_factor = 2;
|
||||
cinfo.comp_info[0].v_samp_factor = 1;
|
||||
|
@ -1312,6 +1322,7 @@ save_image (gchar *filename,
|
|||
cinfo.comp_info[2].h_samp_factor = 1;
|
||||
cinfo.comp_info[2].v_samp_factor = 1;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
cinfo.comp_info[0].h_samp_factor = 1;
|
||||
cinfo.comp_info[0].v_samp_factor = 1;
|
||||
|
@ -1331,9 +1342,11 @@ save_image (gchar *filename,
|
|||
default:
|
||||
cinfo.dct_method = JDCT_ISLOW;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
cinfo.dct_method = JDCT_IFAST;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
cinfo.dct_method = JDCT_FLOAT;
|
||||
break;
|
||||
|
@ -1432,7 +1445,7 @@ save_image (gchar *filename,
|
|||
|
||||
jerr.pub.error_exit = background_error_exit;
|
||||
|
||||
gtk_idle_add ((GtkFunction) background_jpeg_save, (gpointer *)pp);
|
||||
gtk_idle_add ((GtkFunction) background_jpeg_save, (gpointer) pp);
|
||||
|
||||
/* background_jpeg_save() will cleanup as needed */
|
||||
return TRUE;
|
||||
|
@ -1525,21 +1538,25 @@ destroy_preview (void)
|
|||
{
|
||||
*abort_me = TRUE; /* signal the background save to stop */
|
||||
}
|
||||
|
||||
if (drawable_global)
|
||||
{
|
||||
gimp_drawable_detach (drawable_global);
|
||||
drawable_global = NULL;
|
||||
}
|
||||
|
||||
if (layer_ID_global != -1 && image_ID_global != -1)
|
||||
{
|
||||
/* assuming that reference counting is working correctly,
|
||||
we do not need to delete the layer, removing it from
|
||||
the image should be sufficient */
|
||||
gimp_image_remove_layer (image_ID_global, layer_ID_global);
|
||||
|
||||
/* gimp_layer_delete(layer_ID_global); */
|
||||
layer_ID_global = -1;
|
||||
}
|
||||
}
|
||||
|
||||
static gint
|
||||
static gboolean
|
||||
save_dialog (void)
|
||||
{
|
||||
GtkWidget *dlg;
|
||||
|
@ -1858,6 +1875,7 @@ save_ok_callback (GtkWidget *widget,
|
|||
gpointer data)
|
||||
{
|
||||
GtkWidget *text;
|
||||
|
||||
jsint.run = TRUE;
|
||||
|
||||
/* pw - get the comment text object and grab it's data */
|
||||
|
@ -1898,7 +1916,7 @@ save_restart_update (GtkAdjustment *adjustment,
|
|||
|
||||
static void
|
||||
menu_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
gpointer data)
|
||||
{
|
||||
gimp_menu_item_update (widget, data);
|
||||
make_preview ();
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
2000-12-03 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* de.po: updated german translation
|
||||
|
||||
2000-11-24 Christophe Merlet <redfox@eikonex.org>
|
||||
|
||||
* fr.po: updated French translation.
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue