Screen Capture¶
Screenshot capture functionality
Screen capture functionality for Siglent oscilloscopes.
Captures the oscilloscope's display via the SCDP (screen dump) command. Modern Siglent scopes (e.g. SDS800X HD) return a raw BMP whose length is carried in the BMP header; older/other models may return an IEEE-488.2 definite-length block. Both are handled by reading exactly the number of bytes the response declares, rather than over-reading a fixed large size (which times out and drops the connection on the modern models).
ScreenCapture
¶
Handles screenshot capture from an oscilloscope display.
The scope returns its screen as a BMP; use get_screenshot_pil() (requires Pillow) to convert to PNG/JPEG.
Initialize screen capture.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
oscilloscope
|
Parent Oscilloscope instance |
required |
Source code in scpi_control/screen_capture.py
capture_screenshot
¶
Capture a screenshot from the oscilloscope display via SCDP.
The SCDP command returns the screen image in the scope's native format
(BMP on current Siglent models). image_format is accepted for
backwards compatibility but ignored; use get_screenshot_pil() to convert.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image_format
|
str
|
Ignored (SCDP returns the scope's native format). |
'BMP'
|
Returns:
| Type | Description |
|---|---|
bytes
|
Binary image data (BMP). |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If capture fails. |
Example
scope = Oscilloscope('192.168.1.100') scope.connect() data = scope.screen_capture.capture_screenshot() open("screenshot.bmp", "wb").write(data)
Source code in scpi_control/screen_capture.py
save_screenshot
¶
Capture and save a screenshot to a file.
The SCDP command returns BMP data. If you pass a different extension (e.g. .png), the file will still contain BMP bytes -- use get_screenshot_pil() and Pillow to convert formats.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Output file path (recommend a .bmp extension). |
required |
image_format
|
Optional[str]
|
Ignored (SCDP always returns BMP). |
None
|
Example
scope.screen_capture.save_screenshot("capture.bmp")
To save as PNG (requires Pillow):
img = scope.screen_capture.get_screenshot_pil() img.save("capture.png", "PNG")
Source code in scpi_control/screen_capture.py
get_screenshot_pil
¶
Capture a screenshot and return it as a PIL Image.
Requires Pillow. Use this to convert the BMP screen dump to other formats.
Returns:
| Type | Description |
|---|---|
|
PIL.Image loaded from the captured BMP data. |
Raises:
| Type | Description |
|---|---|
ImportError
|
If Pillow is not installed. |
Example
img = scope.screen_capture.get_screenshot_pil() img.save("screenshot.png", "PNG")
Source code in scpi_control/screen_capture.py
See Also¶
- Oscilloscope - Main oscilloscope control class for SCPI communication