hehe, "bread". It reads data into Buffer from the BITFILE, just like fread for FILE.
| 121 | |
| 122 | // hehe, "bread". It reads data into Buffer from the BITFILE, just like fread for FILE. |
| 123 | ILint 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. |
no outgoing calls