Image jmeImage = new AWTLoader().load(image, true); return new Texture2D(jmeImage);
AWTLoader loader = new AWTLoader(); ArrayList<ByteBuffer> output = new ArrayList<ByteBuffer>(); int totalSize = 0;
public static void resizeToPowerOf2(Image image){ BufferedImage original = ImageToAwt.convert(image, false, true, 0); int potWidth = FastMath.nearestPowerOfTwo(image.getWidth()); int potHeight = FastMath.nearestPowerOfTwo(image.getHeight()); int potSize = Math.max(potWidth, potHeight); BufferedImage scaled = scaleDown(original, potSize, potSize); AWTLoader loader = new AWTLoader(); Image output = loader.load(scaled, false); image.setWidth(potSize); image.setHeight(potSize); image.setDepth(0); image.setData(output.getData(0)); image.setFormat(output.getFormat()); image.setMipMapSizes(null); }
awtLoader = new AWTLoader(); imageCapture = new Thread() { @Override
/** this method calls dispose on Graphics2D g*/ public static Texture2D createTexture(BufferedImage img, Graphics2D g) { if (g != null) g.dispose(); AWTLoader loader = new AWTLoader(); Texture2D tex = new Texture2D(loader.load(img, true)); //changes to image parameter in buffer, affect the texture. tex.setMagFilter(Texture.MagFilter.Nearest); tex.setMinFilter(Texture.MinFilter.NearestNearestMipMap); return tex; } }
private void generateTexture() { if (material != null) { // The base image BufferedImage flower = new BufferedImage(64, 64, BufferedImage.TYPE_INT_ARGB); Graphics2D g = flower.createGraphics(); // Health ring drawImage(assetManager, g, flower.getWidth(), flower.getHeight(), "Textures/GUI/moods/H-0" + currentHealthIndex + ".png"); // The rest drawImage(assetManager, g, flower.getWidth(), flower.getHeight(), getCenterIcon()); drawImage(assetManager, g, flower.getWidth(), flower.getHeight(), getObjectiveIcon()); onTextureGenerated(g); // Dispose g.dispose(); // Convert the new image to a texture AWTLoader loader = new AWTLoader(); Texture tex = new Texture2D(loader.load(flower, false)); material.setTexture("ColorMap", tex); } }
/** this method calls dispose on Graphics2D g*/ public static Texture2D createTexture(BufferedImage img, Graphics2D g) { if (g != null) g.dispose(); AWTLoader loader = new AWTLoader(); Texture2D tex = new Texture2D(loader.load(img, true)); //changes to image parameter in buffer, affect the texture. tex.setMagFilter(Texture.MagFilter.Nearest); tex.setMinFilter(Texture.MinFilter.NearestNearestMipMap); return tex; } }
public static void setImageOnTexture(Geometry geo, BufferedImage bufImg) { Texture texture = new Texture2D(bufImg.getWidth(), bufImg.getHeight(), Image.Format.Depth24); texture.setImage(new AWTLoader().load(bufImg, false)); geo.getMaterial().setTexture("ColorMap", texture); }
private Texture createTexture() throws IOException { String name = "ktorch"; //float[] scales = {1f, 1f, 1f, 1f}; //float[] offsets = new float[4]; //RescaleOp rop = new RescaleOp(scales, offsets, null); // Get the first frame, the frames need to be same size BufferedImage img = ImageIO.read(assetManager.locateAsset(new AssetKey(ConversionUtils.getCanonicalAssetKey("Textures/" + name + "0.png"))).openStream()); // Create image big enough to fit all the frames BufferedImage text = new BufferedImage(img.getWidth() * frames, img.getHeight(), BufferedImage.TYPE_INT_ARGB); Graphics2D g = text.createGraphics(); g.drawImage(makeColorTransparent(img), 0, 0, null); for (int x = 1; x < frames; x++) { AssetInfo asset = assetManager.locateAsset(new AssetKey(ConversionUtils.getCanonicalAssetKey("Textures/" + name + x + ".png"))); img = ImageIO.read(asset.openStream()); g.drawImage(makeColorTransparent(img), img.getWidth() * x, 0, null); } g.dispose(); // Convert the new image to a texture AWTLoader loader = new AWTLoader(); Texture result = new Texture2D(loader.load(text, false)); return result; }
AWTLoader loader = new AWTLoader(); ArrayList<ByteBuffer> output = new ArrayList<ByteBuffer>(); int totalSize = 0;
AWTLoader loader = new AWTLoader(); ArrayList<ByteBuffer> output = new ArrayList<ByteBuffer>(); int totalSize = 0;
AWTLoader loader = new AWTLoader(); Texture tex = new Texture2D(loader.load(text, false)); return tex;
public static void resizeToPowerOf2(Image image){ BufferedImage original = ImageToAwt.convert(image, false, true, 0); int potWidth = FastMath.nearestPowerOfTwo(image.getWidth()); int potHeight = FastMath.nearestPowerOfTwo(image.getHeight()); int potSize = Math.max(potWidth, potHeight); BufferedImage scaled = scaleDown(original, potSize, potSize); AWTLoader loader = new AWTLoader(); Image output = loader.load(scaled, false); image.setWidth(potSize); image.setHeight(potSize); image.setDepth(0); image.setData(output.getData(0)); image.setFormat(output.getFormat()); image.setMipMapSizes(null); }
public static void resizeToPowerOf2(Image image){ BufferedImage original = ImageToAwt.convert(image, false, true, 0); int potWidth = FastMath.nearestPowerOfTwo(image.getWidth()); int potHeight = FastMath.nearestPowerOfTwo(image.getHeight()); int potSize = Math.max(potWidth, potHeight); BufferedImage scaled = scaleDown(original, potSize, potSize); AWTLoader loader = new AWTLoader(); Image output = loader.load(scaled, false); image.setWidth(potSize); image.setHeight(potSize); image.setDepth(0); image.setData(output.getData(0)); image.setFormat(output.getFormat()); image.setMipMapSizes(null); }
private Texture generateNormalMap(Texture texture) { BufferedImage image = ImageToAwt.convert(texture.getImage(), false, false, 0); BufferedImage normal = NormalMapFilter.create().filter(image, 0.01f); Image jme = new AWTLoader().load(normal, false); Texture2D jmeTexture = new Texture2D(jme); jmeTexture.setWrap(Texture.WrapAxis.S, texture.getWrap(Texture.WrapAxis.S)); jmeTexture.setWrap(Texture.WrapAxis.T, texture.getWrap(Texture.WrapAxis.T)); jmeTexture.setMagFilter(texture.getMagFilter()); jmeTexture.setMinFilter(texture.getMinFilter()); return jmeTexture; } }
AWTLoader loader = new AWTLoader(); Texture tex = new Texture2D(loader.load(newImage, false)); ((DesktopAssetManager) assetManager).addToCache(new TextureKey("HUDBackground", false), tex);