View Single Post
Old 01-16-2013, 04:54 AM   #4
ichrispa
Enthusiast
ichrispa shines like a glazed doughnut.ichrispa shines like a glazed doughnut.ichrispa shines like a glazed doughnut.ichrispa shines like a glazed doughnut.ichrispa shines like a glazed doughnut.ichrispa shines like a glazed doughnut.ichrispa shines like a glazed doughnut.ichrispa shines like a glazed doughnut.ichrispa shines like a glazed doughnut.ichrispa shines like a glazed doughnut.ichrispa shines like a glazed doughnut.
 
Posts: 40
Karma: 8604
Join Date: Dec 2012
Location: Germany
Device: Kobo Touch
I'm triggering the following script via an integrated webserver on the kobo touch... screenshots directly to the desktop ^^

Quote:
#!/mnt/onboard/.local/bin/python

import png
import struct

RAWD = "/mnt/onboard/.local/tmp/screenshot.raw"

# create a raw image
fb = open("/dev/fb0", b"r")
rawf = open(RAWD, b"w")
rawf.write(fb.read(1089536))
rawf.close()

rawf = open(RAWD, b"r")
pngf = open("/mnt/onboard/.local/tmp/screenshot.png", "w")

rawpng_flat = []
rawpng = []
pixel = []

data = rawf.read(2)
print "Screen data aquired"

while data != "":
r5 = (struct.unpack("H", data)[0] >> 11) & 0x1F
g6 = (struct.unpack("H", data)[0] >> 5) & 0x3F
b5 = (struct.unpack("H", data)[0]) & 0x1F
r8 = (r5<<3)+(r5>>2)
g8 = (g6<<2)+(g6>>4)
b8 = (b5<<3)+(b5>>2)

rawpng_flat += [r8%256, g8%256, b8%256]
data = rawf.read(2)

print "Writing Screenshot"
png.Writer(width=800,height=600,bitdepth=8).write_ array(pngf, rawpng_flat)

pngf.close()
rawf.close()
ichrispa is offline   Reply With Quote