Commit 93eb30f6 authored by Sven Neumann's avatar Sven Neumann
Browse files

I am stupid. Dropping the 4-byte alignment caused the

buffer's rowstride to become different from the
GtkPreview's one. Fixed it by using preview->rowstride
in all cases.


--Sven
parent f7a95205
2000-05-23 Sven Neumann <sven@gimp.org>
* plug-ins/common/flarefx.c
* plug-ins/common/glasstile.c
* plug-ins/common/grid.c
* plug-ins/common/illusion.c
* plug-ins/common/jigsaw.c
* plug-ins/common/max_rgb.c
* plug-ins/common/noisify.c
* plug-ins/common/nova.c
* plug-ins/common/plasma.c: I am stupid. Dropping the
4-byte alignment caused the buffer's rowstride to
become different from the GtkPreview's one. Fixed it
by using preview->rowstride in all cases.
2000-05-23 Sven Neumann <sven@gimp.org> 2000-05-23 Sven Neumann <sven@gimp.org>
   
* plug-ins/common/plasma.c: applied modified version of * plug-ins/common/plasma.c: applied modified version of
......
...@@ -215,7 +215,7 @@ query (void) ...@@ -215,7 +215,7 @@ query (void)
"Karl-Johan Andersson", /* Copyright */ "Karl-Johan Andersson", /* Copyright */
"May 2000", "May 2000",
N_("<Image>/Filters/Light Effects/FlareFX..."), N_("<Image>/Filters/Light Effects/FlareFX..."),
"RGB", "RGB*",
PROC_PLUG_IN, PROC_PLUG_IN,
nargs, 0, nargs, 0,
args, NULL); args, NULL);
...@@ -411,15 +411,20 @@ FlareFX (GDrawable *drawable, ...@@ -411,15 +411,20 @@ FlareFX (GDrawable *drawable,
} }
matt = width; matt = width;
/* allocate row buffers */
cur_row = g_new (guchar, (x2 - x1) * bytes);
dest = g_new (guchar, (x2 - x1) * bytes);
if (!preview_mode) if (preview_mode)
{ {
cur_row = g_new (guchar, GTK_PREVIEW (preview)->rowstride);
dest = g_new (guchar, GTK_PREVIEW (preview)->rowstride);
}
else
{
/* initialize the pixel regions */ /* initialize the pixel regions */
gimp_pixel_rgn_init (&srcPR, drawable, 0, 0, width, height, FALSE, FALSE); gimp_pixel_rgn_init (&srcPR, drawable, 0, 0, width, height, FALSE, FALSE);
gimp_pixel_rgn_init (&destPR, drawable, 0, 0, width, height, TRUE, TRUE); gimp_pixel_rgn_init (&destPR, drawable, 0, 0, width, height, TRUE, TRUE);
cur_row = g_new (guchar, (x2 - x1) * bytes);
dest = g_new (guchar, (x2 - x1) * bytes);
} }
scolor = (gfloat)matt * 0.0375; scolor = (gfloat)matt * 0.0375;
...@@ -440,7 +445,9 @@ FlareFX (GDrawable *drawable, ...@@ -440,7 +445,9 @@ FlareFX (GDrawable *drawable,
for (row = y1; row < y2; row++) /* y-coord */ for (row = y1; row < y2; row++) /* y-coord */
{ {
if (preview_mode) if (preview_mode)
memcpy(cur_row,preview_bits+(width*bytes*row),width*bytes); memcpy (cur_row,
preview_bits + GTK_PREVIEW (preview)->rowstride * row,
GTK_PREVIEW (preview)->rowstride);
else else
gimp_pixel_rgn_get_row (&srcPR, cur_row, x1, row, x2-x1); gimp_pixel_rgn_get_row (&srcPR, cur_row, x1, row, x2-x1);
...@@ -476,8 +483,9 @@ FlareFX (GDrawable *drawable, ...@@ -476,8 +483,9 @@ FlareFX (GDrawable *drawable,
} }
if (preview_mode) if (preview_mode)
{ {
memcpy (GTK_PREVIEW (preview)->buffer + (width * bytes * row), memcpy (GTK_PREVIEW (preview)->buffer + GTK_PREVIEW (preview)->rowstride * row,
cur_row, width * bytes); cur_row,
GTK_PREVIEW (preview)->rowstride);
} }
else else
{ {
...@@ -880,9 +888,7 @@ preview_widget (GDrawable *drawable) ...@@ -880,9 +888,7 @@ preview_widget (GDrawable *drawable)
preview = gtk_preview_new (GTK_PREVIEW_COLOR); preview = gtk_preview_new (GTK_PREVIEW_COLOR);
fill_preview_with_thumb (preview, drawable->id); fill_preview_with_thumb (preview, drawable->id);
size = (GTK_PREVIEW (preview)->buffer_width) * size = GTK_PREVIEW (preview)->rowstride * GTK_PREVIEW (preview)->buffer_height;
(GTK_PREVIEW (preview)->buffer_height) *
(GTK_PREVIEW (preview)->bpp);
preview_bits = g_malloc (size); preview_bits = g_malloc (size);
memcpy (preview_bits, GTK_PREVIEW (preview)->buffer, size); memcpy (preview_bits, GTK_PREVIEW (preview)->buffer, size);
......
...@@ -349,9 +349,7 @@ preview_widget (GDrawable *drawable) ...@@ -349,9 +349,7 @@ preview_widget (GDrawable *drawable)
preview = gtk_preview_new (GTK_PREVIEW_COLOR); preview = gtk_preview_new (GTK_PREVIEW_COLOR);
fill_preview_with_thumb (preview, drawable->id); fill_preview_with_thumb (preview, drawable->id);
size = (GTK_PREVIEW (preview)->buffer_width) * size = GTK_PREVIEW (preview)->rowstride * GTK_PREVIEW (preview)->buffer_height;
(GTK_PREVIEW (preview)->buffer_height) *
(GTK_PREVIEW (preview)->bpp);
preview_bits = g_malloc (size); preview_bits = g_malloc (size);
memcpy (preview_bits, GTK_PREVIEW (preview)->buffer, size); memcpy (preview_bits, GTK_PREVIEW (preview)->buffer, size);
...@@ -532,12 +530,18 @@ glasstile (GDrawable *drawable, ...@@ -532,12 +530,18 @@ glasstile (GDrawable *drawable,
if (preview_mode) if (preview_mode)
{ {
if (ypixel2 < height) if (ypixel2 < height)
memcpy (cur_row, preview_bits + (ypixel2 * width * bytes), width * bytes); memcpy (cur_row,
preview_bits + (ypixel2 * GTK_PREVIEW (preview)->rowstride),
GTK_PREVIEW (preview)->rowstride);
else else
memcpy (cur_row, preview_bits + ((y2 - 1) * width * bytes), width * bytes); memcpy (cur_row,
preview_bits + ((y2 - 1) * GTK_PREVIEW (preview)->rowstride),
GTK_PREVIEW (preview)->rowstride);
if (cbytes != bytes) /* Alpha check */ if (cbytes != bytes) /* Alpha check */
memcpy (ad, preview_bits + (row * width * bytes), width * bytes); memcpy (ad,
preview_bits + (row * GTK_PREVIEW (preview)->rowstride),
GTK_PREVIEW (preview)->rowstride);
} }
else else
{ {
...@@ -593,7 +597,9 @@ glasstile (GDrawable *drawable, ...@@ -593,7 +597,9 @@ glasstile (GDrawable *drawable,
/* Store the dest */ /* Store the dest */
if (preview_mode) if (preview_mode)
memcpy (GTK_PREVIEW (preview)->buffer + (width * bytes * row), dest, width * bytes); memcpy (GTK_PREVIEW (preview)->buffer + (GTK_PREVIEW (preview)->rowstride * row),
dest,
GTK_PREVIEW (preview)->rowstride);
else else
gimp_pixel_rgn_set_row (&destPR, dest, x1, row, iwidth); gimp_pixel_rgn_set_row (&destPR, dest, x1, row, iwidth);
...@@ -617,3 +623,7 @@ glasstile (GDrawable *drawable, ...@@ -617,3 +623,7 @@ glasstile (GDrawable *drawable,
g_free (dest); g_free (dest);
g_free (ad); g_free (ad);
} }
...@@ -421,9 +421,11 @@ doit (gint32 image_ID, ...@@ -421,9 +421,11 @@ doit (gint32 image_ID,
for (y = sy1; y < sy2; y++) for (y = sy1; y < sy2; y++)
{ {
if (preview_mode) if (preview_mode)
memcpy(dest, preview_bits + (sx2 * bytes * y), sx2 * bytes); memcpy (dest,
preview_bits + (GTK_PREVIEW (preview)->rowstride * y),
GTK_PREVIEW (preview)->rowstride);
else else
gimp_pixel_rgn_get_row (&srcPR, dest, sx1, y, (sx2-sx1)); gimp_pixel_rgn_get_row (&srcPR, dest, sx1, y, (sx2 - sx1));
y_offset = y - grid_cfg.voffset; y_offset = y - grid_cfg.voffset;
while (y_offset < 0) while (y_offset < 0)
...@@ -484,7 +486,9 @@ doit (gint32 image_ID, ...@@ -484,7 +486,9 @@ doit (gint32 image_ID,
} }
if (preview_mode) if (preview_mode)
{ {
memcpy(GTK_PREVIEW (preview)->buffer+(sx2*bytes*y),dest,sx2*bytes); memcpy (GTK_PREVIEW (preview)->buffer + GTK_PREVIEW (preview)->rowstride,
dest,
GTK_PREVIEW (preview)->rowstride);
} }
else else
{ {
...@@ -983,9 +987,7 @@ preview_widget (GDrawable *drawable) ...@@ -983,9 +987,7 @@ preview_widget (GDrawable *drawable)
{ {
preview = gtk_preview_new (GTK_PREVIEW_COLOR); preview = gtk_preview_new (GTK_PREVIEW_COLOR);
fill_preview (preview, drawable); fill_preview (preview, drawable);
size = (GTK_PREVIEW (preview)->buffer_width) * size = GTK_PREVIEW (preview)->rowstride * GTK_PREVIEW (preview)->buffer_height;
(GTK_PREVIEW (preview)->buffer_height) *
(GTK_PREVIEW (preview)->bpp);
preview_bits = g_malloc (size); preview_bits = g_malloc (size);
memcpy (preview_bits, GTK_PREVIEW (preview)->buffer, size); memcpy (preview_bits, GTK_PREVIEW (preview)->buffer, size);
} }
......
...@@ -327,10 +327,11 @@ filter_preview (void) ...@@ -327,10 +327,11 @@ filter_preview (void)
for (y = 0; y < image_height; y++) for (y = 0; y < image_height; y++)
{ {
pixels[y] = g_new (guchar, image_width * image_bpp); pixels[y] = g_new (guchar, GTK_PREVIEW (preview)->rowstride);
destpixels[y] = g_new (guchar, image_width * image_bpp); destpixels[y] = g_new (guchar, GTK_PREVIEW (preview)->rowstride);
memcpy (pixels[y], preview_bits + (image_width * image_bpp * y), memcpy (pixels[y],
image_width * image_bpp); preview_bits + GTK_PREVIEW (preview)->rowstride * y,
GTK_PREVIEW (preview)->rowstride);
} }
scale = sqrt (image_width * image_width + image_height * image_height) / 2; scale = sqrt (image_width * image_width + image_height * image_height) / 2;
...@@ -373,8 +374,9 @@ filter_preview (void) ...@@ -373,8 +374,9 @@ filter_preview (void)
(1-radius) * pixels[y][x * image_bpp + b] (1-radius) * pixels[y][x * image_bpp + b]
+ radius * pixels[yy][xx * image_bpp + b]; + radius * pixels[yy][xx * image_bpp + b];
} }
memcpy (GTK_PREVIEW (preview)->buffer + (image_width * image_bpp * y), memcpy (GTK_PREVIEW (preview)->buffer + GTK_PREVIEW (preview)->rowstride * y,
destpixels[y], image_width * image_bpp); destpixels[y],
GTK_PREVIEW (preview)->rowstride);
} }
for (y = 0; y < image_height; y++) for (y = 0; y < image_height; y++)
...@@ -396,9 +398,7 @@ preview_widget (GDrawable *drawable) ...@@ -396,9 +398,7 @@ preview_widget (GDrawable *drawable)
preview = gtk_preview_new (GTK_PREVIEW_COLOR); preview = gtk_preview_new (GTK_PREVIEW_COLOR);
fill_preview_with_thumb (preview, drawable->id); fill_preview_with_thumb (preview, drawable->id);
size = (GTK_PREVIEW (preview)->buffer_width) * size = GTK_PREVIEW (preview)->rowstride * GTK_PREVIEW (preview)->buffer_height;
(GTK_PREVIEW (preview)->buffer_height) *
(GTK_PREVIEW (preview)->bpp);
preview_bits = g_malloc (size); preview_bits = g_malloc (size);
memcpy (preview_bits, GTK_PREVIEW (preview)->buffer, size); memcpy (preview_bits, GTK_PREVIEW (preview)->buffer, size);
......
This diff is collapsed.
...@@ -232,15 +232,15 @@ main_function (GDrawable *drawable, ...@@ -232,15 +232,15 @@ main_function (GDrawable *drawable,
I just don't want to write a prev_pixel_rgn_process I just don't want to write a prev_pixel_rgn_process
and then find out someone else coded a much cooler and then find out someone else coded a much cooler
preview widget / functions for GIMP */ preview widget / functions for GIMP */
src_data = g_malloc (x2 * y2 * bpp); src_data = g_malloc (GTK_PREVIEW (preview)->rowstride * y2);
memcpy (src_data, preview_bits, x2 * y2 * bpp); memcpy (src_data, preview_bits, GTK_PREVIEW (preview)->rowstride * y2);
dest_data = g_malloc (x2 * y2 * bpp); dest_data = g_malloc (GTK_PREVIEW (preview)->rowstride * y2);
save_dest = dest_data; save_dest = dest_data;
for (y = 0; y < y2; y++) for (y = 0; y < y2; y++)
{ {
src = src_data + y * x2 * bpp; src = src_data + y * GTK_PREVIEW (preview)->rowstride;
dest = dest_data + y * x2 * bpp; dest = dest_data + y * GTK_PREVIEW (preview)->rowstride;
for (x = 0; x < x2; x++) for (x = 0; x < x2; x++)
{ {
...@@ -266,11 +266,11 @@ main_function (GDrawable *drawable, ...@@ -266,11 +266,11 @@ main_function (GDrawable *drawable,
*dest++ = (guchar)(((max_ch & (1 << ch)) > 0) ? max : 0); *dest++ = (guchar)(((max_ch & (1 << ch)) > 0) ? max : 0);
if (gap) if (gap)
*dest++=*src++; *dest++ = *src++;
} }
} }
memcpy (GTK_PREVIEW (preview)->buffer, save_dest, x2 * y2 * bpp); memcpy (GTK_PREVIEW (preview)->buffer, save_dest, GTK_PREVIEW (preview)->rowstride * y2);
gtk_widget_queue_draw (preview); gtk_widget_queue_draw (preview);
} }
else else
...@@ -428,9 +428,7 @@ preview_widget (GDrawable *drawable) ...@@ -428,9 +428,7 @@ preview_widget (GDrawable *drawable)
preview = gtk_preview_new (GTK_PREVIEW_COLOR); preview = gtk_preview_new (GTK_PREVIEW_COLOR);
fill_preview_with_thumb (preview, drawable->id); fill_preview_with_thumb (preview, drawable->id);
size = (GTK_PREVIEW (preview)->buffer_width) * size = GTK_PREVIEW (preview)->rowstride * GTK_PREVIEW (preview)->buffer_height;
(GTK_PREVIEW (preview)->buffer_height) *
(GTK_PREVIEW (preview)->bpp);
preview_bits = g_malloc (size); preview_bits = g_malloc (size);
memcpy (preview_bits, GTK_PREVIEW (preview)->buffer, size); memcpy (preview_bits, GTK_PREVIEW (preview)->buffer, size);
......
...@@ -276,15 +276,15 @@ noisify (GDrawable *drawable, ...@@ -276,15 +276,15 @@ noisify (GDrawable *drawable,
if (preview_mode) if (preview_mode)
{ {
src_data = g_malloc (x2 * y2 * bpp); src_data = g_malloc (GTK_PREVIEW (preview)->rowstride * y2);
memcpy (src_data, preview_bits, x2 * y2 * bpp); memcpy (src_data, preview_bits, GTK_PREVIEW (preview)->rowstride * y2);
dest_data = g_malloc (x2 * y2 * bpp); dest_data = g_malloc (GTK_PREVIEW (preview)->rowstride * y2);
save_dest = dest_data; save_dest = dest_data;
for (row = 0; row < y2; row++) for (row = 0; row < y2; row++)
{ {
src = src_data + row * x2 * bpp; src = src_data + row * GTK_PREVIEW (preview)->rowstride;
dest = dest_data + row * x2 * bpp; dest = dest_data + row * GTK_PREVIEW (preview)->rowstride;
for (col = 0; col < x2; col++) for (col = 0; col < x2; col++)
{ {
...@@ -314,7 +314,9 @@ noisify (GDrawable *drawable, ...@@ -314,7 +314,9 @@ noisify (GDrawable *drawable,
} }
} }
memcpy (GTK_PREVIEW(preview)->buffer, save_dest, x2 * y2 * bpp); memcpy (GTK_PREVIEW (preview)->buffer,
save_dest,
GTK_PREVIEW (preview)->rowstride * y2);
gtk_widget_queue_draw (preview); gtk_widget_queue_draw (preview);
} }
else else
...@@ -664,9 +666,7 @@ preview_widget (GDrawable *drawable) ...@@ -664,9 +666,7 @@ preview_widget (GDrawable *drawable)
preview = gtk_preview_new (GTK_PREVIEW_COLOR); preview = gtk_preview_new (GTK_PREVIEW_COLOR);
fill_preview (preview, drawable); fill_preview (preview, drawable);
size = (GTK_PREVIEW (preview)->buffer_width) * size = GTK_PREVIEW (preview)->rowstride * GTK_PREVIEW (preview)->buffer_height;
(GTK_PREVIEW (preview)->buffer_height) *
(GTK_PREVIEW (preview)->bpp);
preview_bits = g_malloc (size); preview_bits = g_malloc (size);
memcpy (preview_bits, GTK_PREVIEW (preview)->buffer, size); memcpy (preview_bits, GTK_PREVIEW (preview)->buffer, size);
......
...@@ -337,9 +337,7 @@ preview_widget (GDrawable *drawable) ...@@ -337,9 +337,7 @@ preview_widget (GDrawable *drawable)
preview = gtk_preview_new (GTK_PREVIEW_COLOR); preview = gtk_preview_new (GTK_PREVIEW_COLOR);
fill_preview_with_thumb (preview, drawable->id); fill_preview_with_thumb (preview, drawable->id);
size = (GTK_PREVIEW (preview)->buffer_width) * size = GTK_PREVIEW (preview)->rowstride * GTK_PREVIEW (preview)->buffer_height;
(GTK_PREVIEW (preview)->buffer_height) *
(GTK_PREVIEW (preview)->bpp);
preview_bits = g_malloc (size); preview_bits = g_malloc (size);
memcpy (preview_bits, GTK_PREVIEW (preview)->buffer, size); memcpy (preview_bits, GTK_PREVIEW (preview)->buffer, size);
...@@ -974,9 +972,9 @@ nova (GDrawable *drawable, ...@@ -974,9 +972,9 @@ nova (GDrawable *drawable,
stuff, i have to duplicate the stuff, i have to duplicate the
entire loop. why not just use entire loop. why not just use
get_row??? */ get_row??? */
src_row = g_malloc (x2 * y2 * bpp); src_row = g_malloc (y2 * GTK_PREVIEW (preview)->rowstride);
memcpy (src_row, preview_bits, x2 * y2 * bpp); memcpy (src_row, preview_bits, y2 * GTK_PREVIEW (preview)->rowstride);
dest_row = g_malloc (x2 * y2 * bpp); dest_row = g_malloc (y2 * GTK_PREVIEW (preview)->rowstride);
save_dest = dest_row; save_dest = dest_row;
for (row = 0, y = 0; row < y2; row++, y++) for (row = 0, y = 0; row < y2; row++, y++)
...@@ -1038,11 +1036,11 @@ nova (GDrawable *drawable, ...@@ -1038,11 +1036,11 @@ nova (GDrawable *drawable,
src += bpp; src += bpp;
dest += bpp; dest += bpp;
} }
src_row += x2*bpp; src_row += GTK_PREVIEW (preview)->rowstride;
dest_row += x2*bpp; dest_row += GTK_PREVIEW (preview)->rowstride;
} }
memcpy (GTK_PREVIEW(preview)->buffer, save_dest, x2 * y2 * bpp); memcpy (GTK_PREVIEW(preview)->buffer, save_dest, y2 * GTK_PREVIEW (preview)->rowstride);
gtk_widget_queue_draw (preview); gtk_widget_queue_draw (preview);
} }
else else
......
...@@ -465,8 +465,8 @@ init_plasma (GDrawable *drawable, ...@@ -465,8 +465,8 @@ init_plasma (GDrawable *drawable,
bpp = GTK_PREVIEW (preview)->bpp; bpp = GTK_PREVIEW (preview)->bpp;
alpha = bpp; alpha = bpp;
has_alpha = 0; has_alpha = 0;
work_buffer = g_malloc (ix2 * iy2 * bpp); work_buffer = g_malloc (GTK_PREVIEW (preview)->rowstride * iy2);
memcpy (work_buffer, GTK_PREVIEW (preview)->buffer, ix2 * iy2 * bpp); memcpy (work_buffer, GTK_PREVIEW (preview)->buffer, GTK_PREVIEW (preview)->rowstride * iy2);
} }
else else
{ {
...@@ -513,7 +513,7 @@ end_plasma (GDrawable *drawable, ...@@ -513,7 +513,7 @@ end_plasma (GDrawable *drawable,
{ {
if (preview_mode) if (preview_mode)
{ {
memcpy (GTK_PREVIEW (preview)->buffer, work_buffer, ix2 * iy2 * bpp); memcpy (GTK_PREVIEW (preview)->buffer, work_buffer, GTK_PREVIEW (preview)->rowstride * iy2);
g_free (work_buffer); g_free (work_buffer);
gtk_widget_queue_draw (preview); gtk_widget_queue_draw (preview);
} }
...@@ -547,7 +547,7 @@ get_pixel (GDrawable *drawable, ...@@ -547,7 +547,7 @@ get_pixel (GDrawable *drawable,
if (preview_mode) if (preview_mode)
{ {
memcpy (pixel, work_buffer + (y * ix2 * bpp) + (x * bpp), bpp); memcpy (pixel, work_buffer + (y * GTK_PREVIEW (preview)->rowstride) + (x * bpp), bpp);
} }
else else
{ {
...@@ -581,7 +581,7 @@ put_pixel (GDrawable *drawable, ...@@ -581,7 +581,7 @@ put_pixel (GDrawable *drawable,
if (y > iy2 - 1) y = iy2 - 1; if (y > iy2 - 1) y = iy2 - 1;
if (preview_mode) if (preview_mode)
memcpy (work_buffer + (y * ix2 * bpp) + (x * bpp), pixel, bpp); memcpy (work_buffer + (y * GTK_PREVIEW (preview)->rowstride) + (x * bpp), pixel, bpp);
else else
{ {
col = x / tile_width; col = x / tile_width;
...@@ -805,3 +805,4 @@ preview_widget (void) ...@@ -805,3 +805,4 @@ preview_widget (void)
return preview; return preview;
} }
...@@ -328,26 +328,31 @@ render_blast (GDrawable *drawable, ...@@ -328,26 +328,31 @@ render_blast (GDrawable *drawable,
x1 = y1 = 0; x1 = y1 = 0;
x2 = width; x2 = width;
y2 = height; y2 = height;
row_stride = GTK_PREVIEW (preview)->rowstride;
} }
else else
{ {
gimp_progress_init( _("Rendering Blast...")); gimp_progress_init( _("Rendering Blast..."));
gimp_drawable_mask_bounds (drawable->id, &x1, &y1, &x2, &y2); gimp_drawable_mask_bounds (drawable->id, &x1, &y1, &x2, &y2);
width = x2 - x1; width = x2 - x1;
height = y2 - y1; height = y2 - y1;
gimp_pixel_rgn_init (&src_region, drawable, x1, y1, width, height, FALSE, FALSE); gimp_pixel_rgn_init (&src_region, drawable, x1, y1, width, height, FALSE, FALSE);
gimp_pixel_rgn_init (&dest_region, drawable, x1, y1, width, height, TRUE, TRUE); gimp_pixel_rgn_init (&dest_region, drawable, x1, y1, width, height, TRUE, TRUE);
row_stride = width * bytes;
} }
row_stride = width * bytes;
lpi = row_stride - bytes; lpi = row_stride - bytes;
buffer = (guchar *) g_malloc(row_stride); buffer = (guchar *) g_malloc (row_stride);
for (row = y1; row < y2; row++) for (row = y1; row < y2; row++)
{ {
if (preview_mode) if (preview_mode)
memcpy (buffer, preview_bits + (row * bytes * width), width * bytes); memcpy (buffer, preview_bits + (row * row_stride), row_stride);
else else
gimp_pixel_rgn_get_row (&src_region, buffer, x1, row, width); gimp_pixel_rgn_get_row (&src_region, buffer, x1, row, width);
...@@ -365,7 +370,7 @@ render_blast (GDrawable *drawable, ...@@ -365,7 +370,7 @@ render_blast (GDrawable *drawable,
if (preview_mode) if (preview_mode)
{ {
memcpy (GTK_PREVIEW (preview)->buffer + (width * bytes * row), buffer, width * bytes); memcpy (GTK_PREVIEW (preview)->buffer + (row_stride * row), buffer, row_stride);
} }
else else
{ {
...@@ -385,9 +390,8 @@ render_blast (GDrawable *drawable, ...@@ -385,9 +390,8 @@ render_blast (GDrawable *drawable,
{ {
if (preview_mode)