Beispiel #1
0
    def encode(self, text, **kw):
	border = kw.get('border', self.border)
	w = kw.get('width', self.width) - border * 2
	v = kw.get('version', self.version)
	mode = kw.get('mode', self.mode.ALNUM)
	eclevel = kw.get('eclevel', self.eclevel.L)
	case_sensitive = kw.get('case_sensitive', self.case_sensitive)

	if v > 40:
	    raise InvalidArgsError('version should be between 1 and 40')

	version, width, data = _encode(text+'\0', case_sensitive, v, eclevel, mode)
	
	rawdata = ''
	dotsize = w / width
	realwidth = width * dotsize

	for y in range(width):
	    line = ''
	    for x in range(width):
		if ord(data[y*width+x]) % 2:
		    line += dotsize * chr(0)
		else:
		    line += dotsize * chr(255)
	    lines = dotsize * line
	    rawdata += lines
	
	image = fromstring('L', (realwidth, realwidth), rawdata)
	return expand(image, border, 255)
Beispiel #2
0
    def run(self,
            robotip=DEFAULT_IP,
            imagename="image",
            port=9559):  # Opens a tkinter window showing application
        '''
        :param robotip: ip of bot
        :type: string

        :param port: port of bot on ip
        :type: int
        '''
        #try:
        if __name__ == "__main__":
            try:
                tkinst = Tk()
                frame = Frame(tkinst, height=640, width=480)
                frame.bind("<Key>", move)
                frame.pack()
                subscriberID = self.vidproxy.subscribe(
                    "subscriberID", 0, 11, 10)  # 0,11,10 is correct numbers
                while True:
                    image = self.vidproxy.getImageRemote(subscriberID)
                    im = fromstring("RGB", (image[0], image[1]),
                                    str(bytearray(image[6])))
                    im.save(imagename + ".jpg")

                    showimage = ImageTk.PhotoImage(
                        Image.open(imagename + ".jpg").resize(
                            (image[0] * 4, image[1] * 4), Image.ANTIALIAS))
                    w = Label(frame, image=showimage)
                    w.image = showimage
                    w.pack()
                    tkinst.update()
                    w.destroy()
            except Exception, e:
                print(str(e))
                self.vidproxy.unsubscribe(subscriberID)
Beispiel #3
0
                            (image[0] * 4, image[1] * 4), Image.ANTIALIAS))
                    w = Label(frame, image=showimage)
                    w.image = showimage
                    w.pack()
                    tkinst.update()
                    w.destroy()
            except Exception, e:
                print(str(e))
                self.vidproxy.unsubscribe(subscriberID)
        else:
            try:
                subscriberID = self.vidproxy.subscribe(
                    "subscriberID", 0, 11, 10)  # 0,11,10 is correct numbers
                image = self.vidproxy.getImageRemote(subscriberID)
                self.vidproxy.unsubscribe(subscriberID)
                im = fromstring("RGB", (160, 120), str(bytearray(image[6])))
                im.save(imagename + ".jpg")
            except Exception, e:
                print(str(e))


class PlayMusic(UpgradedBot):
    '''Plays music'''
    def run(self,
            musiclocation="Dean-Martin-Let-it-Snow.wav",
            robotip=DEFAULT_IP,
            port=9559):
        '''
        :param musiclocation: location of music file on system
        :type: string
Beispiel #4
0
def BitmapToPIL(bmp):
    imageData = wx.ImageFromBitmap(bmp).GetData()
    imagePIL = fromstring('RGB', (bmp.GetWidth(), bmp.GetHeight()), imageData)
    imagePIL = imagePIL.convert('RGB')
    return imagePIL
Beispiel #5
0
def bitmap_to_pil(bmp):
    imageData = wx.ImageFromBitmap(bmp).GetData()
    imagePIL = fromstring('RGB', (bmp.get_width(), bmp.get_height()), imageData)
    imagePIL = imagePIL.convert('RGB')
    return imagePIL
Beispiel #6
0
def bitmap_to_pil(bmp):
    imageData = wx.ImageFromBitmap(bmp).GetData()
    imagePIL = fromstring('RGB', (bmp.get_width(), bmp.get_height()),
                          imageData)
    imagePIL = imagePIL.convert('RGB')
    return imagePIL