List of usage examples for com.badlogic.gdx.graphics Pixmap Pixmap
public Pixmap(byte[] encodedData, int offset, int len)
From source file:CB_UI_Base.GL_UI.Controls.Box.java
License:Open Source License
protected void drawBorder(Batch batch) { if (borderSprite == null) { try {/*from w w w .ja va 2s .co m*/ GL.that.RunOnGLWithThreadCheck(new IRunOnGL() { @Override public void run() { int w = (int) getWidth(); int h = (int) getHeight(); Pixmap borderRegPixmap = new Pixmap(w, h, Pixmap.Format.RGBA8888); borderRegPixmap.setColor(borderColor); int borderAsInt = Math.round(Box.this.borderSize); for (int i = 0; i < borderAsInt + 1; i++) { borderRegPixmap.drawRectangle(i, i, ((int) getWidth()) - (i), ((int) getHeight()) - (i)); } borderSprite = new Sprite(new Texture(borderRegPixmap, Pixmap.Format.RGBA8888, false), (int) getWidth(), (int) getHeight()); } }); } catch (Exception e) { e.printStackTrace(); } } if (borderSprite != null) batch.draw(borderSprite, 0, 0); }
From source file:CB_UI_Base.GL_UI.Controls.PopUps.PopUpMenu.java
License:Open Source License
@Override protected void writeDebug() { if (DebugSprite == null) { try {/*www .j ava2 s . c o m*/ GL.that.RunOnGLWithThreadCheck(new IRunOnGL() { @Override public void run() { // int w = getNextHighestPO2((int) getWidth()); // int h = getNextHighestPO2((int) getHeight()); int w = (int) getWidth(); int h = (int) getHeight(); debugRegPixmap = new Pixmap(w, h, Pixmap.Format.RGBA8888); debugRegPixmap.setColor(1f, 0f, 0f, 1f); debugRegPixmap.drawRectangle(1, 1, (int) getWidth() - 1, (int) getHeight() - 1); debugRegPixmap.drawLine(1, 1, (int) getWidth() - 1, (int) getHeight() - 1); debugRegPixmap.drawLine(1, (int) getHeight() - 1, (int) getWidth() - 1, 1); debugRegTexture = new Texture(debugRegPixmap, Pixmap.Format.RGBA8888, false); DebugSprite = new Sprite(debugRegTexture, (int) getWidth(), (int) getHeight()); } }); } catch (Exception e) { e.printStackTrace(); } } }
From source file:CB_UI_Base.GL_UI.GL_View_Base.java
License:Open Source License
protected void writeDebug() { if (DebugSprite == null) { try {//from w w w . j a v a 2s .com GL.that.RunOnGLWithThreadCheck(new IRunOnGL() { @Override public void run() { // int w = getNextHighestPO2((int) getWidth()); // int h = getNextHighestPO2((int) getHeight()); int w = (int) getWidth(); int h = (int) getHeight(); debugRegPixmap = new Pixmap(w, h, Pixmap.Format.RGBA8888); debugRegPixmap.setColor(1f, 0f, 0f, 1f); debugRegPixmap.drawRectangle(1, 1, (int) getWidth() - 1, (int) getHeight() - 1); debugRegTexture = new Texture(debugRegPixmap, Pixmap.Format.RGBA8888, false); DebugSprite = new Sprite(debugRegTexture, (int) getWidth(), (int) getHeight()); } }); } catch (Exception e) { e.printStackTrace(); } } }
From source file:CB_UI_Base.graphics.Images.BitmapDrawable.java
License:Open Source License
private void createData() { Pixmap pix;/*from ww w . j a v a2 s . com*/ try { pix = new Pixmap(buffer, 0, buffer.length); } catch (Exception e) { // Can't create e.printStackTrace(); return; } // scale? if (this.scaleFactor != 1) { int w = (int) (pix.getWidth() * this.scaleFactor); int h = (int) (pix.getHeight() * this.scaleFactor); Pixmap tmpPixmap = new Pixmap(w, h, pix.getFormat()); Pixmap.setFilter(Pixmap.Filter.NearestNeighbour); tmpPixmap.drawPixmap(pix, 0, 0, pix.getWidth(), pix.getHeight(), 0, 0, w, h); pix.dispose(); pix = tmpPixmap; } try { Packer.pack(AtlasHashString, pix); } catch (Exception e) { e.printStackTrace(); } if (Atlas == null) { Atlas = Packer.generateTextureAtlas(TextureFilter.Linear, TextureFilter.Linear, false); } else { Packer.updateTextureAtlas(Atlas, TextureFilter.Linear, TextureFilter.Linear, false); } pix.dispose(); buffer = null; }
From source file:CB_UI_Base.graphics.PolygonDrawable.java
License:Open Source License
private void createTexRegFromPixMap() { if (isDisposed.get()) return;/*from w w w . jav a 2s .com*/ int w = 2; int h = 2; pix = new Pixmap(w, h, Pixmap.Format.RGB565); pix.setColor(new Color(Color.WHITE)); pix.fillRectangle(0, 0, w, h); try { tex = new Texture(pix); } catch (Exception e) { tex = null; } if (tex != null) { tex.setFilter(TextureFilter.Linear, TextureFilter.MipMapLinearLinear); texReg = new TextureRegion(tex, (int) this.WIDTH, (int) this.HEIGHT); } pix.dispose(); pix = null; }
From source file:CB_UI_Base.graphics.SolidTextureRegion.java
License:Open Source License
public SolidTextureRegion(Color color, float width, float height) { Pixmap pix = new Pixmap(2, 2, Format.RGB565); pix.setColor(color);//w ww . ja va2 s .c o m pix.fill(); Texture tex = new Texture(pix); pix.dispose(); this.setRegion(tex); setRegion(0, 0, width, height); }
From source file:com.agateau.pixelwheels.map.LapPositionTableIO.java
License:Open Source License
public static Pixmap createPixmap(LapPositionTable table, int width, int height) { NLog.i("Saving"); Pixmap pixmap = new Pixmap(width, height, Pixmap.Format.RGBA8888); for (int y = 0; y < height; ++y) { NLog.i("Saving %d/%d", y, height); for (int x = 0; x < width; ++x) { LapPosition pos = table.get(x, y); int color; if (pos == null) { color = 0;//from w w w. j a v a 2 s.c o m } else { int r = (int) ((1 - Math.abs(pos.getCenterDistance())) * 255); int g = pos.getSectionId() * 255 / table.getSectionCount(); int b = (int) (pos.getSectionDistance() * 255); color = (r << 24) | (g << 16) | (b << 8) | 0xff; } pixmap.drawPixel(x, height - 1 - y, color); } } return pixmap; }
From source file:com.agateau.pixelwheels.PwGame.java
License:Open Source License
private void hideMouseCursor() { Pixmap pixmap = new Pixmap(2, 2, Pixmap.Format.RGBA8888); pixmap.setColor(0, 0, 0, 0);/*from w w w .j a v a2s . c o m*/ pixmap.fill(); Cursor cursor = Gdx.graphics.newCursor(pixmap, 0, 0); if (cursor != null) { Gdx.graphics.setCursor(cursor); } }
From source file:com.agateau.pixelwheels.tools.MapScreenshotGenerator.java
License:Apache License
private static Pixmap scaleScreenshot(Pixmap src) { int srcW = src.getWidth(); int srcH = src.getHeight(); float ratio = (float) SHOT_SIZE / Math.min(srcW, srcH); int dstW = (int) (srcW * ratio); int dstH = (int) (srcH * ratio); Pixmap dst = new Pixmap(SHOT_SIZE, SHOT_SIZE, src.getFormat()); dst.setFilter(Pixmap.Filter.BiLinear); dst.drawPixmap(src, 0, 0, srcW, srcH, (SHOT_SIZE - dstW) / 2, (SHOT_SIZE - dstH) / 2, dstW, dstH); return dst;//from ww w.j av a 2 s . c om }
From source file:com.agateau.utils.ScreenshotCreator.java
License:Apache License
private static void init() { int width = Gdx.graphics.getWidth(); int height = Gdx.graphics.getHeight(); sPixmap = new Pixmap(width, height, Pixmap.Format.RGB888); // Guess at deflated size sPNG = new PixmapIO.PNG((int) (width * height * 1.5f)); }