[gimp/wip/wormnest/psp-mask: 4/4] plug-ins: convert endianness of bitmap/channel_count as soon as possible in file-psp.




commit 8ca941632d7a94d860218bb01a9528421a5f5642
Author: Jacob Boerema <jgboerema gmail com>
Date:   Tue Oct 6 11:40:49 2020 -0400

    plug-ins: convert endianness of bitmap/channel_count as soon as possible in file-psp.
    
    Conversion of endianness should happen as soon as possible inside the function
    where the values are read otherwise we get inconsistencies with certain
    values being converted right away and others not.

 plug-ins/common/file-psp.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/plug-ins/common/file-psp.c b/plug-ins/common/file-psp.c
index 9c90c1d414..c3441c8385 100644
--- a/plug-ins/common/file-psp.c
+++ b/plug-ins/common/file-psp.c
@@ -1928,6 +1928,8 @@ read_raster_layer_info (FILE      *f,
                      _("Error reading layer extension information"));
         return FALSE;
       }
+    *bitmap_count = GUINT16_FROM_LE (*bitmap_count);
+    *channel_count = GUINT16_FROM_LE (*channel_count);
     if (try_fseek (f, layer_extension_start + layer_extension_len, SEEK_SET, error) < 0)
       {
         return FALSE;
@@ -2163,6 +2165,8 @@ read_layer_block (FILE      *f,
           if (type == PSP_LAYER_FLOATING_SELECTION)
             g_message ("Floating selection restored as normal layer");
           type = keGLTRaster;
+          bitmap_count = GUINT16_FROM_LE (bitmap_count);
+          channel_count = GUINT16_FROM_LE (channel_count);
           can_handle_layer = TRUE;
           if (try_fseek (f, sub_block_start + sub_init_len, SEEK_SET, error) < 0)
             {
@@ -2175,8 +2179,6 @@ read_layer_block (FILE      *f,
       swab_rect (saved_image_rect);
       swab_rect (mask_rect);
       swab_rect (saved_mask_rect);
-      bitmap_count = GUINT16_FROM_LE (bitmap_count);
-      channel_count = GUINT16_FROM_LE (channel_count);
 
       layer_mode = gimp_layer_mode_from_psp_blend_mode (blend_mode);
       if ((int) layer_mode == -1)


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