本文整理汇总了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;
}
示例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");
}
示例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");
}
示例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);
}
}
示例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);
}
示例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");
}
示例7: getAtlasData
import com.badlogic.gdx.graphics.g2d.TextureAtlas; //导入方法依赖的package包/类
public TextureAtlas.TextureAtlasData getAtlasData() {
return atlasData;
}
示例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");
}
示例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");
}