                         
                         var bitPattern: T = 0
                         for (i, slice) in _slices.enumerated() {
-                            var byte = read_channel(source + _bitsOffset >> 3, _bitsOffset & 7, i)
+                            var byte = read_channel(source + _bitsOffset >> 3, _bitsOffset & 7, i, slice.count)
                             if slice.count != 8 {
                                 byte >>= 8 - slice.count
                             }

        let bytesPerPixel = bitmap.bitsPerPixel >> 3
        let bytesPerChannel = channel.bitRange.count >> 3
        let channelBytesOffset = channel.bitRange.lowerBound >> 3
        let channelShift = channel.bitRange.lowerBound & 7
        
        let _slices: LazySliceSequence = channel.bitRange.lazy.slice(by: 8)
        

        }
        
        @inline(__always)
        func read_channel(_ source: UnsafePointer<UInt8>, _ offset: Int, _ i: Int, _ bits_count: Int) -> UInt8 {
            switch channel.endianness {
            case .big: return channelBitsShift + bits_count <= 8 ? read_pixel(source, offset, i + channelBytesOffset) << channelBitsShift : (read_pixel(source, offset, i + channelBytesOffset) << channelBitsShift) | (read_pixel(source, offset, i + 1 + channelBytesOffset) >> (8 - channelBitsShift))
            case .little: return read_pixel(source, offset, bytesPerChannel - i - 1 + channelBytesOffset)
            }
        }
