[gimp] Fix crasher and behaviour in the GBR plugin for the GRAYA case.
- From: Simon Budig <simon src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gimp] Fix crasher and behaviour in the GBR plugin for the GRAYA case.
- Date: Fri, 2 Oct 2009 20:08:31 +0000 (UTC)
commit 73071e46181b85916b529f8e1690412821b9842f
Author: Simon Budig <simon budig de>
Date: Fri Oct 2 22:03:33 2009 +0200
Fix crasher and behaviour in the GBR plugin for the GRAYA case.
plug-ins/common/file-gbr.c | 19 ++++++++++++++++---
1 files changed, 16 insertions(+), 3 deletions(-)
---
diff --git a/plug-ins/common/file-gbr.c b/plug-ins/common/file-gbr.c
index bc1a747..badc06a 100644
--- a/plug-ins/common/file-gbr.c
+++ b/plug-ins/common/file-gbr.c
@@ -606,6 +606,9 @@ save_image (const gchar *filename,
gint x;
gint bpp;
GimpPixelRgn pixel_rgn;
+ GimpRGB gray, white;
+
+ gimp_rgba_set_uchar (&white, 255, 255, 255, 255);
switch (gimp_drawable_type (drawable_ID))
{
@@ -667,7 +670,7 @@ save_image (const gchar *filename,
0, 0, drawable->width, drawable->height,
FALSE, FALSE);
- buffer = g_new (guchar, drawable->width * bpp);
+ buffer = g_new (guchar, drawable->width * MAX (bpp, drawable->bpp));
for (line = 0; line < drawable->height; line++)
{
@@ -682,9 +685,19 @@ save_image (const gchar *filename,
break;
case 2:
- /* invert and drop alpha channel */
for (x = 0; x < drawable->width; x++)
- buffer[x] = 255 - buffer[2 * x];
+ {
+ /* apply alpha channel */
+ gimp_rgba_set_uchar (&gray,
+ buffer[2 * x],
+ buffer[2 * x],
+ buffer[2 * x],
+ buffer[2 * x + 1]);
+ gimp_rgb_composite (&gray, &white, GIMP_RGB_COMPOSITE_BEHIND);
+ gimp_rgba_get_uchar (&gray, &buffer[x], NULL, NULL, NULL);
+ /* invert */
+ buffer[x] = 255 - buffer[x];
+ }
break;
case 3:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]