}
ByteBuffer data = BufferUtils.createByteBuffer(imageWidth * imageHeight * (imageFormat.getBitsPerPixel() >> 3));
image = new Image(texture.getImage().getFormat(), imageWidth, imageHeight, data);
// computing the pixels
PixelInputOutput pixelWriter = PixelIOFactory.getPixelIO(imageFormat);
TexturePixel pixel = new TexturePixel();
float[] uvs = new float[3];
Vector3f point = new Vector3f(envelope.min);
Vector3f vecY = new Vector3f();
Vector3f wDelta = new Vector3f(envelope.w).multLocal(1.0f / imageWidth);
Vector3f hDelta = new Vector3f(envelope.h).multLocal(1.0f / imageHeight);
for (int x = 0; x < imageWidth; ++x) {
for (int y = 0; y < imageHeight; ++y) {
this.toTextureUV(boundingBox, point, uvs);
texture.getPixel(pixel, uvs[0], uvs[1], uvs[2]);
pixelWriter.write(image, 0, pixel, x, y);
point.addLocal(hDelta);
}
vecY.addLocal(wDelta);
point.set(envelope.min).addLocal(vecY);