gimp r27175 - in trunk: . plug-ins/file-psd



Author: martinn
Date: Wed Oct  8 18:00:48 2008
New Revision: 27175
URL: http://svn.gnome.org/viewvc/gimp?rev=27175&view=rev

Log:
Bug 555222 â PSD Load Plugin: unsupported compression mode

* plug-ins/file-psd/psd-load.c (add_layers): Some PSD files can
have channels where a compression method used for the channel data
is specified, but without any actual channel data. Handle this
case. Fix inspired by patch from Chris Mohler.


Modified:
   trunk/ChangeLog
   trunk/plug-ins/file-psd/psd-load.c

Modified: trunk/plug-ins/file-psd/psd-load.c
==============================================================================
--- trunk/plug-ins/file-psd/psd-load.c	(original)
+++ trunk/plug-ins/file-psd/psd-load.c	Wed Oct  8 18:00:48 2008
@@ -962,6 +962,7 @@
 {
   PSDchannel          **lyr_chn;
   guchar               *pixels;
+  guint16               comp_mode;
   guint16               alpha_chn;
   guint16               user_mask_chn;
   guint16               layer_channels;
@@ -1092,13 +1093,12 @@
                                 lyr_chn[cidx]->columns,
                                 lyr_chn[cidx]->rows);
 
-              /* Only read channel data if there is more data than
-               * what compression method that is used
+              /* Only read channel data if there is any channel
+               * data. Note that the channel data can contain a
+               * compression method but no actual data.
                */
-              if (lyr_a[lidx]->chn_info[cidx].data_len > COMP_MODE_SIZE)
+              if (lyr_a[lidx]->chn_info[cidx].data_len >= COMP_MODE_SIZE)
                 {
-                  guint16 comp_mode;
-
                   if (fread (&comp_mode, COMP_MODE_SIZE, 1, f) < 1)
                     {
                       psd_set_error (feof (f), errno, error);
@@ -1106,7 +1106,9 @@
                     }
                   comp_mode = GUINT16_FROM_BE (comp_mode);
                   IFDBG(3) g_debug ("Compression mode: %d", comp_mode);
-
+                }
+              if (lyr_a[lidx]->chn_info[cidx].data_len > COMP_MODE_SIZE)
+                {
                   switch (comp_mode)
                     {
                       case PSD_COMP_RAW:        /* Planar raw data */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]