02-09-2012, 10:30 AM | #31 |
Junior Member
Posts: 3
Karma: 10
Join Date: Feb 2012
Device: Kindle DXG
|
Any luck getting this to work with a DXG?
I have the graphite version of the DX, and keep seeing references to the USBHack for this device, but none of them link to the actual .bin file.
I've looked in the archives at: http://www.avenard.org/kindle2/ and can't find the the DXG version everyone mentions. |
02-16-2012, 07:46 PM | #32 |
Junior Member
Posts: 1
Karma: 10
Join Date: Feb 2012
Device: kindle
|
It's amazing! Since I bought my Kindle I was looking for a way to get the pc screen on it. Very cool! It made me feel like "Why didn't I think of that?".
kranu, thanks for sharing the code! I hope you don't mind me changing it. Well, I am thinking about some new features to this, mainly some way of selecting the screen area by clicking on it. But I don't know anything about wxWidgets, so firstly I ported the code to PyGTK. I am sharing my code here, so people like me (that don't know wx, but know gtk ) can try to add new features too. This script do the same as the original so far. I don't know if it will work on Windows, I have tested it on Ubuntu. |
Advert | |
|
03-10-2012, 03:22 PM | #33 |
Junior Member
Posts: 2
Karma: 10
Join Date: Mar 2012
Device: Kindle 3 DXg
|
Fiurst of all, great app! if anyone can get this running on their kindle DXG (no wifi) this would be awesome.
I have a the VNC viewer working mentioned in antoher post, even downloaded the donated version but I am not too satisfied with it, just want to test this one out (ready to donate as well ;-)) I am particuarly interested to use it as a seperate view and not as a clone which gives troubles with the other somehow. all help is welcome, thanks! |
04-10-2012, 05:38 PM | #34 |
Junior Member
Posts: 1
Karma: 10
Join Date: Apr 2012
Device: Kindle 3
|
How set up WIRELESS ip?
I have LAN network on PC and i have connected an USB Wireless Adapter, for conect my Computer to a wireless network (and then communicate with Kindle using your application).
The problem is: my device don´t recognizes the LAN ip. And the python only connect using this address. How can i set manually the py archive for my Kindle recognizes the Wireless IP and them see the monitor screenshots on my Kindle screeen? |
04-10-2012, 07:13 PM | #35 | |
Carpe diem, c'est la vie.
Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
|
Quote:
After extracting the files, be sure to install the correct binary for your kindle model and firmware version. |
|
Advert | |
|
04-24-2012, 12:46 AM | #36 |
Zealot
Posts: 130
Karma: 10000
Join Date: Mar 2012
Device: Kindle 3G, Kindle Touch 3G, iRiver Story HD, Sony Reader
|
iRiver Story HD Version
Hi,
I modified the gtk version for iRiver Story HD (6" 768x1024 display). This one has the screen rotated, and the Pixbuf made into grayscale. I also reduced the quality of the JPG to 50 to reduce refresh time. Please see the attached. Code:
#!/usr/bin/python #eMonitor by Kranu #Version 2 (9-1-2011) #modified by jmseight for iRiver Story HD (4-24-2012) # Rotate screen 90 deg # Made into grayscale image (original is color) # Reduce quality for faster load # Set to Story HD resolution #Tested on Windows 7 x64, Python 2.7.2, wxPython 2.8 #For more information, see: http://goo.gl/rJoLp #+---2-16-2012---+ #This is the same as v2 #Just using pygtk instead of wxWidgets. #Tested on Ubuntu #BEGIN SETUP #HTTP Server port=8000 #port of http server (http://127.0.0.1:8000/) #capture region #l,t=(1680,1050-800) l,t=(0,0) #left and right offset from primary monitor w,h=(1024,768) #width and height of capture region fn ='shot.jpg' #file name of screenshot quality = "50" #//END SETUP import pygtk, gtk, socket from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer class serv(BaseHTTPRequestHandler): def do_GET(self): self.send_response(200) if self.path.startswith('/'+fn): self.send_header('Content-type','image/jpeg') self.end_headers() screenshot = gtk.gdk.Pixbuf.rotate_simple( gtk.gdk.Pixbuf.get_from_drawable( gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8, w, h), gtk.gdk.get_default_root_window(), gtk.gdk.colormap_get_system(), l, l, 0, 0, w, h), gtk.gdk.PIXBUF_ROTATE_COUNTERCLOCKWISE ) screenshot.saturate_and_pixelate(screenshot, 0.0, False) screenshot.save(fn, "jpeg", {"quality": quality}) f=open(fn,'rb') self.wfile.write(f.read()) else: self.send_header('Content-type','text/html') self.end_headers() self.wfile.write('<!doctype html>'\ '<html lang="en">'\ '<head>'\ '<title>eMonitor by Kranu</title>'\ '</head>'\ '<body style="margin:0px;">'\ '<img id="pic" src="'+fn+'" style="float:left;width:100%;height:100%;">'\ '<script type="text/javascript">'\ 'document.getElementById("pic").onload=function() {'\ ' document.getElementById("pic").src="'+fn+'?"+(new Date()).getTime();'\ '}'\ '</script>'\ '</body>'\ '</html>') try: print 'eMonitor by Kranu' #Amazon's website is used here for its reliablity. Feel free to change it. s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.connect(("amazon.com",80)) print 'Starting.. ', server=HTTPServer(('',port),serv) print 'Press Ctrl+C to stop' print print 'On your Story HD, visit http://'+s.getsockname()[0]+':'+str(port)+'/' server.serve_forever() except KeyboardInterrupt: print 'Stopping.. ', server.socket.close() print 'Have a nice day!' |
04-24-2012, 05:08 PM | #37 |
Zealot
Posts: 130
Karma: 10000
Join Date: Mar 2012
Device: Kindle 3G, Kindle Touch 3G, iRiver Story HD, Sony Reader
|
eMonitor with Support for Dithering
Hi All,
Please find the enclosed version using wxpython with support for Dithering with geekmaster's formula 42 translated to python. The screen size can be reduced to 800x600 for Kindle easily. The dithered variable is set to True or False to turn on or off. Dithered images are saved as png - for smaller size Grayscale images are saved as jpg - for smaller size Thanks, James Code:
#!/usr/bin/python #eMonitor #Version 3 modified by jmseight for Kindle/Story (4-25-2012) # Rotate screen 90 deg # Support Dithering if turned on (no flash on videos) # support cropping of dithering table # saves as png for dithered # saves as jpeg for grayscale # Reduce quality for faster load # Uses GeekMaster's Dithering Formula (MIT license) # Set to Story HD resolution #based on eMonitor by Kranu #Version 2 (9-1-2011) #Tested on Windows 7 x64, Python 2.7.2, wxPython 2.8 #For more information, see: http://goo.gl/rJoLp #BEGIN SETUP #HTTP Server port=8000 #port of http server (http://127.0.0.1:8000/) #capture region #l,t=(1680,1050-800) l,t=(0,0) #left and right offset from primary monitor w,h=(1024,768) #width and height of capture region fn ='shot.png' #file name of screenshot quality = "50" dt = [ 3,129,34,160,10,136,42,168,192,66,223,97,200,73,231,105,50, 176,18,144,58,184,26,152,239,113,207,81,247,121,215,89,14, 140,46,180,7,133,38,164,203,77,235,109,196,70,227,101,62,188, 30,156,54,180,22,148,251,125,219,93,243,117,211,85 ] # 0-255 dither table white = 255 #white threshold black = 0 #black threshold dithered = True #dithered or not #//END SETUP import wx,socket from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer class serv(BaseHTTPRequestHandler): def do_GET(self): self.send_response(200) if self.path.startswith('/'+fn): self.send_header('Content-type','image/jpeg') self.end_headers() app=wx.PySimpleApp() context=wx.ScreenDC() bitmap=wx.EmptyBitmap(w, h, -1) memory=wx.MemoryDC() memory.SelectObject(bitmap) memory.Blit(0, 0, w, h, context, l, t) memory.SelectObject(wx.NullBitmap) image=wx.ImageFromBitmap(bitmap) data=list(image.GetData()) # for i in xrange(0,len(data),3): # data[i]=data[i+1]=data[i+2]=chr(int(0.2989*float(ord(data[i]))+0.5870*float(ord(data[i+1]))+0.1140*float(ord(data[i+2])))) i=0 if dithered: for y in xrange(0,h-1,1): for x in xrange(0,w-1,1): # i = (y*w + x)*3 # j = ((y&7)<<3)|x&7 # intensity = int((298*ord(data[i])+587*ord(data[i+1])+114*ord(data[i+2]))/1000) if dt[((y&7)<<3)|x&7] < (ord(data[i])+(ord(data[i+1])<<1)+ord(data[i+2]))>>2: data[i] = '\xff' else: data[i] = '\x00' i=i+3 else: for y in xrange(0,h-1,1): for x in xrange(0,w-1,1): # i = (y*w + x)*3 # j = ((y&7)<<3)|x&7 # intensity = int((298*ord(data[i])+587*ord(data[i+1])+114*ord(data[i+2]))/1000) data[i] = chr((ord(data[i])+(ord(data[i+1])<<1)+ord(data[i+2]))>>2) i=i+3 image.SetData("".join(data)) image = image.Rotate90(False) if dithered: image.SetOption(wx.IMAGE_OPTION_PNG_FORMAT, str(wx.PNG_TYPE_GREY_RED)) image.SetOption(wx.IMAGE_OPTION_PNG_BITDEPTH, "8") image.SaveFile(fn,wx.BITMAP_TYPE_PNG) else: image.SetOption("quality", quality) image.SaveFile(fn,wx.BITMAP_TYPE_JPEG) f=open(fn,'rb') self.wfile.write(f.read()) else: self.send_header('Content-type','text/html') self.end_headers() self.wfile.write('<!doctype html>'\ '<html lang="en">'\ '<head>'\ '<title>eMonitor by Kranu</title>'\ '</head>'\ '<body style="margin:0px;">'\ '<img id="pic" src="'+fn+'" style="float:left;width:100%;height:100%;">'\ '<script type="text/javascript">'\ 'document.getElementById("pic").onload=function() {'\ ' document.getElementById("pic").src="'+fn+'?"+(new Date()).getTime();'\ '}'\ '</script>'\ '</body>'\ '</html>') try: print 'eMonitor by jmseight (based on Kranu)' for j in xrange(0, len(dt)-1, 1): if dt[j] < black: dt[j] = black if dt[j] > white: dt[j] = white #Amazon's website is used here for its reliablity. Feel free to change it. s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.connect(("amazon.com",80)) print 'Starting.. ', server=HTTPServer(('',port),serv) print 'Press Ctrl+C to stop' print print 'On your Kindle/Story, visit http://'+s.getsockname()[0]+':'+str(port)+'/' server.serve_forever() except KeyboardInterrupt: print 'Stopping.. ', server.socket.close() print 'Have a nice day!' |
04-24-2012, 06:01 PM | #38 |
Carpe diem, c'est la vie.
Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
|
Python? Cute.
|
04-24-2012, 10:11 PM | #39 |
Zealot
Posts: 130
Karma: 10000
Join Date: Mar 2012
Device: Kindle 3G, Kindle Touch 3G, iRiver Story HD, Sony Reader
|
Hi,
Actually Python is running a little slow. I tried to optimize the code as much as I can using shifts instead of multiply and divide, etc. I am now researching how to put c code into Python on my Win 7 environment. While the grayscale images (wxPython and pygtk) are limited by file size transfer to the SHD (3300~3400msec/frame) for 70~80kB jpeg image, I believe the dithered image (pygtk) is computation limited (~2000msec/frame) for 25~30kB png. I tried to dither the wxPython code, but it is incredible slow due to computation. Thanks, James |
04-24-2012, 10:49 PM | #40 | |
Carpe diem, c'est la vie.
Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
|
Quote:
Read the "Agner Fog" optimization stuff (modern) and the older stuff by Michael Abrash (especially the graphics stuff). Especially, study branch-free and cache-oblivious algorithms, and lock-free queues. P.S. Read the above links, especially "The Aggregate Magic Algorithms" (please). Although some of this is targetted towards Intel CPUs, the ideas and techniques are applicable to embedded computing as well. Last edited by geekmaster; 03-21-2013 at 06:20 PM. Reason: new "cache-oblivious" URL |
|
04-26-2012, 09:55 AM | #41 |
Connoisseur
Posts: 73
Karma: 495694
Join Date: Feb 2009
Device: Between Devices..
|
This is brilliant. I'm now using this to view the output pdf of my latex files. I'm not sure this will make me any more productive, but damn, I love it.
|
04-26-2012, 03:50 PM | #42 |
Zealot
Posts: 130
Karma: 10000
Join Date: Mar 2012
Device: Kindle 3G, Kindle Touch 3G, iRiver Story HD, Sony Reader
|
Hi All,
I found that for dithered screen, PNG is the smallest file size. For grayscale, PNG is smaller is there is only text windows on the screen, and JPEG is smaller is there is any photos or video. I modified the Python program so hat for grayscale, it writes two files, both the jpeg and png. It then determine which is smaller and then updates with the smaller file. Since file transfer remains the largest time component, this results in faster updates. I have found that with Python, to run fast I need to reduce the over number of operations in the critical loop. So in this version I pre-multiply the dither table by 2, so I can remove the last division by 2 or shift. Also, I used 1:2:1 r:g:b instead of 3:6:1 as this will result in less operations. Code:
#!/usr/bin/python #eMonitor #Version 4 modified by jmseight for Kindle/Story (4-26-2012) # Rotate screen 90 deg # Support Dithering if turned on (no flash on videos) # support cropping of dithering table # pre-multiple dither table for faster run time # saves as png for dithered # saves as jpeg and png for grayscale, compare file sizes, then send the smaller file # Reduce quality for faster load # Uses GeekMaster's Dithering Formula (MIT license) # Set to Story HD resolution #based on eMonitor by Kranu #Version 2 (9-1-2011) #Tested on Windows 7 x64, Python 2.7.2, wxPython 2.8 #For more information, see: http://goo.gl/rJoLp #BEGIN SETUP #HTTP Server port=8000 #port of http server (http://127.0.0.1:8000/) #capture region #l,t=(1680,1050-800) l,t=(0,0) #left and right offset from primary monitor w,h=(1024,768) #width and height of capture region fn1 ='shot1.png' #file name of screenshot fn2 ='shot1.jpg' fn = 'shot.png' quality = "50" dt = [ 3,129,34,160,10,136,42,168,192,66,223,97,200,73,231,105,50, 176,18,144,58,184,26,152,239,113,207,81,247,121,215,89,14, 140,46,180,7,133,38,164,203,77,235,109,196,70,227,101,62,188, 30,156,54,180,22,148,251,125,219,93,243,117,211,85 ] # 0-255 dither table white = 255 #white threshold black = 0 #black threshold dithered = False #dithered or not #//END SETUP import wx,socket,os from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer class serv(BaseHTTPRequestHandler): def do_GET(self): self.send_response(200) if self.path.startswith('/'+fn): self.send_header('Content-type','image/jpeg') self.end_headers() app=wx.PySimpleApp() context=wx.ScreenDC() bitmap=wx.EmptyBitmap(w, h, -1) memory=wx.MemoryDC() memory.SelectObject(bitmap) memory.Blit(0, 0, w, h, context, l, t) memory.SelectObject(wx.NullBitmap) image=wx.ImageFromBitmap(bitmap) data=list(image.GetData()) # for i in xrange(0,len(data),3): # data[i]=data[i+1]=data[i+2]=chr(int(0.2989*float(ord(data[i]))+0.5870*float(ord(data[i+1]))+0.1140*float(ord(data[i+2])))) i=0 if dithered: for y in xrange(0,h-1,1): yy=(y&7)<<3 for x in xrange(0,w-1,1): # i = (y*w + x)*3 # j = ((y&7)<<3)|x&7 # if dt[yy|x&7] < (ord(data[i])+(ord(data[i+1])<<1)+ord(data[i+2]))>>2: # if dt[((y&7)*8)|x&7] < (299*ord(data[i])+587*ord(data[i+1])+114*ord(data[i+2]))/1000 : if dt[yy|x&7] < (ord(data[i])+(ord(data[i+1])<<1)+ord(data[i+2])): data[i] = '\xff' else: data[i] = '\x00' i=i+3 else: for y in xrange(0,h-1,1): for x in xrange(0,w-1,1): # i = (y*w + x)*3 # j = ((y&7)<<3)|x&7 data[i+2]=data[i+1]=data[i]= chr((ord(data[i])+(ord(data[i+1])<<1)+ord(data[i+2]))>>2) # data[i] = chr((ord(data[i])+(ord(data[i+1])<<1)+ord(data[i+2]))>>2) # data[i] = chr(int((299*ord(data[i])+587*ord(data[i+1])+144*ord(data[i+2]))/1000)) i=i+3 image.SetData("".join(data)) image = image.Rotate90(False) image.SetOption(wx.IMAGE_OPTION_PNG_FORMAT, str(wx.PNG_TYPE_GREY_RED)) image.SetOption(wx.IMAGE_OPTION_PNG_BITDEPTH, "8") if dithered: image.SaveFile(fn,wx.BITMAP_TYPE_PNG) else: image.SaveFile(fn1,wx.BITMAP_TYPE_PNG) image.SetOption("quality", quality) image.SaveFile(fn2,wx.BITMAP_TYPE_JPEG) size1 = os.stat(fn1).st_size size2 = os.stat(fn2).st_size if size2 < size1: image.SaveFile(fn,wx.BITMAP_TYPE_JPEG) else: image.SaveFile(fn,wx.BITMAP_TYPE_PNG) f=open(fn,'rb') self.wfile.write(f.read()) else: self.send_header('Content-type','text/html') self.end_headers() self.wfile.write('<!doctype html>'\ '<html lang="en">'\ '<head>'\ '<title>eMonitor by Kranu</title>'\ '</head>'\ '<body style="margin:0px;">'\ '<img id="pic" src="'+fn+'" style="float:left;width:100%;height:100%;">'\ '<script type="text/javascript">'\ 'document.getElementById("pic").onload=function() {'\ ' document.getElementById("pic").src="'+fn+'?"+(new Date()).getTime();'\ '}'\ '</script>'\ '</body>'\ '</html>') try: print 'eMonitor by jmseight (based on Kranu)' for j in xrange(0, len(dt)-1, 1): if dt[j] < black: dt[j] = black if dt[j] > white: dt[j] = white for j in xrange(0, len(dt)-1, 1): dt[j] = dt[j] << 2 #Amazon's website is used here for its reliablity. Feel free to change it. s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.connect(("amazon.com",80)) print 'Starting.. ', server=HTTPServer(('',port),serv) print 'Press Ctrl+C to stop' print print 'On your Kindle/Story, visit http://'+s.getsockname()[0]+':'+str(port)+'/' server.serve_forever() except KeyboardInterrupt: print 'Stopping.. ', server.socket.close() print 'Have a nice day!' |
04-26-2012, 04:43 PM | #43 |
Wizard
Posts: 1,379
Karma: 2155307
Join Date: Nov 2010
Location: Goettingen, Germany
Device: Kindle Paperwhite, Kobo Mini
|
maybe it would run with PyPy, further improving speed?
|
04-26-2012, 09:50 PM | #44 |
Zealot
Posts: 130
Karma: 10000
Join Date: Mar 2012
Device: Kindle 3G, Kindle Touch 3G, iRiver Story HD, Sony Reader
|
[UPDATE] I found out that there is a little bug in my code, and these are actually kind resize artifact.
Thanks, James Hi Geekmaster, I don't know if I am doing something wrong, but I am getting some dithering artifacts. Please see the attached screen capture on my K3G. This is a single cyan image. Please see the diagonal line I can actually see it when I use Youtube video, and the vertical lines (showing as horizontal). These images were transfereed with lossless PNG so these are not JPEG compression artifacts. Thanks, James Last edited by jmseight; 04-26-2012 at 11:11 PM. |
04-26-2012, 11:16 PM | #45 |
Zealot
Posts: 130
Karma: 10000
Join Date: Mar 2012
Device: Kindle 3G, Kindle Touch 3G, iRiver Story HD, Sony Reader
|
Hi,
I removed the K3G browser resize artifact by setting the screen to 706x600. This makes perfect dithering. Code:
#!/usr/bin/python #eMonitor #Version 4 modified by jmseight for Kindle/Story (4-26-2012) # Rotate screen 90 deg # Support Dithering if turned on (no flash on videos) # support cropping of dithering table # pre-multiple dither table for faster run time # saves as png for dithered # saves as jpeg and png for grayscale, compare file sizes, then send the smaller file # Reduce quality for faster load # Uses GeekMaster's Dithering Formula (MIT license) # Set to Story HD resolution #based on eMonitor by Kranu #Version 2 (9-1-2011) #Tested on Windows 7 x64, Python 2.7.2, wxPython 2.8 #For more information, see: http://goo.gl/rJoLp #BEGIN SETUP #HTTP Server port=8000 #port of http server (http://127.0.0.1:8000/) #capture region l,t=(0,0) #left and right offset from primary monitor w,h=(706,600) #width and height of capture region fn1 ='shot1.png' #file name of screenshot fn2 ='shot1.jpg' fn = 'shot.png' quality = "50" dt = [ 3,129,34,160,10,136,42,168,192,66,223,97,200,73,231,105,50, 176,18,144,58,184,26,152,239,113,207,81,247,121,215,89,14, 140,46,180,7,133,38,164,203,77,235,109,196,70,227,101,62,188, 30,156,54,180,22,148,251,125,219,93,243,117,211,85 ] # 0-255 dither table white = 255 #white threshold black = 0 #black threshold dithered = True #dithered or not #//END SETUP import wx,socket,os from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer class serv(BaseHTTPRequestHandler): def do_GET(self): self.send_response(200) if self.path.startswith('/'+fn): self.send_header('Content-type','image/jpeg') self.end_headers() app=wx.PySimpleApp() context=wx.ScreenDC() bitmap=wx.EmptyBitmap(w, h, -1) memory=wx.MemoryDC() memory.SelectObject(bitmap) memory.Blit(0, 0, w, h, context, l, t) memory.SelectObject(wx.NullBitmap) image=wx.ImageFromBitmap(bitmap) data=list(image.GetData()) # for i in xrange(0,len(data),3): # data[i]=data[i+1]=data[i+2]=chr(int(0.2989*float(ord(data[i]))+0.5870*float(ord(data[i+1]))+0.1140*float(ord(data[i+2])))) i=0 if dithered: for y in xrange(0,h,1): yy=(y&7)<<3 # i=y*w*3 for x in xrange(0,w,1): # j = ((y&7)<<3)|x&7 # if dt[yy|x&7] < (ord(data[i])+(ord(data[i+1])<<1)+ord(data[i+2]))>>2: # if dt[((y&7)*8)|x&7] < (299*ord(data[i])+587*ord(data[i+1])+114*ord(data[i+2]))/1000 : if dt[yy|x&7] < (ord(data[i])+(ord(data[i+1])<<1)+ord(data[i+2])): data[i] = '\xff' else: data[i] = '\x00' i=i+3 else: for y in xrange(0,h,1): for x in xrange(0,w,1): # i = (y*w + x)*3 # j = ((y&7)<<3)|x&7 data[i+2]=data[i+1]=data[i]= chr((ord(data[i])+(ord(data[i+1])<<1)+ord(data[i+2]))>>2) # data[i] = chr((ord(data[i])+(ord(data[i+1])<<1)+ord(data[i+2]))>>2) # data[i] = chr(int((299*ord(data[i])+587*ord(data[i+1])+144*ord(data[i+2]))/1000)) i=i+3 image.SetData("".join(data)) image = image.Rotate90(False) image.SetOption(wx.IMAGE_OPTION_PNG_FORMAT, str(wx.PNG_TYPE_GREY_RED)) image.SetOption(wx.IMAGE_OPTION_PNG_BITDEPTH, "8") if dithered: image.SaveFile(fn,wx.BITMAP_TYPE_PNG) else: image.SaveFile(fn1,wx.BITMAP_TYPE_PNG) image.SetOption("quality", quality) image.SaveFile(fn2,wx.BITMAP_TYPE_JPEG) size1 = os.stat(fn1).st_size size2 = os.stat(fn2).st_size if size2 < size1: image.SaveFile(fn,wx.BITMAP_TYPE_JPEG) else: image.SaveFile(fn,wx.BITMAP_TYPE_PNG) f=open(fn,'rb') self.wfile.write(f.read()) else: self.send_header('Content-type','text/html') self.end_headers() self.wfile.write('<!doctype html>'\ '<html lang="en">'\ '<head>'\ '<title>eMonitor by Kranu</title>'\ '</head>'\ '<body style="margin:0px;">'\ '<img id="pic" src="'+fn+'" style="float:left;width:100%;height:100%;">'\ '<script type="text/javascript">'\ 'document.getElementById("pic").onload=function() {'\ ' document.getElementById("pic").src="'+fn+'?"+(new Date()).getTime();'\ '}'\ '</script>'\ '</body>'\ '</html>') try: print 'eMonitor by jmseight (based on Kranu)' for j in xrange(0, len(dt), 1): if dt[j] < black: dt[j] = black if dt[j] > white: dt[j] = white for j in xrange(0, len(dt), 1): dt[j] = dt[j] * 4 #Amazon's website is used here for its reliablity. Feel free to change it. s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.connect(("amazon.com",80)) print 'Starting.. ', server=HTTPServer(('',port),serv) print 'Press Ctrl+C to stop' print print 'On your Kindle/Story, visit http://'+s.getsockname()[0]+':'+str(port)+'/' server.serve_forever() except KeyboardInterrupt: print 'Stopping.. ', server.socket.close() print 'Have a nice day!' James Last edited by jmseight; 04-26-2012 at 11:41 PM. |