예제 #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)
예제 #2
0
 def next_background(self):
     n = 0
     dw, dh = wx.DisplaySize()
     w = int(math.ceil(((dw-self.cols*2)*1.0)/(self.cols*1.0)))
     y = top = ((dh%w)/4)
     x = left = ((dw%w)/2)
     rows = dh/w
     
     background = Image.new('RGBA', (dw, dh), (255, 255, 255, 0))
 
     while n < (self.cols*rows):
         if n >= (self.cols*2 + 5) and \
             n < (self.cols*6 + 5) and \
             ((n-5)%self.cols == 0 or \
              (n-6)%self.cols == 0 or \
              (n-7)%self.cols == 0 or\
              (n-8)%self.cols == 0):
             pass
         else:
             image =  self._image_cache.get(self.photos[self.cur], None)
             if not image:
                 image = Image.open(os.path.join(BASE_DIR, "photos/logos", self.photos[self.cur]))
                 self._image_cache[self.photos[self.cur]] = image
             val = imgutil._crop((w-2, w-2), image)
             background.paste(Image.open(cStringIO.StringIO(val)), (x, y))
         n += 1
         self.cur += 1
         if n % self.cols == 0:
             x = left
             y += w
         else:
             x += w
         if self.cur >= len(self.photos):
             self.cur = 0
             
     val = imgutil._crop((w*4, w*4), Image.open(os.path.join(BASE_DIR, "photos", "main.png")))
     background.paste(Image.open(cStringIO.StringIO(val)), (left+5*w, top+2*w))
     return background
예제 #3
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)
예제 #4
0
    def next_background(self):
        n = 0
        dw, dh = wx.DisplaySize()
        w = int(math.ceil(((dw-self.cols*2)*1.0)/(self.cols*1.0)))
        y = top = ((dh%w)/4)
        x = left = ((dw%w)/2)
        rows = dh/w
        print "width: %s" % w
        background = Image.new('RGBA', (dw, dh), (255, 255, 255, 0))
    
        while n < (self.cols*rows) and self.photos:
            need_paste = True
            if n >= (self.cols*main_logo['postion'][1] + 5) and n < (self.cols*(main_logo['postion'][0]+1) + 5):
                for i in range(main_logo['postion'][2]):
                    if (n - (main_logo['postion'][0]+i))%self.cols == 0:
                        need_paste = False
            if need_paste and self.photos:
                image =  self._image_cache.get(self.photos[self.cur], None)
                if not image:
                    image = Image.open(os.path.join(BASE_DIR, "photos", self.photos[self.cur]))
                    self._image_cache[self.photos[self.cur]] = image
                image.thumbnail((w-2, w-2), Image.ANTIALIAS)
#                image = imgutil._crop((w-2, w-2), image, True)
                background.paste(image, (x, y))
            n += 1
            self.cur += 1
            if n % self.cols == 0:
                x = left
                y += w
            else:
                x += w
            if self.cur >= len(self.photos):
                self.cur = 0

        image = imgutil._crop((w*main_logo['postion'][2], w*main_logo['postion'][2]), 
                              Image.open(os.path.join(BASE_DIR, "photos", "Steve-Jobs-iOSCon.jpg")),
                              False)
        background.paste(image, (left+main_logo['postion'][0]*w, top+main_logo['postion'][1]*w))
        return background