hello!
i create a new snapshot (canvas snapshot) , i want to put the picture which has been rendered on the suspensive 3DWorld , but the load time is too lang, so i just want to replace the picture on hand with its reduced picture and put it on the 3DWorld (paused ) . After the picture load complete i will use it to replace the reduced picture. and my question is how should i get the reduced picture???
he code is presented as follows:
[java]
int height = viewPort.getCamera().getHeight();
int width = viewPort.getCamera().getWidth();
BufferedImage rawFrame = new BufferedImage(width, height,BufferedImage.TYPE_4BYTE_ABGR);
ByteBuffer byteBuffer = BufferUtils.createByteBuffer(width * height * 4 );
renderManager.getRenderer().readFrameBuffer(viewPort.getOutputFrameBuffer(), byteBuffer);
Screenshots.convertScreenShot(byteBuffer, rawFrame);
[/java]
I want get a BufferedImage image and it’s size as follows
width = width / 2;
height = height /2;
how to do?
PS: Please write easy because my English very poor….
Best regards !!
[java]
public class V3DWorld extends SimpleApplication implements SceneProcessor {
// i implement SceneProcessor for snapshot.
private FrameBuffer offBuffer = null;
private ByteBuffer cpuBuf = null;
private BufferedImage image = null;
private AtomicBoolean firstTime = new AtomicBoolean(true);
private ViewPort offView = null;
//…
}
[/java]
as follows
[java]
@Override
public void initialize(RenderManager rm, ViewPort vp) {
}
@Override
public void reshape(ViewPort vp, int w, int h) {
}
@Override
public boolean isInitialized() {
return true;
}
@Override
public void preFrame(float tpf) {
}
@Override
public void postQueue(RenderQueue rq) {
}
@Override
public void postFrame(FrameBuffer out) {
updateImageContents(out);
}
@Override
public void cleanup() {
}
public void updateImageContents(FrameBuffer out) {
if (firstTime.get()) {
cpuBuf.clear();
renderer.readFrameBuffer(offBuffer, cpuBuf);
synchronized (image) {
Screenshots.convertScreenShot(cpuBuf, image);
}
firstTime.set(false);
render.setImage(image);//
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
rendToCanvas();
setPaused(true);
}
});
}
}
[/java]
[java]
private void setupOffscreenView(int width, int height) {
cpuBuf = BufferUtils.createByteBuffer(width * height * 4/* 4 */);
image = new BufferedImage(width, height,
BufferedImage.TYPE_4BYTE_ABGR);
offBuffer = new FrameBuffer(width, height, 1);
offBuffer.setDepthBuffer(Format.Depth24);
offBuffer.setColorBuffer(Format.RGB8);
this.enqueue(addProcessor);
}
[/java]
i will crazy for this issue,Can anyone help me please???
Why are you double posting? http://hub.jmonkeyengine.org/groups/graphics/forum/topic/loading-snapshot-for-3d-city-issue/#post-188955