# screencap to ppm
### Tested against Windows 10 / Python 3.11 / Anaconda / BlueStacks (Android 11 - rooted with Python installed)
### pip install cythonscreencap2ppm
```py
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")
```
Raw data
{
"_id": null,
"home_page": "https://github.com/hansalemaos/cythonscreencap2ppm",
"name": "cythonscreencap2ppm",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "Android, instance",
"author": "Johannes Fischer",
"author_email": "aulasparticularesdealemaosp@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/3c/3a/8e14ca9d47e6fc6754746c05fee85f6b150987e3c09d1875057842771108/cythonscreencap2ppm-0.10.tar.gz",
"platform": null,
"description": "\r\n# screencap to ppm \r\n\r\n### Tested against Windows 10 / Python 3.11 / Anaconda / BlueStacks (Android 11 - rooted with Python installed) \r\n\r\n### pip install cythonscreencap2ppm\r\n\r\n\r\n```py\r\nfrom cythonscreencap2ppm import (\r\n Screencaptaker,\r\n mount_memory_disk,\r\n remount_rw,\r\n convert_screencap2file,\r\n convert_screencap2np,\r\n get_all_sh,\r\n get_all_su,\r\n get_resolution,\r\n remount_rw,\r\n remount_rw_all_shell_su_combinations,\r\n unmount_memory_disk,\r\n)\r\nimport os\r\n\r\nos.environ[\"OMP_THREAD_LIMIT\"] = \"1\"\r\nmount_memory_disk(\r\n path=\"/media/ramdisk\", mb=256, su=\"su\", sh=\"sh\", try_all_combinations=False\r\n)\r\n\r\n# class to take screenshots with screencap (raw RGB data - NOT PNG! ) and convert to PPM\r\nself = Screencaptaker(\r\n path=\"/media/ramdisk\",\r\n mb=256,\r\n sh=\"sh\",\r\n pure_shot=\"pure_shot.raw\",\r\n converted_shot=\"converted_shot.ppm\",\r\n width=0,\r\n height=0,\r\n max_color_value=255,\r\n)\r\n\r\ncounter = 0\r\nwhile True:\r\n nparraybuf = self.get_screenshot_as_np()\r\n print(nparraybuf.shape, counter, end=\"\\r\")\r\n counter += 1\r\n\r\n# Example of using remount_rw to attempt remounting the root filesystem as read-write\r\nresult, success = remount_rw(\"su\", \"sh\")\r\n# Convert a raw screenshot file to a PPM format and save it\r\nconvert_screencap2file(\r\n \"/path/to/input.raw\",\r\n \"/path/to/output.ppm\",\r\n max_color_value=255,\r\n width=0,\r\n height=0,\r\n)\r\n# Convert a raw screenshot file directly into a NumPy array\r\nimage_array = convert_screencap2np(\"/path/to/input.raw\", width=0, height=0)\r\nprint(\"Image array shape:\", image_array.shape)\r\n# Retrieve all paths where the 'sh' shell executable is found\r\nsh_paths = get_all_sh()\r\nprint(\"SH paths found:\", sh_paths)\r\n# Retrieve all paths where the 'su' executable is found\r\nsu_paths = get_all_su()\r\nprint(\"SU paths found:\", su_paths)\r\n# Get the screen resolution of the device\r\nwidth, height = get_resolution()\r\nprint(\"Screen resolution:\", width, \"x\", height)\r\n# Try to remount the root filesystem as read-write using all combinations of 'su' and 'sh' paths\r\nstdout_stderr, success = remount_rw_all_shell_su_combinations()\r\nprint(\"Remount attempt successful:\", success)\r\n# Unmount a previously mounted memory disk\r\nresult = unmount_memory_disk(\"/media/ramdisk\", \"su\", \"sh\")\r\nprint(\"Unmount operation completed\")\r\n# Example of mounting a memory disk to a specified path with a defined size\r\nmount_memory_disk(\r\n path=\"/media/ramdisk\", mb=256, su=\"su\", sh=\"sh\", try_all_combinations=False\r\n)\r\nprint(\"Memory disk mounted at /media/ramdisk with size 256MB\")\r\n```\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "screencap to ppm",
"version": "0.10",
"project_urls": {
"Homepage": "https://github.com/hansalemaos/cythonscreencap2ppm"
},
"split_keywords": [
"android",
" instance"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "38781edb9caa9295b93fbf34ec22c3475dbace3474febcf8ddd68bf9f576724a",
"md5": "3b75b16dbfce9a139e738950a628c129",
"sha256": "6a784edac9fd4ea84424696dc049b853b1513f8059b8d5cbf29e0fdbad909c6c"
},
"downloads": -1,
"filename": "cythonscreencap2ppm-0.10-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3b75b16dbfce9a139e738950a628c129",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 28671,
"upload_time": "2024-06-30T09:08:25",
"upload_time_iso_8601": "2024-06-30T09:08:25.621604Z",
"url": "https://files.pythonhosted.org/packages/38/78/1edb9caa9295b93fbf34ec22c3475dbace3474febcf8ddd68bf9f576724a/cythonscreencap2ppm-0.10-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "3c3a8e14ca9d47e6fc6754746c05fee85f6b150987e3c09d1875057842771108",
"md5": "0a5826eec13858b08e63e2808228f34d",
"sha256": "1b4e866f01f7bd06cb96d98cbac30f23420cc503b46690c8198487bf53a7f137"
},
"downloads": -1,
"filename": "cythonscreencap2ppm-0.10.tar.gz",
"has_sig": false,
"md5_digest": "0a5826eec13858b08e63e2808228f34d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 27912,
"upload_time": "2024-06-30T09:08:27",
"upload_time_iso_8601": "2024-06-30T09:08:27.130454Z",
"url": "https://files.pythonhosted.org/packages/3c/3a/8e14ca9d47e6fc6754746c05fee85f6b150987e3c09d1875057842771108/cythonscreencap2ppm-0.10.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-06-30 09:08:27",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "hansalemaos",
"github_project": "cythonscreencap2ppm",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "cythonscreencap2ppm"
}