diff options
-rw-r--r-- | .gitattributes | 14 | ||||
-rw-r--r-- | DevIL/src-IL/src/il_targa.c | 19 |
2 files changed, 27 insertions, 6 deletions
diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..fbf9358b --- /dev/null +++ b/.gitattributes @@ -0,0 +1,14 @@ +# Set the default behavior, in case people don't have core.autocrlf set. +* text=auto + +# Explicitly declare text files you want to always be normalized and converted +# to native line endings on checkout. +*.c text +*.h text + +# Declare files that will always have CRLF line endings on checkout. +*.sln text eol=crlf + +# Denote all files that are truly binary and should not be modified. +*.png binary +*.jpg binary diff --git a/DevIL/src-IL/src/il_targa.c b/DevIL/src-IL/src/il_targa.c index 4732df9c..e414152b 100644 --- a/DevIL/src-IL/src/il_targa.c +++ b/DevIL/src-IL/src/il_targa.c @@ -719,23 +719,30 @@ ILboolean iSaveTargaInternal() TempImage = iCurImage; } - if (TempImage->Origin != IL_ORIGIN_LOWER_LEFT) + if (TempImage->Origin != IL_ORIGIN_LOWER_LEFT) { TempData = (char*)iGetFlipped(TempImage); + } else TempData = (char*)TempImage->Data; // Write out the origin stuff. - Temp = 0; - iwrite(&Temp, sizeof(ILshort), 1); - iwrite(&Temp, sizeof(ILshort), 1); + ILshort zero_short = 0; + iwrite(&zero_short, sizeof(ILshort), 1); + iwrite(&zero_short, sizeof(ILshort), 1); - Temp = iCurImage->Bpp << 3; // Changes to bits per pixel + Temp = iCurImage->Bpp << 3; // Changes to bits per pixel SaveLittleUShort((ILushort)iCurImage->Width); SaveLittleUShort((ILushort)iCurImage->Height); iwrite(&Temp, sizeof(ILubyte), 1); // Still don't know what exactly this is for... + // It's actually the 'Image Descriptor Byte' + // from wiki: Image descriptor (1 byte): bits 3-0 give the alpha channel depth, bits 5-4 give direction Temp = 0; + if (iCurImage->Bpp > 3) + Temp = 8; + if (TempImage->Origin == IL_ORIGIN_UPPER_LEFT) + Temp |= 0x20; //set 5th bit iwrite(&Temp, sizeof(ILubyte), 1); iwrite(ID, sizeof(char), IDLen); ifree(ID); @@ -810,7 +817,7 @@ ILboolean iSaveTargaInternal() // Write the footer. SaveLittleUInt(ExtOffset); // No extension area SaveLittleUInt(0); // No developer directory - iwrite(Footer, 1, ilCharStrLen(Footer)); + iwrite(Footer, 1, ilCharStrLen(Footer)+1); if (TempImage->Origin != IL_ORIGIN_LOWER_LEFT) { ifree(TempData); |