Internal function used to save the .bmp.
| 895 | |
| 896 | // Internal function used to save the .bmp. |
| 897 | ILboolean iSaveBitmapInternal() |
| 898 | { |
| 899 | //int compress_rle8 = ilGetInteger(IL_BMP_RLE); |
| 900 | int compress_rle8 = IL_FALSE; // disabled BMP RLE compression. broken |
| 901 | ILuint FileSize, i, PadSize, Padding = 0; |
| 902 | ILimage *TempImage = NULL; |
| 903 | ILpal *TempPal; |
| 904 | ILubyte *TempData; |
| 905 | |
| 906 | if (iCurImage == NULL) { |
| 907 | ilSetError(IL_ILLEGAL_OPERATION); |
| 908 | return IL_FALSE; |
| 909 | } |
| 910 | |
| 911 | iputc('B'); // Comprises the |
| 912 | iputc('M'); // "signature" |
| 913 | |
| 914 | SaveLittleUInt(0); // Will come back and change later in this function (filesize) |
| 915 | SaveLittleUInt(0); // Reserved |
| 916 | |
| 917 | if (compress_rle8 == IL_TRUE) |
| 918 | { |
| 919 | TempImage = iConvertImage(iCurImage, IL_COLOR_INDEX, IL_UNSIGNED_BYTE); |
| 920 | if (TempImage == NULL) |
| 921 | return IL_FALSE; |
| 922 | TempPal = iConvertPal(&TempImage->Pal, IL_PAL_BGR32); |
| 923 | if (TempPal == NULL) |
| 924 | { |
| 925 | ilCloseImage(TempImage); |
| 926 | return IL_FALSE; |
| 927 | } |
| 928 | } |
| 929 | |
| 930 | // If the current image has a palette, take care of it |
| 931 | TempPal = &iCurImage->Pal; |
| 932 | if( iCurImage->Pal.PalSize && iCurImage->Pal.Palette && iCurImage->Pal.PalType != IL_PAL_NONE ) { |
| 933 | // If the palette in .bmp format, write it directly |
| 934 | if (iCurImage->Pal.PalType == IL_PAL_BGR32) { |
| 935 | TempPal = &iCurImage->Pal; |
| 936 | } else { |
| 937 | TempPal = iConvertPal(&iCurImage->Pal, IL_PAL_BGR32); |
| 938 | if (TempPal == NULL) { |
| 939 | return IL_FALSE; |
| 940 | } |
| 941 | } |
| 942 | } |
| 943 | |
| 944 | SaveLittleUInt(54 + TempPal->PalSize); // Offset of the data |
| 945 | |
| 946 | //Changed 20040923: moved this block above writing of |
| 947 | //BITMAPINFOHEADER, so that the written header refers to |
| 948 | //TempImage instead of the original image |
| 949 | |
| 950 | // @TODO LUMINANCE converted to BGR insteaf of beign saved to luminance |
| 951 | if (iCurImage->Format != IL_BGR && iCurImage->Format != IL_BGRA && iCurImage->Format != IL_COLOUR_INDEX) { |
| 952 | if (iCurImage->Format == IL_RGBA) { |
| 953 | TempImage = iConvertImage(iCurImage, IL_BGRA, IL_UNSIGNED_BYTE); |
| 954 | } else { |
no test coverage detected