Skip to main content

screencap to ppm

Project description

screencap to ppm

Tested against Windows 10 / Python 3.11 / Anaconda / BlueStacks (Android 11 - rooted with Python installed)

pip install cythonscreencap2ppm

from cythonscreencap2ppm import (
    Screencaptaker,
    mount_memory_disk,
    remount_rw,
    convert_screencap2file,
    convert_screencap2np,
    get_all_sh,
    get_all_su,
    get_resolution,
    remount_rw,
    remount_rw_all_shell_su_combinations,
    unmount_memory_disk,
)
import os

os.environ["OMP_THREAD_LIMIT"] = "1"
mount_memory_disk(
    path="/media/ramdisk", mb=256, su="su", sh="sh", try_all_combinations=False
)

# class to take screenshots with screencap (raw RGB data - NOT PNG! ) and convert to PPM
self = Screencaptaker(
    path="/media/ramdisk",
    mb=256,
    sh="sh",
    pure_shot="pure_shot.raw",
    converted_shot="converted_shot.ppm",
    width=0,
    height=0,
    max_color_value=255,
)

counter = 0
while True:
    nparraybuf = self.get_screenshot_as_np()
    print(nparraybuf.shape, counter, end="\r")
    counter += 1

# Example of using remount_rw to attempt remounting the root filesystem as read-write
result, success = remount_rw("su", "sh")
# Convert a raw screenshot file to a PPM format and save it
convert_screencap2file(
    "/path/to/input.raw",
    "/path/to/output.ppm",
    max_color_value=255,
    width=0,
    height=0,
)
# Convert a raw screenshot file directly into a NumPy array
image_array = convert_screencap2np("/path/to/input.raw", width=0, height=0)
print("Image array shape:", image_array.shape)
# Retrieve all paths where the 'sh' shell executable is found
sh_paths = get_all_sh()
print("SH paths found:", sh_paths)
# Retrieve all paths where the 'su' executable is found
su_paths = get_all_su()
print("SU paths found:", su_paths)
# Get the screen resolution of the device
width, height = get_resolution()
print("Screen resolution:", width, "x", height)
# Try to remount the root filesystem as read-write using all combinations of 'su' and 'sh' paths
stdout_stderr, success = remount_rw_all_shell_su_combinations()
print("Remount attempt successful:", success)
# Unmount a previously mounted memory disk
result = unmount_memory_disk("/media/ramdisk", "su", "sh")
print("Unmount operation completed")
# Example of mounting a memory disk to a specified path with a defined size
mount_memory_disk(
    path="/media/ramdisk", mb=256, su="su", sh="sh", try_all_combinations=False
)
print("Memory disk mounted at /media/ramdisk with size 256MB")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cythonscreencap2ppm-0.11.tar.gz (27.9 kB view details)

Uploaded Source

Built Distribution

cythonscreencap2ppm-0.11-py3-none-any.whl (28.6 kB view details)

Uploaded Python 3

File details

Details for the file cythonscreencap2ppm-0.11.tar.gz.

File metadata

  • Download URL: cythonscreencap2ppm-0.11.tar.gz
  • Upload date:
  • Size: 27.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for cythonscreencap2ppm-0.11.tar.gz
Algorithm Hash digest
SHA256 a597614474a7fc3be6b92df5aba5f1bb8d5d09da84bf6736d818acaa8b0d24ec
MD5 f393b1c330b5830e4088bb8be38f516c
BLAKE2b-256 7877dec89a47ecf698b406e88883a05b65922d3f88409d7b67bdc349ba697253

See more details on using hashes here.

File details

Details for the file cythonscreencap2ppm-0.11-py3-none-any.whl.

File metadata

File hashes

Hashes for cythonscreencap2ppm-0.11-py3-none-any.whl
Algorithm Hash digest
SHA256 910d7dca304b686e16a0c3acab6359f0c33401b3b612b220f9af3dc92edc91df
MD5 974408f814f5dcdfbf55ed13985d2cb8
BLAKE2b-256 c9f8e90210187de2f25290fae3b037b54cb727a83e782ba8236eb079c4cd6788

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page