image.setMipMapSizes(mipSizes);
image.setMipMapSizes(mipMapSizes);
image.setMipMapSizes(mipSizes); image.setFormat(format);
int[] mipMapSizes = images.get(0).getMipMapSizes(); Image arrayImage = new Image(format, width, height, null, colorSpace); arrayImage.setMipMapSizes(mipMapSizes);
public static void createData(Image image, boolean mipmaps){ int bpp = image.getFormat().getBitsPerPixel(); int w = image.getWidth(); int h = image.getHeight(); if (!mipmaps){ image.setData(BufferUtils.createByteBuffer(w*h*bpp/8)); return; } int expectedMipmaps = 1 + (int) Math.ceil(Math.log(Math.max(h, w)) / LOG2); int[] mipMapSizes = new int[expectedMipmaps]; int total = 0; for (int i = 0; i < mipMapSizes.length; i++){ int size = (w * h * bpp) / 8; total += size; mipMapSizes[i] = size; w /= 2; h /= 2; } image.setMipMapSizes(mipMapSizes); image.setData(BufferUtils.createByteBuffer(total)); }
/** * Inits the mip maps of a cube map witht he given number of mip maps * @param nbMipMaps the number of mip maps to initialize */ public void initMipMaps(int nbMipMaps) { int maxMipMap = (int) (Math.log(image.getWidth()) / Math.log(2) + 1); if (nbMipMaps > maxMipMap) { throw new IllegalArgumentException("Max mip map number for a " + image.getWidth() + "x" + image.getHeight() + " cube map is " + maxMipMap); } sizes = new int[nbMipMaps]; int totalSize = 0; for (int i = 0; i < nbMipMaps; i++) { int size = (int) pow(2, maxMipMap - 1 - i); sizes[i] = size * size * image.getFormat().getBitsPerPixel() / 8; totalSize += sizes[i]; } image.setMipMapSizes(sizes); image.getData().clear(); for (int i = 0; i < 6; i++) { image.addData(BufferUtils.createByteBuffer(totalSize)); } mipMapRaster = new MipMapImageRaster(image, 0); } }
result.setMipMapSizes(image.getMipMapSizes().clone());
result.setMipMapSizes(image.getMipMapSizes().clone());
result.setMipMapSizes(image.getMipMapSizes().clone());
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); }
new Image(Format.RGBA8, image.getWidth(), image.getHeight(), dataArray.get(0), com.jme3.texture.image.ColorSpace.Linear); if (newMipmapSizes != null) { result.setMipMapSizes(newMipmapSizes);
/** * Make a duplicate of this cube Map. That means that it's another instant * od TextureCubeMap, but the underlying buffers are duplicates of the * original ones. see {@link ByteBuffer#duplicate()} * * Use this if you need to read from the map from multiple threads, it * should garanty the thread safety. Note that if you want to write to the * cube map you have to make sure that the different thread do not write to * the same area of the buffer. The position, limit and mark are not an * issue. * * @param sourceMap * @return */ public static TextureCubeMap duplicateCubeMap(TextureCubeMap sourceMap) { Image srcImg = sourceMap.getImage(); Image cubeImage = new Image(srcImg.getFormat(), srcImg.getWidth(), srcImg.getHeight(), null, srcImg.getColorSpace()); for (ByteBuffer d : srcImg.getData()) { cubeImage.addData(d.duplicate()); } cubeImage.setMipMapSizes(srcImg.getMipMapSizes()); TextureCubeMap cubeMap = new TextureCubeMap(cubeImage); cubeMap.setAnisotropicFilter(sourceMap.getAnisotropicFilter()); cubeMap.setMagFilter(sourceMap.getMagFilter()); cubeMap.setMinFilter(sourceMap.getMinFilter()); cubeMap.setWrap(sourceMap.getWrap(Texture.WrapAxis.S)); return cubeMap; }
cubeImage.addData(frontImg.getData(0)); cubeImage.setMipMapSizes(rightImg.getMipMapSizes());
int[] mipMapSizes = images.get(0).getMipMapSizes(); Image arrayImage = new Image(format, width, height, null, colorSpace); arrayImage.setMipMapSizes(mipMapSizes);
public static void createData(Image image, boolean mipmaps){ int bpp = image.getFormat().getBitsPerPixel(); int w = image.getWidth(); int h = image.getHeight(); if (!mipmaps){ image.setData(BufferUtils.createByteBuffer(w*h*bpp/8)); return; } int expectedMipmaps = 1 + (int) Math.ceil(Math.log(Math.max(h, w)) / LOG2); int[] mipMapSizes = new int[expectedMipmaps]; int total = 0; for (int i = 0; i < mipMapSizes.length; i++){ int size = (w * h * bpp) / 8; total += size; mipMapSizes[i] = size; w /= 2; h /= 2; } image.setMipMapSizes(mipMapSizes); image.setData(BufferUtils.createByteBuffer(total)); }
public static void createData(Image image, boolean mipmaps){ int bpp = image.getFormat().getBitsPerPixel(); int w = image.getWidth(); int h = image.getHeight(); if (!mipmaps){ image.setData(BufferUtils.createByteBuffer(w*h*bpp/8)); return; } int expectedMipmaps = 1 + (int) Math.ceil(Math.log(Math.max(h, w)) / LOG2); int[] mipMapSizes = new int[expectedMipmaps]; int total = 0; for (int i = 0; i < mipMapSizes.length; i++){ int size = (w * h * bpp) / 8; total += size; mipMapSizes[i] = size; w /= 2; h /= 2; } image.setMipMapSizes(mipMapSizes); image.setData(BufferUtils.createByteBuffer(total)); }
/** * Inits the mip maps of a cube map witht he given number of mip maps * @param nbMipMaps the number of mip maps to initialize */ public void initMipMaps(int nbMipMaps) { int maxMipMap = (int) (Math.log(image.getWidth()) / Math.log(2) + 1); if (nbMipMaps > maxMipMap) { throw new IllegalArgumentException("Max mip map number for a " + image.getWidth() + "x" + image.getHeight() + " cube map is " + maxMipMap); } sizes = new int[nbMipMaps]; int totalSize = 0; for (int i = 0; i < nbMipMaps; i++) { int size = (int) pow(2, maxMipMap - 1 - i); sizes[i] = size * size * image.getFormat().getBitsPerPixel() / 8; totalSize += sizes[i]; } image.setMipMapSizes(sizes); image.getData().clear(); for (int i = 0; i < 6; i++) { image.addData(BufferUtils.createByteBuffer(totalSize)); } mipMapRaster = new MipMapImageRaster(image, 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); }
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); }
/** * Make a duplicate of this cube Map. That means that it's another instant * od TextureCubeMap, but the underlying buffers are duplicates of the * original ones. see {@link ByteBuffer#duplicate()} * * Use this if you need to read from the map from multiple threads, it * should garanty the thread safety. Note that if you want to write to the * cube map you have to make sure that the different thread do not write to * the same area of the buffer. The position, limit and mark are not an * issue. * * @param sourceMap * @return */ public static TextureCubeMap duplicateCubeMap(TextureCubeMap sourceMap) { Image srcImg = sourceMap.getImage(); Image cubeImage = new Image(srcImg.getFormat(), srcImg.getWidth(), srcImg.getHeight(), null, srcImg.getColorSpace()); for (ByteBuffer d : srcImg.getData()) { cubeImage.addData(d.duplicate()); } cubeImage.setMipMapSizes(srcImg.getMipMapSizes()); TextureCubeMap cubeMap = new TextureCubeMap(cubeImage); cubeMap.setAnisotropicFilter(sourceMap.getAnisotropicFilter()); cubeMap.setMagFilter(sourceMap.getMagFilter()); cubeMap.setMinFilter(sourceMap.getMinFilter()); cubeMap.setWrap(sourceMap.getWrap(Texture.WrapAxis.S)); return cubeMap; }