Commit 91b78678 authored by Sven Neumann's avatar Sven Neumann

correctly initialize the bumpmap offsets

* plug-ins/common/bumpmap.c: correctly initialize the bumpmap
  offsets

* plug-ins/common/png.c: (load_image) if the PNG cannot be loaded,
  return -1 instead of some uninitialized integer


--Sven
parent f622c868
2000-04-20 Sven Neumann <sven@gimp.org>
* plug-ins/common/bumpmap.c: correctly initialize the bumpmap
offsets
* plug-ins/common/png.c: (load_image) if the PNG cannot be loaded,
return -1 instead of some uninitialized integer
2000-04-20 Michael Natterer <mitch@gimp.org> 2000-04-20 Michael Natterer <mitch@gimp.org>
* gimprc.in * gimprc.in
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
/* Version 3.0-pre1-ac2: /* Version 3.0-pre1-ac2:
* *
* - waterlevel/ambient restricted to 0-255 * - waterlevel/ambient restricted to 0-255
* - correctly initialize bumpmap_offsets
*/ */
/* Version 3.0-pre1-ac1: /* Version 3.0-pre1-ac1:
...@@ -236,7 +237,7 @@ static void bumpmap_convert_row (guchar *row, ...@@ -236,7 +237,7 @@ static void bumpmap_convert_row (guchar *row,
static gint bumpmap_dialog (void); static gint bumpmap_dialog (void);
static void dialog_init_preview (void); static void dialog_init_preview (void);
static void dialog_new_bumpmap (void); static void dialog_new_bumpmap (gboolean init_offsets);
static void dialog_update_preview (void); static void dialog_update_preview (void);
static gint dialog_preview_events (GtkWidget *widget, GdkEvent *event); static gint dialog_preview_events (GtkWidget *widget, GdkEvent *event);
static void dialog_scroll_src (void); static void dialog_scroll_src (void);
...@@ -429,7 +430,7 @@ run (gchar *name, ...@@ -429,7 +430,7 @@ run (gchar *name,
case RUN_INTERACTIVE: case RUN_INTERACTIVE:
/* Possibly retrieve data */ /* Possibly retrieve data */
gimp_get_data (name, &bmvals); gimp_get_data (name, &bmvals);
/* Get information from the dialog */ /* Get information from the dialog */
if (!bumpmap_dialog ()) if (!bumpmap_dialog ())
return; return;
...@@ -691,14 +692,14 @@ bumpmap_row (guchar *src, ...@@ -691,14 +692,14 @@ bumpmap_row (guchar *src,
gboolean row_in_bumpmap, gboolean row_in_bumpmap,
bumpmap_params_t *params) bumpmap_params_t *params)
{ {
gint xofs1, xofs2, xofs3; gint xofs1, xofs2, xofs3;
gint shade; gint shade;
gint ndotl; gint ndotl;
gint nx, ny; gint nx, ny;
gint x, k; gint x, k;
gint pbpp; gint pbpp;
gint result; gint result;
gint tmp; gint tmp;
if (has_alpha) if (has_alpha)
pbpp = bpp - 1; pbpp = bpp - 1;
...@@ -1150,13 +1151,13 @@ dialog_init_preview (void) ...@@ -1150,13 +1151,13 @@ dialog_init_preview (void)
for (x = 0; x < bmint.preview_width; x++) for (x = 0; x < bmint.preview_width; x++)
if ((x / GIMP_CHECK_SIZE) & 1) if ((x / GIMP_CHECK_SIZE) & 1)
{ {
bmint.check_row_0[x] = GIMP_CHECK_DARK * 255; bmint.check_row_0[x] = GIMP_CHECK_DARK * 255;
bmint.check_row_1[x] = GIMP_CHECK_LIGHT * 255; bmint.check_row_1[x] = GIMP_CHECK_LIGHT * 255;
} }
else else
{ {
bmint.check_row_0[x] = GIMP_CHECK_LIGHT * 255; bmint.check_row_0[x] = GIMP_CHECK_LIGHT * 255;
bmint.check_row_1[x] = GIMP_CHECK_DARK * 255; bmint.check_row_1[x] = GIMP_CHECK_DARK * 255;
} }
/* Initialize source rows */ /* Initialize source rows */
...@@ -1300,9 +1301,8 @@ dialog_preview_events (GtkWidget *widget, ...@@ -1300,9 +1301,8 @@ dialog_preview_events (GtkWidget *widget,
} }
static void static void
dialog_new_bumpmap (void) dialog_new_bumpmap (gboolean init_offsets)
{ {
static gboolean first_call = TRUE;
GtkAdjustment *adj; GtkAdjustment *adj;
gint i; gint i;
gint yofs; gint yofs;
...@@ -1329,7 +1329,7 @@ dialog_new_bumpmap (void) ...@@ -1329,7 +1329,7 @@ dialog_new_bumpmap (void)
bmint.bm_bpp = gimp_drawable_bpp (bmint.bm_drawable->id); bmint.bm_bpp = gimp_drawable_bpp (bmint.bm_drawable->id);
bmint.bm_has_alpha = gimp_drawable_has_alpha (bmint.bm_drawable->id); bmint.bm_has_alpha = gimp_drawable_has_alpha (bmint.bm_drawable->id);
if (!first_call || bmvals.bumpmap_id == -1) if (init_offsets)
{ {
gimp_drawable_offsets (bmint.bm_drawable->id, &bump_offset_x, &bump_offset_y); gimp_drawable_offsets (bmint.bm_drawable->id, &bump_offset_x, &bump_offset_y);
gimp_drawable_offsets (drawable->id, &draw_offset_x, &draw_offset_y); gimp_drawable_offsets (drawable->id, &draw_offset_x, &draw_offset_y);
...@@ -1338,9 +1338,6 @@ dialog_new_bumpmap (void) ...@@ -1338,9 +1338,6 @@ dialog_new_bumpmap (void)
bmvals.yofs = draw_offset_y - bump_offset_y; bmvals.yofs = draw_offset_y - bump_offset_y;
} }
if (first_call)
first_call = FALSE;
adj = (GtkAdjustment *) bmint.offset_adj_x; adj = (GtkAdjustment *) bmint.offset_adj_x;
if (adj) if (adj)
{ {
...@@ -1414,9 +1411,6 @@ dialog_update_preview (void) ...@@ -1414,9 +1411,6 @@ dialog_update_preview (void)
{ {
bumpmap_row (bmint.src_rows[y] + 4 * xofs, dest_row, bumpmap_row (bmint.src_rows[y] + 4 * xofs, dest_row,
bmint.preview_width, 4, TRUE, bmint.preview_width, 4, TRUE,
/* bmint.bm_rows[(y + sel_y1) % bmint.bm_height], */
/* bmint.bm_rows[(y + sel_y1 + 1) % bmint.bm_height], */
/* bmint.bm_rows[(y + sel_y1 + 2) % bmint.bm_height], */
bmint.bm_rows[y], bmint.bm_rows[y],
bmint.bm_rows[y + 1], bmint.bm_rows[y + 1],
bmint.bm_rows[y + 2], bmint.bm_rows[y + 2],
...@@ -1792,8 +1786,15 @@ static void ...@@ -1792,8 +1786,15 @@ static void
dialog_bumpmap_callback (gint32 id, dialog_bumpmap_callback (gint32 id,
gpointer data) gpointer data)
{ {
bmvals.bumpmap_id = id; if (bmvals.bumpmap_id == id)
dialog_new_bumpmap (); {
dialog_new_bumpmap (FALSE);
}
else
{
bmvals.bumpmap_id = id;
dialog_new_bumpmap (TRUE);
}
dialog_update_preview (); dialog_update_preview ();
} }
......
...@@ -398,13 +398,9 @@ load_image (gchar *filename) /* I - File to load */ ...@@ -398,13 +398,9 @@ load_image (gchar *filename) /* I - File to load */
if (setjmp (pp->jmpbuf)) if (setjmp (pp->jmpbuf))
{ {
g_message (_("%s\nPNG error. File corrupted?"), filename); g_message (_("%s\nPNG error. File corrupted?"), filename);
return image; return -1;
} }
/* initialise variables here, thus avoiding compiler warnings */
image= -1;
/* /*
* Open the file and initialize the PNG read "engine"... * Open the file and initialize the PNG read "engine"...
*/ */
......
2000-04-20 Sven Neumann <sven@gimp.org>
* de.po: updated german translation
2000-04-19 Sven Neumann <sven@gimp.org> 2000-04-19 Sven Neumann <sven@gimp.org>
* de.po: updated german translation * de.po: updated german translation
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment