public void setMipLevel(int mipLevel) { if (mipLevel >= image.getMipMapSizes().length || mipLevel < 0) { throw new IllegalArgumentException("Mip level must be between 0 and " + image.getMipMapSizes().length); } this.mipLevel = mipLevel; }
/** * The method prepares images for blending. It generates mipmaps if one of * the images has them defined and the other one has not. * * @param target * the image where the blending result is stored * @param source * the image that is being read only */ protected void prepareImagesForBlending(Image target, Image source) { LOGGER.fine("Generating mipmaps if needed!"); boolean targetHasMipmaps = target == null ? false : target.getMipMapSizes() != null && target.getMipMapSizes().length > 0; boolean sourceHasMipmaps = source == null ? false : source.getMipMapSizes() != null && source.getMipMapSizes().length > 0; if (target != null && !targetHasMipmaps && sourceHasMipmaps) { MipMapGenerator.generateMipMaps(target); } else if (source != null && !sourceHasMipmaps && targetHasMipmaps) { MipMapGenerator.generateMipMaps(source); } } }
public MipMapImageRaster(Image image, int slice) { this.image = image; this.slice = slice; this.buffer = image.getData(slice); this.codec = ImageCodec.lookup(image.getFormat()); if (image.hasMipmaps()) { int nbMipMap = image.getMipMapSizes().length; this.width = new int[nbMipMap]; this.height = new int[nbMipMap]; this.offsets = new int[nbMipMap]; for (int i = 0; i < nbMipMap; i++) { width[i] = Math.max(1, image.getWidth() >> i); height[i] = Math.max(1, image.getHeight() >> i); if (i > 0) { offsets[i] = image.getMipMapSizes()[i - 1] + offsets[i - 1]; } } } else { throw new IllegalArgumentException("Image must have MipMapSizes initialized."); } if (codec instanceof ByteAlignedImageCodec || codec instanceof ByteOffsetImageCodec) { this.temp = new byte[codec.bpp]; } else { this.temp = null; } }
@Override public boolean equals(Object other) { if (other == this) { return true; } if (!(other instanceof Image)) { return false; } Image that = (Image) other; if (this.getFormat() != that.getFormat()) return false; if (this.getWidth() != that.getWidth()) return false; if (this.getHeight() != that.getHeight()) return false; if (this.getData() != null && !this.getData().equals(that.getData())) return false; if (this.getData() == null && that.getData() != null) return false; if (this.getMipMapSizes() != null && !Arrays.equals(this.getMipMapSizes(), that.getMipMapSizes())) return false; if (this.getMipMapSizes() == null && that.getMipMapSizes() != null) return false; if (this.getMultiSamples() != that.getMultiSamples()) return false; return true; }
Format format = images.get(0).getFormat(); ColorSpace colorSpace = images.get(0).getColorSpace(); int[] mipMapSizes = images.get(0).getMipMapSizes(); Image arrayImage = new Image(format, width, height, null, colorSpace); arrayImage.setMipMapSizes(mipMapSizes); throw new IllegalArgumentException("Images in texture array must have same format"); if (!Arrays.equals(mipMapSizes, img.getMipMapSizes())) { throw new IllegalArgumentException("Images in texture array must have same mipmap sizes");
if (image.getMipMapSizes() != null) { throw new UnsupportedOperationException("Updating mip-mappped images is not supported");
mipPos += image.getMipMapSizes()[i];
/** * Creates a CubeMapWrapper for the given cube map * Note that the cube map must be initialized, and the mipmaps sizes should * be set if relevant for them to be readable/writable * @param cubeMap the cubemap to wrap. */ public CubeMapWrapper(TextureCubeMap cubeMap) { image = cubeMap.getImage(); if (image.hasMipmaps()) { int nbMipMaps = image.getMipMapSizes().length; sizes = new int[nbMipMaps]; mipMapRaster = new MipMapImageRaster(image, 0); for (int i = 0; i < nbMipMaps; i++) { sizes[i] = Math.max(1, image.getWidth() >> i); } } else { sizes = new int[1]; sizes[0] = image.getWidth(); } raster = new DefaultImageRaster(image, 0,0 , false); }
if (image.getMipMapSizes() != null) { result.setMipMapSizes(image.getMipMapSizes().clone());
public DefaultImageRaster(Image image, int slice, int mipMapLevel, boolean convertToLinear) { int[] mipMapSizes = image.getMipMapSizes(); int availableMips = mipMapSizes != null ? mipMapSizes.length : 1;
int depth = image.getDepth(); int[] mipSizes = image.getMipMapSizes(); int pos = 0;
throw new IllegalArgumentException("Only flat images are allowed for subimage operation!"); if (image.getMipMapSizes() != null) { LOGGER.warning("Subimaging image with mipmaps is not yet supported!");
@Override public void done(Integer result) { if (globalListener != null) { if (result < 6) { globalListener.step("Prefiltered env map face " + result + " generated"); } else { globalListener.step("Irradiance map generated"); } } jobState.done[index] = true; if (jobState.isDone()) { probe.setNbMipMaps(probe.getPrefilteredEnvMap().getImage().getMipMapSizes().length); probe.setReady(true); if (globalListener != null) { globalListener.done(probe); } jobState.executor.shutdownNow(); } } }
if (image.getMipMapSizes() != null) { result.setMipMapSizes(image.getMipMapSizes().clone());
if (image.getMipMapSizes() != null) { result.setMipMapSizes(image.getMipMapSizes().clone());
TextureCubeMap pem = store; int nbMipMap = store.getImage().getMipMapSizes().length; if (!sourceEnvMap.getImage().hasMipmaps() || sourceEnvMap.getImage().getMipMapSizes().length < nbMipMap) { throw new IllegalArgumentException("The input cube map must have at least " + nbMipMap + "mip maps");
int[] mipSizes = image.getMipMapSizes(); int pos = 0;
/** * 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; }
public static Node getCubeMapCrossDebugViewWithMipMaps(TextureCubeMap cubeMap, AssetManager assetManager) { Node n = new Node("CubeMapDebug" + cubeMap.getName()); int size = cubeMap.getImage().getWidth(); int nbMips = cubeMap.getImage().getMipMapSizes().length; Picture[] pics = new Picture[6*nbMips]; for (int mipLevel = 0; mipLevel < nbMips; mipLevel++) { size = Math.max(1, cubeMap.getImage().getWidth() >> mipLevel); int dataSize = cubeMap.getImage().getMipMapSizes()[mipLevel]; byte[] dataArray = new byte[dataSize]; for (int i = 0; i < 6; i++) {
cubeImage.addData(frontImg.getData(0)); cubeImage.setMipMapSizes(rightImg.getMipMapSizes());