docs: def iterboxed(self, rows):
          """
          Iterator that yields each scanline in boxed row flat pixel format.
  
          `rows` should be an iterator that yields the bytes of
          each row in turn.
          """
          def asvalues(raw):
              """
              Convert a row of raw bytes into a flat row.
  
              Result may or may not share with argument
              """
              if self.bitdepth == 8:
                  return raw
              if self.bitdepth == 16:
                  raw = bytearray_to_bytes(raw)
                  return array('H', struct.unpack('!%dH' % (len(raw) // 2), raw))
              assert self.bitdepth < 8
              width = self.width
              # Samples per byte
              spb = 8 // self.bitdepth
              out = newBarray()
              mask = 2 ** self.bitdepth - 1
              #                                      reversed range(spb)
              shifts = [self.bitdepth * it for it in range(spb - 1, -1, -1)]
              for o in raw:
                  out.extend([mask & (o >> i) for i in shifts])
              return out[:width]
  
          return map(asvalues, rows)