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

Function bread

DevIL/src-IL/src/il_bits.cpp:123–146  ·  view source on GitHub ↗

hehe, "bread". It reads data into Buffer from the BITFILE, just like fread for FILE.

Source from the content-addressed store, hash-verified

121
122// hehe, "bread". It reads data into Buffer from the BITFILE, just like fread for FILE.
123ILint bread(void *Buffer, ILuint Size, ILuint Number, BITFILE *BitFile)
124{
125 // Note that this function is somewhat useless: In binary image
126 // formats, there are some pad bits after each scanline. This
127 // function does not take that into account, so you must use bseek to
128 // skip the calculated value of bits.
129
130 ILuint BuffPos = 0, Count = Size * Number;
131
132 while (BuffPos < Count) {
133 if (BitFile->ByteBitOff < 0 || BitFile->ByteBitOff > 7) {
134 BitFile->ByteBitOff = 7;
135 if (iread(&BitFile->Buff, 1, 1) != 1) // Reached eof or error...
136 return BuffPos;
137 }
138
139 *((ILubyte*)(Buffer) + BuffPos) = (ILubyte)!!(BitFile->Buff & (1 << BitFile->ByteBitOff));
140
141 BuffPos++;
142 BitFile->ByteBitOff--;
143 }
144
145 return BuffPos;
146}
147
148
149// Reads bits and puts the first bit in the file as the highest in the return value.

Callers 3

iLoadSunInternalFunction · 0.85
iLoadWbmpInternalFunction · 0.85
BitTestFunction · 0.85

Calls

no outgoing calls

Tested by 1

BitTestFunction · 0.68