setFormat(format); this.width = width; this.height = height;
setFormat(format); this.width = width; this.height = height;
image.setFormat(format);
/** * This method scales the given texture to the given size. * * @param texture * the texture to be scaled * @param width * new width of the texture * @param height * new height of the texture */ private void scale(Texture2D texture, int width, int height) { // first determine if scaling is required boolean scaleRequired = texture.getImage().getWidth() != width || texture.getImage().getHeight() != height; if (scaleRequired) { Image image = texture.getImage(); BufferedImage sourceImage = ImageToAwt.convert(image, false, true, 0); int sourceWidth = sourceImage.getWidth(); int sourceHeight = sourceImage.getHeight(); BufferedImage targetImage = new BufferedImage(width, height, sourceImage.getType()); Graphics2D g = targetImage.createGraphics(); g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); g.drawImage(sourceImage, 0, 0, width, height, 0, 0, sourceWidth, sourceHeight, null); g.dispose(); Image output = new ImageLoader().load(targetImage, false); image.setWidth(width); image.setHeight(height); image.setData(output.getData(0)); image.setFormat(output.getFormat()); } }
textureImage.setFormat(format); textureImage.setWidth(width); textureImage.setHeight(height);
/** * Create a framebuffer for an eye. */ public void setupFramebuffers(int eye) { // Find the chain length IntBuffer length = BufferUtils.createIntBuffer(1); ovr_GetTextureSwapChainLength(session, chains[eye], length); int chainLength = length.get(); LOGGER.fine("HMD Eye #" + eye + " texture chain length: " + chainLength); // Create the frame buffers framebuffers[eye] = new FrameBuffer[chainLength]; for (int i = 0; i < chainLength; i++) { // find the GL texture ID for this texture IntBuffer textureIdB = BufferUtils.createIntBuffer(1); OVRGL.ovr_GetTextureSwapChainBufferGL(session, chains[eye], i, textureIdB); int textureId = textureIdB.get(); // TODO less hacky way of getting our texture into JMonkeyEngine Image img = new Image(); img.setId(textureId); img.setFormat(Image.Format.RGBA8); img.setWidth(textureW); img.setHeight(textureH); Texture2D tex = new Texture2D(img); FrameBuffer buffer = new FrameBuffer(textureW, textureH, 1); buffer.setDepthBuffer(Image.Format.Depth); buffer.setColorTexture(tex); framebuffers[eye][i] = buffer; } }
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); }
/** * Constructor instantiates a new <code>Image</code> object. The * attributes of the image are defined during construction. * * @param format * the data format of the image. * @param width * the width of the image. * @param height * the height of the image. * @param data * the image data. * @param mipMapSizes * the array of mipmap sizes, or null for no mipmaps. */ public Image(Format format, int width, int height, int depth, ArrayList<ByteBuffer> data, int[] mipMapSizes) { this(); if (mipMapSizes != null && mipMapSizes.length <= 1) { mipMapSizes = null; } setFormat(format); this.width = width; this.height = height; this.data = data; this.depth = depth; this.mipMapSizes = mipMapSizes; }
setFormat(format); this.width = width; this.height = height;
/** * Constructor instantiates a new <code>Image</code> object. The * attributes of the image are defined during construction. * * @param format * the data format of the image. * @param width * the width of the image. * @param height * the height of the image. * @param data * the image data. * @param mipMapSizes * the array of mipmap sizes, or null for no mipmaps. */ public Image(Format format, int width, int height, ByteBuffer data, int[] mipMapSizes) { this(); if (mipMapSizes != null && mipMapSizes.length <= 1) { mipMapSizes = null; } setFormat(format); this.width = width; this.height = height; if (data != null){ this.data = new ArrayList<ByteBuffer>(1); this.data.add(data); } this.mipMapSizes = mipMapSizes; }
setFormat(format); this.width = width; this.height = height;
image.setFormat(format);
image.setFormat(format);
textureImage.setFormat(format); textureImage.setWidth(width); textureImage.setHeight(height);
textureImage.setFormat(format); textureImage.setWidth(width); textureImage.setHeight(height);
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); }