• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Region类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.badlogic.gdx.graphics.g2d.TextureAtlas.TextureAtlasData.Region的典型用法代码示例。如果您正苦于以下问题:Java Region类的具体用法?Java Region怎么用?Java Region使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Region类属于com.badlogic.gdx.graphics.g2d.TextureAtlas.TextureAtlasData包,在下文中一共展示了Region类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: extractNinePatch

import com.badlogic.gdx.graphics.g2d.TextureAtlas.TextureAtlasData.Region; //导入依赖的package包/类
/** Extract a ninepatch from a texture atlas, according to the android specification.
 * @see <a href="http://developer.android.com/guide/topics/graphics/2d-graphics.html#nine-patch">ninepatch specification</a>
 * @param page The image file related to the page the region is in
 * @param region The region to extract */
private BufferedImage extractNinePatch (BufferedImage page, Region region, File outputDirFile) {
	BufferedImage splitImage = extractImage(page, region, outputDirFile, NINEPATCH_PADDING);
	Graphics2D g2 = splitImage.createGraphics();
	g2.setColor(Color.BLACK);

	// Draw the four lines to save the ninepatch's padding and splits
	int startX = region.splits[0] + NINEPATCH_PADDING;
	int endX = region.width - region.splits[1] + NINEPATCH_PADDING - 1;
	int startY = region.splits[2] + NINEPATCH_PADDING;
	int endY = region.height - region.splits[3] + NINEPATCH_PADDING - 1;
	if (endX >= startX) g2.drawLine(startX, 0, endX, 0);
	if (endY >= startY) g2.drawLine(0, startY, 0, endY);
	if (region.pads != null) {
		int padStartX = region.pads[0] + NINEPATCH_PADDING;
		int padEndX = region.width - region.pads[1] + NINEPATCH_PADDING - 1;
		int padStartY = region.pads[2] + NINEPATCH_PADDING;
		int padEndY = region.height - region.pads[3] + NINEPATCH_PADDING - 1;
		g2.drawLine(padStartX, splitImage.getHeight() - 1, padEndX, splitImage.getHeight() - 1);
		g2.drawLine(splitImage.getWidth() - 1, padStartY, splitImage.getWidth() - 1, padEndY);
	}
	g2.dispose();

	return splitImage;
}
 
开发者ID:crashinvaders,项目名称:gdx-texture-packer-gui,代码行数:29,代码来源:TextureUnpacker.java


示例2: extractImage

import com.badlogic.gdx.graphics.g2d.TextureAtlas.TextureAtlasData.Region; //导入依赖的package包/类
/** Extract an image from a texture atlas.
 * @param page The image file related to the page the region is in
 * @param region The region to extract
 * @param outputDirFile The output directory
 * @param padding padding (in pixels) to apply to the image
 * @return The extracted image */
private BufferedImage extractImage (BufferedImage page, Region region, File outputDirFile, int padding) {
	BufferedImage splitImage = null;

	// get the needed part of the page and rotate if needed
	if (region.rotate) {
		BufferedImage srcImage = page.getSubimage(region.left, region.top, region.height, region.width);
		splitImage = new BufferedImage(region.width, region.height, page.getType());

		AffineTransform transform = new AffineTransform();
		transform.rotate(Math.toRadians(90.0));
		transform.translate(0, -region.width);
		AffineTransformOp op = new AffineTransformOp(transform, AffineTransformOp.TYPE_BILINEAR);
		op.filter(srcImage, splitImage);
	} else {
		splitImage = page.getSubimage(region.left, region.top, region.width, region.height);
	}

	// draw the image to a bigger one if padding is needed
	if (padding > 0) {
		BufferedImage paddedImage = new BufferedImage(splitImage.getWidth() + padding * 2, splitImage.getHeight() + padding * 2,
			page.getType());
		Graphics2D g2 = paddedImage.createGraphics();
		g2.drawImage(splitImage, padding, padding, null);
		g2.dispose();
		return paddedImage;
	} else {
		return splitImage;
	}
}
 
开发者ID:crashinvaders,项目名称:gdx-texture-packer-gui,代码行数:36,代码来源:TextureUnpacker.java


示例3: load

import com.badlogic.gdx.graphics.g2d.TextureAtlas.TextureAtlasData.Region; //导入依赖的package包/类
private void load (TextureAtlasData data) {
	ObjectMap<Page, Texture> pageToTexture = new ObjectMap<Page, Texture>();
	for (Page page : data.pages) {
		Texture texture = null;
		if (page.texture == null) {
			texture = new Texture(page.textureFile, page.format, page.useMipMaps);
			texture.setFilter(page.minFilter, page.magFilter);
			texture.setWrap(page.uWrap, page.vWrap);
		} else {
			texture = page.texture;
			texture.setFilter(page.minFilter, page.magFilter);
			texture.setWrap(page.uWrap, page.vWrap);
		}
		textures.add(texture);
		pageToTexture.put(page, texture);
	}

	for (Region region : data.regions) {
		int width = region.width;
		int height = region.height;
		AtlasRegion atlasRegion = new AtlasRegion(pageToTexture.get(region.page), region.left, region.top,
			region.rotate ? height : width, region.rotate ? width : height);
		atlasRegion.index = region.index;
		atlasRegion.name = region.name;
		atlasRegion.offsetX = region.offsetX;
		atlasRegion.offsetY = region.offsetY;
		atlasRegion.originalHeight = region.originalHeight;
		atlasRegion.originalWidth = region.originalWidth;
		atlasRegion.rotate = region.rotate;
		atlasRegion.splits = region.splits;
		atlasRegion.pads = region.pads;
		if (region.flip) atlasRegion.flip(false, true);
		regions.add(atlasRegion);
	}
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:36,代码来源:TextureAtlas.java


示例4: compare

import com.badlogic.gdx.graphics.g2d.TextureAtlas.TextureAtlasData.Region; //导入依赖的package包/类
public int compare (Region region1, Region region2) {
	int i1 = region1.index;
	if (i1 == -1) i1 = Integer.MAX_VALUE;
	int i2 = region2.index;
	if (i2 == -1) i2 = Integer.MAX_VALUE;
	return i1 - i2;
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:8,代码来源:TextureAtlas.java


示例5: extractImage

import com.badlogic.gdx.graphics.g2d.TextureAtlas.TextureAtlasData.Region; //导入依赖的package包/类
/** Extract an image from a texture atlas.
 * @param page The image file related to the page the region is in
 * @param region The region to extract
 * @param outputDirFile The output directory
 * @param padding padding (in pixels) to apply to the image
 * @return The extracted image */
private BufferedImage extractImage (BufferedImage page, Region region, File outputDirFile, int padding) {
	BufferedImage splitImage = null;

	// get the needed part of the page and rotate if needed
	if (region.rotate) {
		BufferedImage srcImage = page.getSubimage(region.left, region.top, region.height, region.width);
		splitImage = new BufferedImage(region.height, region.width, page.getType());

		AffineTransform transform = new AffineTransform();
		transform.rotate(Math.toRadians(90.0));
		transform.translate(0, -region.width);
		AffineTransformOp op = new AffineTransformOp(transform, AffineTransformOp.TYPE_BILINEAR);
		op.filter(srcImage, splitImage);
	} else {
		splitImage = page.getSubimage(region.left, region.top, region.width, region.height);
	}

	// draw the image to a bigger one if padding is needed
	if (padding > 0) {
		BufferedImage paddedImage = new BufferedImage(splitImage.getWidth() + padding * 2, splitImage.getHeight() + padding * 2,
			page.getType());
		Graphics2D g2 = paddedImage.createGraphics();
		g2.drawImage(splitImage, padding, padding, null);
		g2.dispose();
		return paddedImage;
	} else {
		return splitImage;
	}
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:36,代码来源:TextureUnpacker.java


示例6: extractNinePatch

import com.badlogic.gdx.graphics.g2d.TextureAtlas.TextureAtlasData.Region; //导入依赖的package包/类
/**
 * Extract a ninepatch from a texture atlas, according to the android
 * specification.
 * 
 * @see <a
 *      href="http://developer.android.com/guide/topics/graphics/2d-graphics.html#nine-patch">ninepatch
 *      specification</a>
 * @param page
 *            The image file related to the page the region is in
 * @param region
 *            The region to extract
 */
private BufferedImage extractNinePatch(BufferedImage page, Region region, File outputDirFile) {
	BufferedImage splitImage = extractImage(page, region, outputDirFile, NINEPATCH_PADDING);
	Graphics2D g2 = splitImage.createGraphics();
	g2.setColor(Color.BLACK);

	// Draw the four lines to save the ninepatch's padding and splits
	int startX = region.splits[0] + NINEPATCH_PADDING;
	int endX = region.width - region.splits[1] + NINEPATCH_PADDING - 1;
	int startY = region.splits[2] + NINEPATCH_PADDING;
	int endY = region.height - region.splits[3] + NINEPATCH_PADDING - 1;
	if (endX >= startX)
		g2.drawLine(startX, 0, endX, 0);
	if (endY >= startY)
		g2.drawLine(0, startY, 0, endY);
	if (region.pads != null) {
		int padStartX = region.pads[0] + NINEPATCH_PADDING;
		int padEndX = region.width - region.pads[1] + NINEPATCH_PADDING - 1;
		int padStartY = region.pads[2] + NINEPATCH_PADDING;
		int padEndY = region.height - region.pads[3] + NINEPATCH_PADDING - 1;
		g2.drawLine(padStartX, splitImage.getHeight() - 1, padEndX, splitImage.getHeight() - 1);
		g2.drawLine(splitImage.getWidth() - 1, padStartY, splitImage.getWidth() - 1, padEndY);
	}
	g2.dispose();

	return splitImage;
}
 
开发者ID:bladecoder,项目名称:bladecoder-adventure-engine,代码行数:39,代码来源:CustomTextureUnpacker.java


示例7: getRegions

import com.badlogic.gdx.graphics.g2d.TextureAtlas.TextureAtlasData.Region; //导入依赖的package包/类
public Array<Region> getRegions () {
	return regions;
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:4,代码来源:TextureAtlas.java


示例8: crack

import com.badlogic.gdx.graphics.g2d.TextureAtlas.TextureAtlasData.Region; //导入依赖的package包/类
public static void crack(String srcAtlas,String dstDir) throws Exception{
	FileHandle fh = Gdx.files.absolute(srcAtlas);
	TextureAtlasData data = new TextureAtlasData(fh, fh.parent(),false);
	File dir = new File(dstDir);
	if(!dir.exists()){
		dir.mkdirs();
		System.out.println("mkdirs:"+dstDir);
	}
	for(Region region:data.getRegions()){
		File file = region.page.textureFile.file();
		BufferedImage root = ImageIO.read(file);
		String fileName = region.name ;
		int sizeWidth = region.originalWidth;
		int sizeHeight= region.originalHeight;
		int width = region.width;
		int height= region.height;
		int x = region.left ;
		int y = region.top ;
		int offsetX = (int)region.offsetX;
		int offsetY = (int)region.offsetY;

		BufferedImage canvas = null;
		
		if(region.rotate){
			canvas = new BufferedImage(height, width, BufferedImage.TYPE_INT_ARGB);
			canvas.getGraphics().drawImage(root, 0, 0, height, width, x, y, x+height, y+width, null);
		}else{
			canvas = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
			canvas.getGraphics().drawImage(root, 0, 0, width, height, x, y, x+width, y+height, null);
		}
		
		if(offsetX!=0 || offsetY!=0){
			BufferedImage canvas2 = canvas;
			canvas = new BufferedImage(sizeWidth, sizeHeight, BufferedImage.TYPE_INT_ARGB);
			canvas.getGraphics().drawImage(canvas2, offsetX, offsetY, width, height, 0, 0, width, height, null);
		}
		if(region.rotate){
			canvas = rotate(canvas, Math.toRadians(90));
		}
		ImageIO.write(canvas, "png", new File(dstDir+fileName+".png"));
		
		
		System.out.println("Proccess to "+dstDir+fileName +".png" + " offsetX:"+region.offsetX+",offsetY:"+region.offsetY +" rotate:"+region.rotate);
	}
}
 
开发者ID:lycying,项目名称:c2d-engine,代码行数:46,代码来源:CrackTextureAtlasTool.java



注:本文中的com.badlogic.gdx.graphics.g2d.TextureAtlas.TextureAtlasData.Region类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PropertyValueConverter类代码示例发布时间:2022-05-23
下一篇:
Java AccountManagement类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap