Esempio n. 1
0
 def next_people(self):
     image, name =  random.choice(namelist)
     avatar_path = os.path.join(BASE_DIR, "photos/peoples", image)
     if os.path.exists(avatar_path):
         dw, dh = wx.DisplaySize()
         w = int(math.ceil(((dw-self.cols*2)*1.0)/(self.cols*1.0)))
         background = Image.new('RGBA', (w*4, w*4), (199, 215, 255, 0))
         image = Image.open(avatar_path)
         val = imgutil._crop((w*2, w*2), image)
         background.paste(Image.open(cStringIO.StringIO(val)), (1*w, 1*w))
         return imgutil.to_data(background)
Esempio n. 2
0
    def next_people(self):
        avatar_path = self.lettory.next_people_avatar()
        if avatar_path and os.path.exists(avatar_path):
            dw, dh = wx.DisplaySize()
            w = imgutil.rcd(((dw-self.cols*2)*1.0)/(self.cols*1.0))
            background = Image.new('RGBA', (w*main_logo['postion'][2], w*main_logo['postion'][2]), main_logo['bg_color'])
            image = Image.open(avatar_path)
            image = imgutil._crop((w*main_logo['postion'][2], w*main_logo['postion'][2]), image, False)
            background.paste(image, (0, 0))
#            body_font = ImageFont.truetype(os.path.join(BASE_DIR, "xxk.ttf"), lottery_people['font_size'])
#            imgutil.draw_word_wrap(
#                    background,
#                    "%s:%s" % (id, name), 
#                    lottery_people['position'][0], 
#                    lottery_people['position'][1], 
#                    max_width=1000,
#                    fill=lottery_people['font_color'],
#                    font=body_font
#                )
            return imgutil.to_data(background)