MCPcopy Create free account
hub / github.com/MearaY/StegaPy / _read_one_bit

Method _read_one_bit

StegaPy/plugin/lsb/lsb_input_stream.py:55–65  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

53 return bytes(result)
54
55 def _read_one_bit(self) -> int:
56 bits_per_ch = getattr(self, 'channel_bits_used', None) or self.config.get_max_bits_used_per_channel()
57 ch_pos = self._bit_offset // bits_per_ch
58 bit_slot = self._bit_offset % bits_per_ch
59 pixel_idx = ch_pos // self.channels
60 channel = ch_pos % self.channels
61 row = pixel_idx // self.width
62 col = pixel_idx % self.width
63 bit = (int(self.pixels[row, col, channel]) >> bit_slot) & 1
64 self._bit_offset += 1
65 return bit
66
67 def read(self, size: int = -1) -> bytes:
68 n = self.header.get_data_length() if size < 0 else min(size, self.header.get_data_length())

Callers 1

_read_bytesMethod · 0.95

Calls 1

Tested by

no test coverage detected