Beispiel #1
0
    def __init__(self, media_id, scene):
        MediaObject.__init__(self, media_id, scene)

        hexcol = self._media_id[len("string:") : len("string:rrggbb")]
        self.__color = QtGui.QColor("#" + hexcol)
        if not self.__color.isValid():
            raise LoadError("the supplied colour is invalid")

        self.__str = self._media_id[len("string:rrggbb:") :].decode("utf-8")
Beispiel #2
0
    def __init__(self, media_id, scene):
        MediaObject.__init__(self, media_id, scene)

        self.__renderer = QtSvg.QSvgRenderer()
        if not self.__renderer.load(self._media_id):
            raise LoadError("unable to parse SVG file")

        size = self.__renderer.defaultSize()
        self.__width = size.width()
        self.__height = size.height()
Beispiel #3
0
    def __init__(self, media_id, scene, autofit=False):
        MediaObject.__init__(self, media_id, scene)

        self.__autofit = autofit

        self.__loaded = False

        self.__tmpfile = None

        self.__converter = None
        self.__tiler = None

        self.__logger = logging.getLogger(str(self))

        self.__maxtilelevel = 0
        self.__width, self.__height = self.default_size
        self.__aspect_ratio = None

        ## for caching tileblocks
        self.__tileblock = None
        self.__tileblock_id = None
        self.__tileblock_final = False
        self.__tileblock_age = 0

        if TileManager.tiled(self._media_id):
            TileManager.load_tile((self._media_id, 0, 0, 0))
        else:
            self.__logger.info("need to tile media")
            fd, self.__tmpfile = tempfile.mkstemp('.ppm')
            os.close(fd)
            if self._media_id.startswith('http://') or \
               self._media_id.lower().endswith('.html') or \
               self._media_id.lower().endswith('.htm'):
                self.__converter = WebKitConverter(
                    self._media_id, self.__tmpfile)
                self.__ppmfile = self.__tmpfile
                self.__converter.start()
            elif self._media_id.lower().endswith('.pdf'):
                self.__converter = PDFConverter(
                    self._media_id, self.__tmpfile)
                self.__ppmfile = self.__tmpfile
                self.__converter.start()
            elif self._media_id.lower().endswith('.ppm'):
                ## assume media_id is a local PPM file
                self.__logger.info(
                    "assuming media is a local PPM file")
                self.__ppmfile = self._media_id
            else:
                self.__converter = MagickConverter(
                    self._media_id, self.__tmpfile)
                self.__ppmfile = self.__tmpfile
                self.__converter.start()