file-bmp: Fix final bfSize patched into BMP header (#737669)

This commit is contained in:
Mukund Sivaraman 2014-10-03 11:10:26 +05:30
parent dbfbc221a5
commit db18c1f172
1 changed files with 11 additions and 5 deletions

View File

@ -72,7 +72,9 @@ static void write_image (FILE *f,
gint bpp,
gint spzeile,
gint MapSize,
RGBMode rgb_format);
RGBMode rgb_format,
gint mask_info_size,
gint color_space_size);
static gboolean save_dialog (gint channels);
@ -354,9 +356,10 @@ WriteBMP (const gchar *filename,
else
SpZeile = ((gint) (((Spcols * BitsPerPixel) / 8) / 4) + 1) * 4;
color_space_size = 0;
if (! BMPSaveData.dont_write_color_space_data)
color_space_size = 68;
else
color_space_size = 0;
Bitmap_File_Head.bfSize = (0x36 + MapSize + (rows * SpZeile) +
mask_info_size + color_space_size);
@ -541,7 +544,8 @@ WriteBMP (const gchar *filename,
pixels, cols, rows,
BMPSaveData.use_run_length_encoding,
channels, BitsPerPixel, SpZeile,
MapSize, BMPSaveData.rgb_format);
MapSize, BMPSaveData.rgb_format,
mask_info_size, color_space_size);
/* ... and exit normally */
@ -582,7 +586,9 @@ write_image (FILE *f,
gint bpp,
gint spzeile,
gint MapSize,
RGBMode rgb_format)
RGBMode rgb_format,
gint mask_info_size,
gint color_space_size)
{
guchar buf[16] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0 };
guchar puffer[8];
@ -830,7 +836,7 @@ write_image (FILE *f,
FromL (length, puffer);
Write (f, puffer, 4);
fseek (f, 0x02, SEEK_SET); /* Write length of file */
length += (0x36 + MapSize);
length += (0x36 + MapSize + mask_info_size + color_space_size);
FromL (length, puffer);
Write (f, puffer, 4);
g_free (ketten);