當前位置: 首頁>>代碼示例>>Java>>正文


Java TextureAtlas.TextureAtlasData方法代碼示例

本文整理匯總了Java中com.badlogic.gdx.graphics.g2d.TextureAtlas.TextureAtlasData方法的典型用法代碼示例。如果您正苦於以下問題:Java TextureAtlas.TextureAtlasData方法的具體用法?Java TextureAtlas.TextureAtlasData怎麽用?Java TextureAtlas.TextureAtlasData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.badlogic.gdx.graphics.g2d.TextureAtlas的用法示例。


在下文中一共展示了TextureAtlas.TextureAtlasData方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: extractImage

import com.badlogic.gdx.graphics.g2d.TextureAtlas; //導入方法依賴的package包/類
public BufferedImage extractImage(TextureAtlas.TextureAtlasData atlas, String regionName, int[] splits) {
    for (TextureAtlas.TextureAtlasData.Region region : atlas.getRegions()) {
        if(region.name.equals(regionName)) {
            TextureAtlas.TextureAtlasData.Page page = region.page;
            BufferedImage img = null;
            try {
                img = ImageIO.read(page.textureFile.file());
            } catch (IOException e) {

            }
            region.splits = splits;
            return extractNinePatch(img, region);
        }
    }
    return null;
}
 
開發者ID:whitecostume,項目名稱:libgdx_ui_editor,代碼行數:17,代碼來源:ImageUtils.java

示例2: processPackage

import com.badlogic.gdx.graphics.g2d.TextureAtlas; //導入方法依賴的package包/類
@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");
}
 
開發者ID:crashinvaders,項目名稱:gdx-texture-packer-gui,代碼行數:17,代碼來源:PageAmountMetadataProcessor.java

示例3: processPackage

import com.badlogic.gdx.graphics.g2d.TextureAtlas; //導入方法依賴的package包/類
@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");
}
 
開發者ID:crashinvaders,項目名稱:gdx-texture-packer-gui,代碼行數:23,代碼來源:FileSizeMetadataProcessor.java

示例4: launchUnpackProcess

import com.badlogic.gdx.graphics.g2d.TextureAtlas; //導入方法依賴的package包/類
@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);
    }
}
 
開發者ID:crashinvaders,項目名稱:gdx-texture-packer-gui,代碼行數:21,代碼來源:TextureUnpackerDialogController.java

示例5: AtlasModel

import com.badlogic.gdx.graphics.g2d.TextureAtlas; //導入方法依賴的package包/類
public AtlasModel(FileHandle atlasFile) {
    this.atlasFile = atlasFile;
    this.atlasData = new TextureAtlas.TextureAtlasData(atlasFile, atlasFile.parent(), false);
    this.atlas = new TextureAtlas(atlasData);
    atlasPath = atlasFile.file().getAbsolutePath();

    generatePages(atlas);
}
 
開發者ID:crashinvaders,項目名稱:gdx-texture-packer-gui,代碼行數:9,代碼來源:AtlasModel.java

示例6: processPackage

import com.badlogic.gdx.graphics.g2d.TextureAtlas; //導入方法依賴的package包/類
@Override
public void processPackage(PackProcessingNode node) throws Exception {
    PackModel pack = node.getPack();
    ProjectModel project = node.getProject();

    if (project.getFileType().getClass() != PngFileTypeModel.class) return;

    PngFileTypeModel fileType = (PngFileTypeModel) project.getFileType();

    if (fileType.getCompression() == null || fileType.getCompression().getType() != PngCompressionType.TINY_PNG) return;

    System.out.println("Tinify compression started");

    TextureAtlas.TextureAtlasData atlasData = new TextureAtlas.TextureAtlasData(
                    Gdx.files.absolute(pack.getOutputDir()).child(pack.getCanonicalFilename()),
                    Gdx.files.absolute(pack.getOutputDir()), false);

    float compressionRateSum = 0f;
    for (TextureAtlas.TextureAtlasData.Page page : atlasData.getPages()) {
        long preCompressedSize = page.textureFile.length();

        tinifyService.compressImageSync(page.textureFile);

        long postCompressedSize = page.textureFile.length();
        float pageCompression = ((postCompressedSize-preCompressedSize) / (float)preCompressedSize);
        compressionRateSum += pageCompression;

        System.out.println(String.format(Locale.US, "%s compressed for %+.2f%%", page.textureFile.name(), pageCompression*100f));
    }
    node.addMetadata(PackProcessingNode.META_COMPRESSION_RATE, compressionRateSum / atlasData.getPages().size);

    System.out.println("Tinify compression finished");
}
 
開發者ID:crashinvaders,項目名稱:gdx-texture-packer-gui,代碼行數:34,代碼來源:TinifyCompressingProcessor.java

示例7: getAtlasData

import com.badlogic.gdx.graphics.g2d.TextureAtlas; //導入方法依賴的package包/類
public TextureAtlas.TextureAtlasData getAtlasData() {
    return atlasData;
}
 
開發者ID:crashinvaders,項目名稱:gdx-texture-packer-gui,代碼行數:4,代碼來源:AtlasModel.java

示例8: processPackage

import com.badlogic.gdx.graphics.g2d.TextureAtlas; //導入方法依賴的package包/類
@Override
public void processPackage(PackProcessingNode node) throws Exception {
    PackModel pack = node.getPack();
    ProjectModel project = node.getProject();

    if (project.getFileType().getClass() != PngFileTypeModel.class) return;

    PngFileTypeModel fileType = (PngFileTypeModel) project.getFileType();

    if (fileType.getCompression() == null || fileType.getCompression().getType() != PngCompressionType.PNGTASTIC) return;

    System.out.println("Pngtastic compression started");

    PngtasticCompressionModel compModel = fileType.getCompression();
    PngOptimizer pngOptimizer = new PngOptimizer(LOG_LEVEL);

    // Compression section
    {
        TextureAtlas.TextureAtlasData atlasData = new TextureAtlas.TextureAtlasData(
                        Gdx.files.absolute(pack.getOutputDir()).child(pack.getCanonicalFilename()),
                        Gdx.files.absolute(pack.getOutputDir()), false);

        for (TextureAtlas.TextureAtlasData.Page page : atlasData.getPages()) {
            BufferedInputStream bis = null;
            try {
                String fileName = page.textureFile.file().getAbsolutePath();
                bis = new BufferedInputStream(new FileInputStream(fileName));
                PngImage image = new PngImage(bis, LOG_LEVEL);
                image.setFileName(fileName);
                pngOptimizer.optimize(
                        image,
                        fileName,
                        compModel.isRemoveGamma(),
                        compModel.getLevel());
            } finally {
                if (bis != null) {
                    bis.close();
                }
            }
        }
    }

    // Compute compression rate for metadata
    {
        float compressionRate = 0f;
        for (PngOptimizer.OptimizerResult optimizerResult : pngOptimizer.getResults()) {
            float localCompressionRate = (optimizerResult.getOptimizedFileSize() - optimizerResult.getOriginalFileSize()) / (float) optimizerResult.getOriginalFileSize();
            compressionRate += localCompressionRate / pngOptimizer.getResults().size();
        }
        node.addMetadata(PackProcessingNode.META_COMPRESSION_RATE, compressionRate);
    }

    System.out.println("Pngtastic compression finished");
}
 
開發者ID:crashinvaders,項目名稱:gdx-texture-packer-gui,代碼行數:55,代碼來源:PngtasticCompressingProcessor.java

示例9: processPackage

import com.badlogic.gdx.graphics.g2d.TextureAtlas; //導入方法依賴的package包/類
@Override
public void processPackage(PackProcessingNode node) throws Exception {
    PackModel pack = node.getPack();
    ProjectModel project = node.getProject();

    if (project.getFileType().getClass() != PngFileTypeModel.class) return;

    PngFileTypeModel fileType = (PngFileTypeModel) project.getFileType();

    if (fileType.getCompression() == null || fileType.getCompression().getType() != PngCompressionType.ZOPFLI) return;

    System.out.println("Zopfli compression started");

    ZopfliCompressionModel compModel = fileType.getCompression();
    PngOptimizer pngOptimizer = new PngOptimizer(LOG_LEVEL);
    pngOptimizer.setCompressor("zopfli", compModel.getIterations());

    // Compression section
    {
        TextureAtlas.TextureAtlasData atlasData = new TextureAtlas.TextureAtlasData(
                        Gdx.files.absolute(pack.getOutputDir()).child(pack.getCanonicalFilename()),
                        Gdx.files.absolute(pack.getOutputDir()), false);

        for (TextureAtlas.TextureAtlasData.Page page : atlasData.getPages()) {
            PngImage image = new PngImage(page.textureFile.file().getAbsolutePath(), LOG_LEVEL);
            pngOptimizer.optimize(
                    image,
                    page.textureFile.file().getAbsolutePath(),
                    false,
                    compModel.getLevel());
        }
    }

    // Compute compression rate for metadata
    {
        float compressionRate = 0f;
        for (PngOptimizer.OptimizerResult optimizerResult : pngOptimizer.getResults()) {
            float localCompressionRate = (optimizerResult.getOptimizedFileSize() - optimizerResult.getOriginalFileSize()) / (float) optimizerResult.getOriginalFileSize();
            compressionRate += localCompressionRate / pngOptimizer.getResults().size();
        }
        node.addMetadata(PackProcessingNode.META_COMPRESSION_RATE, compressionRate);
    }

    System.out.println("Zopfli compression finished");
}
 
開發者ID:crashinvaders,項目名稱:gdx-texture-packer-gui,代碼行數:46,代碼來源:ZopfliCompressingProcessor.java


注:本文中的com.badlogic.gdx.graphics.g2d.TextureAtlas.TextureAtlasData方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。