Ejemplo n.º 1
0
    def addFile(self, relPath, fullPath):
        """Adds the specific file to the sprite packer."""

        fileType = relPath.split('.')[-1]
        if fileType not in self.types:
            raise Exception('Unsupported image format: %s' % fileType)

        # Load image and grab required information
        img = ImgInfo(fullPath)
        width, height = img.getSize()
        checksum = img.getChecksum()

        self.files.append(SpriteFile(width, height, relPath, fullPath, checksum))

        Console.debug('- Found image "%s" (%dx%dpx)' % (relPath, width, height))
Ejemplo n.º 2
0
    def __collectImages(self):
        """
        Stores __images as { dirName : { assetName : [projectObj, imageWidth, imageHeight] }}
        """

        images = {}
        assets = self.__assets
        for name in assets:
            # white list matching
            if not name.endswith((".png", ".jpeg", ".jpg", ".gif")):
                continue

            resdir = dirname(name)
            if not resdir in images:
                images[resdir] = {}

            entry = assets[name]
            info = ImgInfo(entry["path"]).getInfo()
            if info is None:
                raise Exception("Invalid image: %s" % name)

            images[resdir][basename(name)] = [
                entry["project"], info[0], info[1]
            ]

        self.__images = images
Ejemplo n.º 3
0
    def addFile(self, relPath, fullPath):
        """Adds the specific file to the sprite packer."""

        fileType = relPath.split('.')[-1]
        if fileType not in self.types:
            raise Exception('Unsupported image format: %s' % fileType)

        # Load image and grab required information
        img = ImgInfo(fullPath)
        width, height = img.getSize()
        checksum = img.getChecksum()

        self.files.append(
            SpriteFile(width, height, relPath, fullPath, checksum))

        Console.debug('- Found image "%s" (%dx%dpx)' %
                      (relPath, width, height))
Ejemplo n.º 4
0
    def addFile(self, relPath, fullPath):
        """Adds the specific file to the sprite packer."""

        fileType = relPath.split('.')[-1]
        if fileType not in self.types:
            raise Exception('Unsupported image format: %s' % fileType)

        # Load image and grab required information
        img = ImgInfo(fullPath)
        w, h = img.getSize()
        checksum = img.getChecksum()
        del img

        # TODO crop transparent "borders"
        # TODO allow for rotation

        self.files.append(SpriteFile(w, h, relPath, fullPath, checksum))

        Console.debug('- Found image "%s" (%dx%dpx)' % (relPath, w, h))
Ejemplo n.º 5
0
    def addFile(self, relPath, fullPath):
        """Adds the specific file to the sprite packer."""

        fileType = relPath.split(".")[-1]
        if fileType not in self.types:
            raise Exception("Unsupported image format: %s" % fileType)

        # Load image and grab required information
        img = ImgInfo(fullPath)
        w, h = img.getSize()
        checksum = img.getChecksum()
        del img

        # TODO crop transparent "borders"
        # TODO allow for rotation

        self.files.append(SpriteFile(w, h, relPath, fullPath, checksum))

        debug('- Found image "%s" (%dx%dpx)' % (relPath, w, h))