[gimp] file-bmp: Use BITMAPV5HEADER structure (bug #649741)



commit b3a4a00d29a30385fec154853149a52f1a1a325f
Author: Mukund Sivaraman <muks banu com>
Date:   Sun May 8 22:57:39 2011 +0530

    file-bmp: Use BITMAPV5HEADER structure (bug #649741)

 plug-ins/file-bmp/bmp-write.c |   42 ++++++++++++++++++++++++++++++++++++----
 1 files changed, 37 insertions(+), 5 deletions(-)
---
diff --git a/plug-ins/file-bmp/bmp-write.c b/plug-ins/file-bmp/bmp-write.c
index f45554a..943fadc 100644
--- a/plug-ins/file-bmp/bmp-write.c
+++ b/plug-ins/file-bmp/bmp-write.c
@@ -154,7 +154,7 @@ WriteBMP (const gchar  *filename,
   GimpPixelRgn   pixel_rgn;
   GimpDrawable  *drawable;
   GimpImageType  drawable_type;
-  guchar         puffer[50];
+  guchar         puffer[128];
   gint           i;
   gint           mask_info_size;
   guint32        Mask[4];
@@ -331,11 +331,11 @@ WriteBMP (const gchar  *filename,
   else
     SpZeile = ((gint) (((Spcols * BitsPerPixel) / 8) / 4) + 1) * 4;
 
-  Bitmap_File_Head.bfSize    = 0x36 + MapSize + (rows * SpZeile) + mask_info_size;
+  Bitmap_File_Head.bfSize    = 0x36 + MapSize + (rows * SpZeile) + mask_info_size + (68 /* V5 color space */);
   Bitmap_File_Head.zzHotX    = 0;
   Bitmap_File_Head.zzHotY    = 0;
-  Bitmap_File_Head.bfOffs    = 0x36 + MapSize + mask_info_size;
-  Bitmap_File_Head.biSize    = 40 + (mask_info_size > 12 ? mask_info_size : 0);
+  Bitmap_File_Head.bfOffs    = 0x36 + MapSize + mask_info_size + 68;
+  Bitmap_File_Head.biSize    = 40 + mask_info_size + 68;
 
   Bitmap_Head.biWidth  = cols;
   Bitmap_Head.biHeight = rows;
@@ -421,7 +421,7 @@ WriteBMP (const gchar  *filename,
   Write (outfile, puffer, 36);
   write_color_map (outfile, Red, Green, Blue, MapSize);
 
-  if (mask_info_size)
+  if (mask_info_size > 0)
     {
       switch (BMPSaveData.rgb_format)
         {
@@ -470,6 +470,38 @@ WriteBMP (const gchar  *filename,
       Write (outfile, puffer, mask_info_size);
     }
 
+  /* Write V4 header colorspace fields */
+
+  /* bV5CSType = LCS_sRGB */
+  FromL (0x73524742, &puffer[0x00]);
+
+  /* bV5Endpoints is set to 0 (ignored) */
+  for (i = 0; i < 0x24; i++)
+    puffer[0x04 + i] = 0x00;
+
+  /* bV5GammaRed is set to 0 (ignored) */
+  FromL (0x0, &puffer[0x28]);
+
+  /* bV5GammaGreen is set to 0 (ignored) */
+  FromL (0x0, &puffer[0x2c]);
+
+  /* bV5GammaBlue is set to 0 (ignored) */
+  FromL (0x0, &puffer[0x30]);
+
+  /* bV5Intent = LCS_GM_GRAPHICS */
+  FromL (0x00000002, &puffer[0x34]);
+
+  /* bV5ProfileData is set to 0 (ignored) */
+  FromL (0x0, &puffer[0x38]);
+
+  /* bV5ProfileSize is set to 0 (ignored) */
+  FromL (0x0, &puffer[0x3c]);
+
+  /* bV5Reserved = 0 */
+  FromL (0x0, &puffer[0x40]);
+
+  Write (outfile, puffer, 68);
+
   /* After that is done, we write the image ... */
 
   write_image (outfile,



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