def GetImage(self, picture): key = picture.GetKey() if key not in self._wxImgCache: pilImg = PILBackend.GetThumbnail(picture, width=ImageCache.SIZE) wxImg = wx.Image(PILBackend.ImageToStream(pilImg), wx.BITMAP_TYPE_JPEG) self._wxImgCache[key] = wxImg return self._wxImgCache[key]
def run(self): self._abort = False for __ in range(20): time.sleep(0.1) if self._abort: return pilImg = PILBackend.GetImage(self._picture) wxImg = wx.Image(PILBackend.ImageToStream(pilImg), wx.BITMAP_TYPE_JPEG) if not self._abort: self._callbackOnDone(wxImg)
def GetThumbBmp(self, picture): key = picture.GetKey() if key not in self._wxBmpCache: pilImg = self._pilCache.get(key) if pilImg is None: self._pilCache[key] = self._inScalingQueue self.scaleThread.queue.append(picture) return self.thumb elif pilImg is self._inScalingQueue: return self.thumb else: # pilImg = self._pilCache[key] wxImg = wx.Image(PILBackend.ImageToStream(pilImg), wx.BITMAP_TYPE_JPEG) self._wxBmpCache[key] = wxImg.ConvertToBitmap() return self._wxBmpCache[key]
def __init__(self, parent, size=wx.DefaultSize, filename=None): self.filename = filename if not LinkOpenPfs.BMP_MAP.has_key(filename): prjFile = ProjectFile(filename=filename) imgCount = prjFile.GetPicCount() img = prjFile.GetPreviewThumb() if img is not None: wxImg = wx.ImageFromStream(PILBackend.ImageToStream(img), wx.BITMAP_TYPE_JPEG) bmp = wxImg.ConvertToBitmap() else: bmp = wx.ArtProvider.GetBitmap("PFS_ICON_48", wx.ART_OTHER) descr = "%d images" % imgCount LinkOpenPfs.BMP_MAP[filename] = (bmp, descr) bmp, descr = LinkOpenPfs.BMP_MAP[filename] IconLabelLink.__init__(self, parent, size, os.path.splitext(os.path.basename(filename))[0], bmp, descr)