TextureAtlasData atlas = new TextureAtlasData(new FileHandle(atlasFile), new FileHandle(imageDir), false); unpacker.splitAtlas(atlas, outputDir);
TextureAtlasData atlas = new TextureAtlasData(new FileHandle(atlasFile), new FileHandle(imageDir), false); unpacker.splitAtlas(atlas, outputDir);
TextureAtlasData textureAtlasData = new TextureAtlasData(new FileHandle(packFile), new FileHandle(packFile), false); for (Page page : pages) { for (Rect rect : page.outputRects) {
TextureAtlas.TextureAtlasData atlasData = new TextureAtlas.TextureAtlasData( Gdx.files.absolute(pack.getOutputDir()).child(pack.getCanonicalFilename()), Gdx.files.absolute(pack.getOutputDir()), false);
TextureAtlasData atlas = new TextureAtlasData(new FileHandle(atlasFile), new FileHandle(imageDir), false); unpacker.splitAtlas(atlas, outputDir);
public static void main (String[] args) { TextureUnpacker unpacker = new TextureUnpacker(); String atlasFile = null, imageDir = null, outputDir = null; // parse the arguments and display the help text if there is a problem with the command line arguments switch (unpacker.parseArguments(args)) { case 0: System.out.println(HELP); return; case 3: outputDir = args[2]; case 2: imageDir = args[1]; case 1: atlasFile = args[0]; } File atlasFileHandle = new File(atlasFile); String atlasParentPath = atlasFileHandle.getParentFile().getAbsolutePath(); // Set the directory variables to a default when they weren't given in the variables if (imageDir == null) imageDir = atlasParentPath; if (outputDir == null) outputDir = (new File(atlasParentPath, DEFAULT_OUTPUT_PATH)).getAbsolutePath(); // Opens the atlas file from the specified filename TextureAtlasData atlas = new TextureAtlasData(new FileHandle(atlasFile), new FileHandle(imageDir), false); unpacker.splitAtlas(atlas, outputDir); } }
TextureAtlas.TextureAtlasData atlasData = new TextureAtlas.TextureAtlasData( Gdx.files.absolute(pack.getOutputDir()).child(pack.getCanonicalFilename()), Gdx.files.absolute(pack.getOutputDir()), false);
@Override public void processPackage(PackProcessingNode node) throws Exception { PackModel pack = node.getPack(); ProjectModel project = node.getProject(); FileHandle packFileHandle = Gdx.files.absolute(pack.getOutputDir()).child(pack.getCanonicalFilename()); FileHandle imagesDirFileHandle = Gdx.files.absolute(pack.getOutputDir()); TextureAtlas.TextureAtlasData atlasData = new TextureAtlas.TextureAtlasData( packFileHandle, imagesDirFileHandle, false); long totalSize = 0; // Bytes totalSize += packFileHandle.length(); for (TextureAtlas.TextureAtlasData.Page page : atlasData.getPages()) { long pageSize = page.textureFile.length(); totalSize += pageSize; } node.addMetadata(PackProcessingNode.META_FILE_SIZE, totalSize); System.out.println("Total pack files size is " + totalSize + " bytes"); } }
@Override public Array<AssetDescriptor> getDependencies (String fileName, FileHandle atlasFile, TextureAtlasParameter parameter) { FileHandle imgDir = atlasFile.parent(); if (parameter != null) data = new TextureAtlasData(atlasFile, imgDir, parameter.flip); else { data = new TextureAtlasData(atlasFile, imgDir, false); } Array<AssetDescriptor> dependencies = new Array(); for (Page page : data.getPages()) { TextureParameter params = new TextureParameter(); params.format = page.format; params.genMipMaps = page.useMipMaps; params.minFilter = page.minFilter; params.magFilter = page.magFilter; dependencies.add(new AssetDescriptor(page.textureFile, Texture.class, params)); } return dependencies; }
@LmlAction("launchUnpackProcess") void launchUnpackProcess() { try { Gdx.app.log(TAG, "Start texture unpacking"); FileHandle outputDir = Gdx.files.absolute(edtOutputDir.getText()); FileHandle atlasFile = FileUtils.obtainIfExists(edtAtlasPath.getText()); if (atlasFile == null) throw new IllegalStateException("Atlas file does not exist: " + edtAtlasPath.getText()); TextureAtlas.TextureAtlasData atlasData = new TextureAtlas.TextureAtlasData(atlasFile, atlasFile.parent(), false); TextureUnpacker textureUnpacker = new TextureUnpacker(); textureUnpacker.splitAtlas(atlasData, outputDir.path()); Gdx.app.log(TAG, "Texture unpacking successfully finished"); showSuccessfulDialog(outputDir); } catch (Exception e) { Gdx.app.log(TAG, "Texture unpacking failed with error", e); showErrorDialog(e); } }
@Override public void processPackage(PackProcessingNode node) throws Exception { PackModel pack = node.getPack(); ProjectModel project = node.getProject(); FileHandle packFileHandle = Gdx.files.absolute(pack.getOutputDir()).child(pack.getCanonicalFilename()); FileHandle imagesDirFileHandle = Gdx.files.absolute(pack.getOutputDir()); TextureAtlas.TextureAtlasData atlasData = new TextureAtlas.TextureAtlasData( packFileHandle, imagesDirFileHandle, false); int pageAmount = atlasData.getPages().size; node.addMetadata(PackProcessingNode.META_ATLAS_PAGES, pageAmount); System.out.println(pageAmount + " pages"); } }
/** @param flip If true, all regions loaded will be flipped for use with a perspective where 0,0 is the upper left corner. */ public TextureAtlas (FileHandle packFile, FileHandle imagesDir, boolean flip) { this(new TextureAtlasData(packFile, imagesDir, flip)); }
public static void scaleAtlas(File orgAtlas, File destDir, float scale) throws IOException { File tmpDir = DesktopUtils.createTempDirectory(); EditorLogger.debug("SCALING: " + orgAtlas.getName()); unpackAtlas(orgAtlas, tmpDir); String atlasParentPath = orgAtlas.getParentFile().getAbsolutePath(); TextureAtlasData atlasData = new TextureAtlasData(new FileHandle(orgAtlas), new FileHandle(atlasParentPath), false); String outputFormat = atlasData.getPages().get(0).textureFile.extension(); int maxWH = (int) (getRecommendedAtlasSize() * scale); createAtlas(tmpDir.getAbsolutePath(), destDir.getAbsolutePath(), orgAtlas.getName(), scale, maxWH, maxWH, atlasData.getPages().get(0).minFilter, atlasData.getPages().get(0).magFilter, outputFormat); DesktopUtils.removeDir(tmpDir.getAbsolutePath()); }
public static void unpackAtlas(File orgAtlas, File destDir) { CustomTextureUnpacker unpacker = new CustomTextureUnpacker(); String atlasParentPath = orgAtlas.getParentFile().getAbsolutePath(); TextureAtlasData atlas = new TextureAtlasData(new FileHandle(orgAtlas), new FileHandle(atlasParentPath), false); unpacker.splitAtlas(atlas, destDir.getAbsolutePath()); }
public AtlasModel(FileHandle atlasFile) { this.atlasFile = atlasFile; this.atlasData = new TextureAtlasData(atlasFile, atlasFile.parent(), false); atlasPath = atlasFile.file().getAbsolutePath(); generatePages(atlasData); }
TextureAtlasData textureAtlasData = new TextureAtlasData(new FileHandle(packFile), new FileHandle(packFile), false); for (Page page : pages) { for (Rect rect : page.outputRects) {
@Override public Array<AssetDescriptor> getDependencies (String fileName, FileHandle atlasFile, TextureAtlasParameter parameter) { FileHandle imgDir = atlasFile.parent(); if (parameter != null) data = new TextureAtlasData(atlasFile, imgDir, parameter.flip); else { data = new TextureAtlasData(atlasFile, imgDir, false); } Array<AssetDescriptor> dependencies = new Array(); for (Page page : data.getPages()) { TextureParameter params = new TextureParameter(); params.format = page.format; params.genMipMaps = page.useMipMaps; params.minFilter = page.minFilter; params.magFilter = page.magFilter; dependencies.add(new AssetDescriptor(page.textureFile, Texture.class, params)); } return dependencies; }
@Override public Array<AssetDescriptor> getDependencies (String fileName, FileHandle atlasFile, TextureAtlasParameter parameter) { FileHandle imgDir = atlasFile.parent(); if (parameter != null) data = new TextureAtlasData(atlasFile, imgDir, parameter.flip); else { data = new TextureAtlasData(atlasFile, imgDir, false); } Array<AssetDescriptor> dependencies = new Array(); for (Page page : data.getPages()) { TextureParameter params = new TextureParameter(); params.format = page.format; params.genMipMaps = page.useMipMaps; params.minFilter = page.minFilter; params.magFilter = page.magFilter; dependencies.add(new AssetDescriptor(page.textureFile, Texture.class, params)); } return dependencies; }
/** @param flip If true, all regions loaded will be flipped for use with a perspective where 0,0 is the upper left corner. */ public TextureAtlas (FileHandle packFile, FileHandle imagesDir, boolean flip) { this(new TextureAtlasData(packFile, imagesDir, flip)); }
/** @param flip If true, all regions loaded will be flipped for use with a perspective where 0,0 is the upper left corner. */ public TextureAtlas (FileHandle packFile, FileHandle imagesDir, boolean flip) { this(new TextureAtlasData(packFile, imagesDir, flip)); }