Internal function used to save the Psd.
| 954 | |
| 955 | // Internal function used to save the Psd. |
| 956 | ILboolean iSavePsdInternal() |
| 957 | { |
| 958 | ILubyte *Signature = (ILubyte*)"8BPS"; |
| 959 | ILimage *TempImage; |
| 960 | ILpal *TempPal; |
| 961 | ILuint c, i; |
| 962 | ILubyte *TempData; |
| 963 | ILushort *ShortPtr; |
| 964 | ILenum Format, Type; |
| 965 | |
| 966 | if (iCurImage == NULL) { |
| 967 | ilSetError(IL_ILLEGAL_OPERATION); |
| 968 | return IL_FALSE; |
| 969 | } |
| 970 | |
| 971 | Format = iCurImage->Format; |
| 972 | Type = iCurImage->Type; |
| 973 | |
| 974 | // All of these comprise the actual signature. |
| 975 | iwrite(Signature, 1, 4); |
| 976 | SaveBigShort(1); |
| 977 | SaveBigInt(0); |
| 978 | SaveBigShort(0); |
| 979 | |
| 980 | SaveBigShort(iCurImage->Bpp); |
| 981 | SaveBigInt(iCurImage->Height); |
| 982 | SaveBigInt(iCurImage->Width); |
| 983 | if (iCurImage->Bpc > 2) |
| 984 | Type = IL_UNSIGNED_SHORT; |
| 985 | |
| 986 | if (iCurImage->Format == IL_BGR) |
| 987 | Format = IL_RGB; |
| 988 | else if (iCurImage->Format == IL_BGRA) |
| 989 | Format = IL_RGBA; |
| 990 | |
| 991 | if (Format != iCurImage->Format || Type != iCurImage->Type) { |
| 992 | TempImage = iConvertImage(iCurImage, Format, Type); |
| 993 | if (TempImage == NULL) |
| 994 | return IL_FALSE; |
| 995 | } |
| 996 | else { |
| 997 | TempImage = iCurImage; |
| 998 | } |
| 999 | SaveBigShort((ILushort)(TempImage->Bpc * 8)); |
| 1000 | |
| 1001 | // @TODO: Put the other formats here. |
| 1002 | switch (TempImage->Format) |
| 1003 | { |
| 1004 | case IL_COLOUR_INDEX: |
| 1005 | SaveBigShort(2); |
| 1006 | break; |
| 1007 | case IL_LUMINANCE: |
| 1008 | SaveBigShort(1); |
| 1009 | break; |
| 1010 | case IL_RGB: |
| 1011 | case IL_RGBA: |
| 1012 | SaveBigShort(3); |
| 1013 | break; |
no test coverage detected