MCPcopy Create free account
hub / github.com/DentonW/DevIL / GetSingleChannel

Function GetSingleChannel

DevIL/src-IL/src/il_psd.cpp:858–899  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

856
857
858ILboolean 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

Callers 1

ReadCMYKFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected