本文整理匯總了Java中com.badlogic.gdx.graphics.Pixmap.Format類的典型用法代碼示例。如果您正苦於以下問題:Java Format類的具體用法?Java Format怎麽用?Java Format使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Format類屬於com.badlogic.gdx.graphics.Pixmap包,在下文中一共展示了Format類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: create
import com.badlogic.gdx.graphics.Pixmap.Format; //導入依賴的package包/類
@Override
public Texture create(int width, int height) {
Pixmap map = new Pixmap(width, height, Format.RGBA8888);
Color skinColor = getSkinColor();
Color hairColor = getHairColor();
Color shoeColor = getShoeColor();
Color trousesColor = getTrousesColor();
Color shirtColor = getShirtColor();
generate(map, skinColor, hairColor, shoeColor, trousesColor, shirtColor);
Texture texture = new Texture(map);
map.dispose();
return texture;
}
示例2: load
import com.badlogic.gdx.graphics.Pixmap.Format; //導入依賴的package包/類
@Override
public void load() {
if(isLoaded())
return;
bird = loadTextureRegion("angrybirds/sprites/bird.png");
pig = loadTexture("angrybirds/sprites/pig.png");
sling = loadTextureRegion("angrybirds/sprites/sling.png");
block = loadTexture("angrybirds/sprites/woods/block.gif");
longwood = loadTexture("angrybirds/sprites/woods/long.gif");
smallblock = loadTexture("angrybirds/sprites/woods/small.gif");
tallwood = loadTexture("angrybirds/sprites/woods/tall.gif");
background = loadTexture("bg.jpg", Format.RGB565, true);
font = loadBitmapFont("default.fnt", "default.png");
damaged_block = loadTexture("angrybirds/sprites/damaged_woods/block.gif");
damaged_longwood = loadTexture("angrybirds/sprites/damaged_woods/long.gif");
damaged_smallblock = loadTexture("angrybirds/sprites/damaged_woods/small.gif");
damaged_tallwood = loadTexture("angrybirds/sprites/damaged_woods/tall.gif");
setLoaded(true);
}
示例3: createHighlightingGraphic
import com.badlogic.gdx.graphics.Pixmap.Format; //導入依賴的package包/類
private Texture createHighlightingGraphic(TextureRegion textureRegion)
{
TextureData textureData = textureRegion.getTexture().getTextureData();
textureData.prepare();
Pixmap sourcePixmap = textureData.consumePixmap();
Pixmap destinationPixmap = new Pixmap(textureRegion.getRegionWidth(), textureRegion.getRegionHeight(), Format.RGBA8888);
Color color = new Color();
for (int x = 0; x < textureRegion.getRegionWidth(); x++)
{
for (int y = 0; y < textureRegion.getRegionHeight(); y++)
{
int colorInt = sourcePixmap.getPixel(textureRegion.getRegionX() + x, textureRegion.getRegionY() + y);
Color.rgba8888ToColor(color, colorInt);
destinationPixmap.setColor(1.0f, 1f, 1.0f, 1);
if (color.a > 0.004f)
destinationPixmap.drawPixel(x, y);
}
}
Texture result = new Texture(destinationPixmap);
textureData.disposePixmap();
destinationPixmap.dispose();
return result;
}
示例4: LightMap
import com.badlogic.gdx.graphics.Pixmap.Format; //導入依賴的package包/類
public LightMap(RayHandler rayHandler, int fboWidth, int fboHeight) {
this.rayHandler = rayHandler;
if (fboWidth <= 0)
fboWidth = 1;
if (fboHeight <= 0)
fboHeight = 1;
frameBuffer = new FrameBuffer(Format.RGBA8888, fboWidth,
fboHeight, false);
pingPongBuffer = new FrameBuffer(Format.RGBA8888, fboWidth,
fboHeight, false);
lightMapMesh = createLightMapMesh();
shadowShader = ShadowShader.createShadowShader();
diffuseShader = DiffuseShader.createShadowShader();
withoutShadowShader = WithoutShadowShader.createShadowShader();
blurShader = Gaussian.createBlurShader(fboWidth, fboHeight);
}
示例5: Renderer
import com.badlogic.gdx.graphics.Pixmap.Format; //導入依賴的package包/類
public Renderer () {
try {
lights = new Environment();
lights.add(new DirectionalLight().set(Color.WHITE, new Vector3(-1, -0.5f, 0).nor()));
spriteBatch = new SpriteBatch();
modelBatch = new ModelBatch();
backgroundTexture = new Texture(Gdx.files.internal("data/planet.jpg"), Format.RGB565, true);
backgroundTexture.setFilter(TextureFilter.MipMap, TextureFilter.Linear);
font = new BitmapFont(Gdx.files.internal("data/font10.fnt"), Gdx.files.internal("data/font10.png"), false);
camera = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
} catch (Exception ex) {
ex.printStackTrace();
}
}
示例6: show
import com.badlogic.gdx.graphics.Pixmap.Format; //導入依賴的package包/類
@Override
public void show () {
font = new BitmapFont(Gdx.files.internal("fonts/font.fnt"));
cache = font.getCache();
if (Gdx.app.getType() == ApplicationType.Android)
font.getData().setScale(2);
polygonBatch = new PolygonSpriteBatch();
camera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
Pixmap pixMap = new Pixmap(1, 1, Format.RGB565);
pixMap.setColor(Color.WHITE);
pixMap.fill();
emptyTexture = new Texture(pixMap);
pixMap.dispose();
}
示例7: resize
import com.badlogic.gdx.graphics.Pixmap.Format; //導入依賴的package包/類
/** Resizes internal RavCamera for framebuffer use, call this in you ApplicationListener's resize.
*
* @param width - new screen width
* @param height - new screen height
* @param resizeFramebuffers - whether all of the framebuffers should be recreated to match new screen size */
public void resize (int width, int height, boolean resizeFramebuffers) {
// ?????
if (resizeFramebuffers) {
Keys<String> keys = frameBuffers.keys();
while (keys.hasNext) {
String key = keys.next();
FrameBuffer fb = frameBuffers.get(key);
int oldWidth = fb.getWidth();
int oldHeight = fb.getHeight();
Format format = fb.getColorBufferTexture().getTextureData().getFormat();
fb.dispose();
frameBuffers.put(key, null);
float factorX = 1f * width / screenCamera.viewportWidth;
float factorY = 1f * height / screenCamera.viewportHeight;
createFB(key, format, (int)(factorX * oldWidth), (int)(factorY * oldHeight));
// System.out.println("Recreated FB '" + key + "' from " +
// oldWidth + "x" + oldHeight + " to " +
// frameBuffers.get(key).getWidth() + "x" +
// frameBuffers.get(key).getHeight());
}
}
screenCamera = new OrthographicCamera(width, height);
createScreenQuad();
}
示例8: PowerLUT
import com.badlogic.gdx.graphics.Pixmap.Format; //導入依賴的package包/類
/** W power will be in luminance, and H power will be in alpha**/
public PowerLUT(float powerW, float intensityW, float powerH, float intensityH, int width, int height){
Pixmap pixmap = new Pixmap(width, height, Format.RGBA8888);
for (int i=0; i<width; i++){
float valueW = (float)Math.pow((float)i/width, powerW) * intensityW;
for (int j = 0; j < height; j++) {
float valueH = (float)Math.pow((float)j/height, powerH) * intensityH;
pixmap.setColor(valueW, valueH, 1.0f, 1.0f);
pixmap.drawPixel(i, j);
}
}
PixmapTextureData data = new PixmapTextureData(pixmap, Format.RGBA8888, false, false, true);
texture = new Texture(data);
texture.setWrap(TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);
texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
}
示例9: toBufferedImageType
import com.badlogic.gdx.graphics.Pixmap.Format; //導入依賴的package包/類
/**
* Returns the equivalent buffered image type ({@link BufferedImage#getType()}) for the given pixmap
* format.
*/
public static int toBufferedImageType(Format format) {
switch (format) {
case Intensity:
case Alpha:
return BufferedImage.TYPE_BYTE_GRAY;
case RGB565:
case RGB888:
return BufferedImage.TYPE_3BYTE_BGR;
case LuminanceAlpha:
case RGBA4444:
case RGBA8888:
return BufferedImage.TYPE_INT_ARGB;
default:
throw new IllegalArgumentException("Unsupported format: " + format);
}
}
示例10: loadAsync
import com.badlogic.gdx.graphics.Pixmap.Format; //導入依賴的package包/類
@Override
public void loadAsync(AssetManager manager, String fileName, FileHandle file,
TextureParameter parameter) {
if (parameter == null || parameter.textureData == null) {
Format format = null;
boolean genMipMaps = false;
info.texture = null;
if (parameter != null) {
format = parameter.format;
genMipMaps = parameter.genMipMaps;
info.texture = parameter.texture;
}
info.data = loadTexData(file, format, genMipMaps);
} else {
info.data = parameter.textureData;
info.texture = parameter.texture;
}
if (!info.data.isPrepared()) {
info.data.prepare();
}
}
示例11: flipVertical
import com.badlogic.gdx.graphics.Pixmap.Format; //導入依賴的package包/類
/**
* @param pixels A Pixmap in {@link Format#RGBA8888}.
*/
public static void flipVertical(Pixmap pixels) {
Checks.checkArgument(pixels.getFormat() == Format.RGBA8888,
"Pixmap with unsupported format: " + pixels.getFormat());
int bytesPerRow = pixels.getWidth() * 4; // RGBA8888
int h = pixels.getHeight();
byte[] lineBuffer0 = new byte[bytesPerRow];
byte[] lineBuffer1 = new byte[bytesPerRow];
ByteBuffer pixelsBuffer = pixels.getPixels();
for (int y = 0; y < h / 2; y++) {
int y0 = y * bytesPerRow;
int y1 = (h - 1 - y) * bytesPerRow;
// Swap pixels in rows
pixelsBuffer.position(y0);
pixelsBuffer.get(lineBuffer0);
pixelsBuffer.position(y1);
pixelsBuffer.get(lineBuffer1);
pixelsBuffer.position(y1);
pixelsBuffer.put(lineBuffer0);
pixelsBuffer.position(y0);
pixelsBuffer.put(lineBuffer1);
}
pixelsBuffer.rewind();
}
示例12: convert
import com.badlogic.gdx.graphics.Pixmap.Format; //導入依賴的package包/類
/**
* Converts the given pixmap to the specified target color format. If the source pixmap is already in the
* correct format, the original pixmap is returned unmodified.
*/
public static Pixmap convert(Pixmap source, Format targetFormat, boolean disposeSource) {
if (source.getFormat() == targetFormat) {
return source; // Already the correct format
}
int iw = source.getWidth();
int ih = source.getHeight();
Pixmap result = newUninitializedPixmap(iw, ih, targetFormat);
copySubRect(source, Rect.of(0, 0, iw, ih), result, Rect.of(0, 0, iw, ih), Filter.NearestNeighbour);
if (disposeSource) {
source.dispose();
}
return result;
}
示例13: copy
import com.badlogic.gdx.graphics.Pixmap.Format; //導入依賴的package包/類
/**
* Copies the contents of {@code src} to {@code dst}.
*
* @throws IllegalArgumentException If the pixmaps are different sizes or different formats.
*/
public static void copy(Pixmap src, Pixmap dst) {
Format srcFmt = src.getFormat();
Format dstFmt = dst.getFormat();
Checks.checkArgument(srcFmt == dstFmt, "Formats not equal: src=" + srcFmt + ", dst=" + dstFmt);
int srcW = src.getWidth();
int dstW = dst.getWidth();
Checks.checkArgument(srcW == dstW, "Widths not equal: src.w=" + srcW + ", dst.w=" + dstW);
int srcH = src.getHeight();
int dstH = src.getHeight();
Checks.checkArgument(srcH == dstH, "Heights not equal: src.h=" + srcH + ", dst.h=" + dstH);
ByteBuffer srcPixels = src.getPixels();
ByteBuffer dstPixels = dst.getPixels();
BufferUtils.copy(srcPixels, dstPixels, srcPixels.limit());
srcPixels.clear();
dstPixels.clear();
}
示例14: testFlipVertical
import com.badlogic.gdx.graphics.Pixmap.Format; //導入依賴的package包/類
@Test
public void testFlipVertical() {
Pixmap flip = new Pixmap(2, 3, Format.RGBA8888);
flip.drawPixel(0, 0, 0xAABBCCDD);
flip.drawPixel(1, 2, 0x11223344);
PixmapUtil.flipVertical(flip);
Pixmap expected = new Pixmap(2, 3, Format.RGBA8888);
expected.drawPixel(0, 2, 0xAABBCCDD);
expected.drawPixel(1, 0, 0x11223344);
pixmapEquals.assertEquals(expected, flip);
flip.dispose();
expected.dispose();
}
示例15: generatePlanet
import com.badlogic.gdx.graphics.Pixmap.Format; //導入依賴的package包/類
public static Texture generatePlanet(int[][] tileMap, ArrayList<Tile> tiles) {
int s = tileMap.length;
Pixmap pixmap = new Pixmap(s, s, Format.RGBA4444);
// draw circle for planet
pixmap.setColor(1, 1, 1, 1);
pixmap.fillCircle(s/2,s/2,s/2-1);
//draw noise
for (int y = 0; y < s; ++y) {
for (int x = 0; x < s; ++x) {
//only draw on circle
if (pixmap.getPixel(x, y) != 0) {
pixmap.setColor(tiles.get(tileMap[x][y]).getColor());
pixmap.drawPixel(x, y);
}
}
}
Texture t = new Texture(pixmap);
pixmap.dispose();
return t;
}