Screen Capture¶
Screenshot capture functionality
Screen capture functionality for Siglent oscilloscopes.
This module provides functionality to capture screenshots from the oscilloscope's display in various image formats.
ScreenCapture
¶
Handles screenshot capture from oscilloscope display.
Supports capturing the oscilloscope screen in PNG, BMP, and JPEG formats.
Initialize screen capture.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
oscilloscope
|
Parent Oscilloscope instance |
required |
Source code in scpi_control/screen_capture.py
capture_screenshot
¶
Capture screenshot from oscilloscope display using SCDP command.
Note: The SCDP command returns the screen image in the oscilloscope's native format (typically BMP). The image_format parameter is ignored for Siglent scopes using SCDP. To convert to other formats, use PIL/Pillow after capture.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image_format
|
str
|
Desired format (currently ignored, SCDP returns BMP) |
'BMP'
|
Returns:
| Type | Description |
|---|---|
bytes
|
Binary image data (typically BMP format) |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If capture fails |
Example
scope = Oscilloscope('192.168.1.100') scope.connect() image_data = scope.screen_capture.capture_screenshot() with open("screenshot.bmp", "wb") as f: ... f.write(image_data)
Source code in scpi_control/screen_capture.py
save_screenshot
¶
Capture and save screenshot to file.
Note: The SCDP command returns images in BMP format. If you specify a different extension (e.g., .png), the file will still contain BMP data. Use get_screenshot_pil() and PIL to convert formats if needed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Output file path (recommend using .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 PIL/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 screenshot and return as PIL Image object.
Requires PIL/Pillow to be installed. Use this method to convert the BMP screenshot to other formats.
Returns:
| Type | Description |
|---|---|
|
PIL.Image object (loaded from BMP data) |
Raises:
| Type | Description |
|---|---|
ImportError
|
If PIL is not installed |
Example
Capture and display¶
img = scope.screen_capture.get_screenshot_pil() img.show()
Capture and save as PNG¶
img = scope.screen_capture.get_screenshot_pil() img.save("screenshot.png", "PNG")
Capture and save as JPEG with quality¶
img = scope.screen_capture.get_screenshot_pil() img.save("screenshot.jpg", "JPEG", quality=95)
Source code in scpi_control/screen_capture.py
See Also¶
- Oscilloscope - Main oscilloscope control class for SCPI communication