MCPcopy Index your code
hub / github.com/python-openxml/python-docx / from_stream

Method from_stream

src/docx/image/bmp.py:10–24  ·  view source on GitHub ↗

Return |Bmp| instance having header properties parsed from the BMP image in `stream`.

(cls, stream)

Source from the content-addressed store, hash-verified

8
9 @classmethod
10 def from_stream(cls, stream):
11 """Return |Bmp| instance having header properties parsed from the BMP image in
12 `stream`."""
13 stream_rdr = StreamReader(stream, LITTLE_ENDIAN)
14
15 px_width = stream_rdr.read_long(0x12)
16 px_height = stream_rdr.read_long(0x16)
17
18 horz_px_per_meter = stream_rdr.read_long(0x26)
19 vert_px_per_meter = stream_rdr.read_long(0x2A)
20
21 horz_dpi = cls._dpi(horz_px_per_meter)
22 vert_dpi = cls._dpi(vert_px_per_meter)
23
24 return cls(px_width, px_height, horz_dpi, vert_dpi)
25
26 @property
27 def content_type(self):

Callers

nothing calls this directly

Calls 3

read_longMethod · 0.95
StreamReaderClass · 0.85
_dpiMethod · 0.45

Tested by

no test coverage detected