def Process(self, atlas: TexturePackerAtlas, outputFilename: str) -> None: dstList = [] # type: List[int] AddHeader(dstList, 1) # make room for a number of bytes written entry and store the offset where it was written so we can pacth it later offset = len(dstList) AddUInt32(dstList, 0) AddEncodedUInt32(dstList, len(atlas.Entries)) for entry in atlas.Entries: rectX = entry.Frame.X - entry.SpriteSourceSize.X rectY = entry.Frame.Y - entry.SpriteSourceSize.Y rectWidth = entry.SourceSize.Width rectHeight = entry.SourceSize.Height self.__AddEntry(dstList, rectX, rectY, rectWidth, rectHeight, entry.Frame.X, entry.Frame.Y, entry.Frame.Width, entry.Frame.Height, entry.FullFilenameWithoutExt) # Write the number of bytes that were written to the extended header # -4 because we dont count the 'size' entry bytesWritten = len(dstList) - offset - 4 SetUInt32(dstList, offset, bytesWritten) content = bytearray(dstList) outputFilename = '%s.%s' % (outputFilename, 'bta') IOUtil.WriteBinaryFileIfChanged(outputFilename, content)
def Process(self, atlas, outputFilename): pathInfo = self.__BuildPathDirectory(atlas.Entries) #self.__DebugPaths(atlas.Entries, pathInfo) entryDict = {} for entry in pathInfo[1]: entryDict[entry[2]+entry[1]] = entry list = [] AddHeader(list, 2); # make room for a number of bytes written entry and store the offset where it was written so we can pacth it later offset = len(list) AddUInt32(list, 0); self.__AddPathList(list, pathInfo[0]) AddEncodedUInt32(list, len(atlas.Entries)) for entry in atlas.Entries: rectX = entry.Frame.X - entry.SpriteSourceSize.X rectY = entry.Frame.Y - entry.SpriteSourceSize.Y rectWidth = entry.SourceSize.Width rectHeight = entry.SourceSize.Height self.__AddEntry(list, rectX, rectY, rectWidth, rectHeight, entry.Frame.X, entry.Frame.Y, entry.Frame.Width, entry.Frame.Height, entryDict[entry.FullFilenameWithoutExt]) # Write the number of bytes that were written to the extended header # -4 because we dont count the 'size' entry bytesWritten = len(list) - offset - 4 SetUInt32(list, offset, bytesWritten) content = bytearray(list) outputFilename = '%s.%s' % (outputFilename, 'bta') IOUtil.WriteBinaryFileIfChanged(outputFilename, content)
def Process(self, atlas: TexturePackerAtlas, outputFilename: str) -> None: pathInfo = self.__BuildPathDirectory(atlas.Entries) self.__DebugPaths(atlas.Entries, pathInfo) entryDict = {} # type: Dict[str, Tuple[int,str,str]] for pathEntry in pathInfo[1]: entryDict[pathEntry[2]+pathEntry[1]] = pathEntry entryList = [] # type: List[int] AddHeader(entryList, 0x1001); # make room for a number of bytes written entry and store the offset where it was written so we can pacth it later offset = len(entryList) AddUInt32(entryList, 0); self.__AddPathList(entryList, pathInfo[0]) AddEncodedUInt32(entryList, len(atlas.Entries)) for entry in atlas.Entries: rectX = entry.Frame.X - entry.SpriteSourceSize.X rectY = entry.Frame.Y - entry.SpriteSourceSize.Y rectWidth = entry.SourceSize.Width rectHeight = entry.SourceSize.Height self.__AddEntry(entryList, rectX, rectY, rectWidth, rectHeight, entry.Frame.X, entry.Frame.Y, entry.Frame.Width, entry.Frame.Height, entryDict[entry.FullFilenameWithoutExt]) # Write the number of bytes that were written to the extended header # -4 because we dont count the 'size' entry bytesWritten = len(entryList) - offset - 4 SetUInt32(entryList, offset, bytesWritten) content = bytearray(entryList) outputFilename = '{0}.{1}'.format(outputFilename, 'bta') IOUtil.WriteBinaryFileIfChanged(outputFilename, content)