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()
|