| 856 | |
| 857 | |
| 858 | ILboolean GetSingleChannel(PSDHEAD *Head, ILubyte *Buffer, ILboolean Compressed) |
| 859 | { |
| 860 | ILuint i; |
| 861 | ILushort *ShortPtr; |
| 862 | ILbyte HeadByte; |
| 863 | ILint Run; |
| 864 | |
| 865 | ShortPtr = (ILushort*)Buffer; |
| 866 | |
| 867 | if (!Compressed) { |
| 868 | if (iCurImage->Bpc == 1) { |
| 869 | if (iread(Buffer, Head->Width * Head->Height, 1) != 1) |
| 870 | return IL_FALSE; |
| 871 | } |
| 872 | else { // iCurImage->Bpc == 2 |
| 873 | if (iread(Buffer, Head->Width * Head->Height * 2, 1) != 1) |
| 874 | return IL_FALSE; |
| 875 | } |
| 876 | } |
| 877 | else { |
| 878 | for (i = 0; i < Head->Width * Head->Height; ) { |
| 879 | HeadByte = igetc(); |
| 880 | |
| 881 | if (HeadByte >= 0) { // && HeadByte <= 127 |
| 882 | if (iread(Buffer + i, HeadByte + 1, 1) != 1) |
| 883 | return IL_FALSE; |
| 884 | i += HeadByte + 1; |
| 885 | } |
| 886 | if (HeadByte >= -127 && HeadByte <= -1) { |
| 887 | Run = igetc(); |
| 888 | if (Run == IL_EOF) |
| 889 | return IL_FALSE; |
| 890 | memset(Buffer + i, Run, -HeadByte + 1); |
| 891 | i += -HeadByte + 1; |
| 892 | } |
| 893 | if (HeadByte == -128) |
| 894 | { } // Noop |
| 895 | } |
| 896 | } |
| 897 | |
| 898 | return IL_TRUE; |
| 899 | } |
| 900 | |
| 901 | |
| 902 | |