Areas
  • J3D FAQ
  • Tutorials
  • Utilities
  • Books
  • News
  • Other Sites
  • FAQ Topics
  • Introduction to Java 3D
  • Documentation
  • Speed issues
  • Running Java 3D
  • Object manipulation
  • Scene appearance
  • Java 3D and Swing
  • Image capturing
  • Stereo viewing
  • Input Devices
  • Textures
  • Web browsers
  • Video Hardware
  • VRML
  •   

    Image capturing

    1. Capturing still images in JPEG format

    Return to the main FAQ page for more questions and answers.

      

    1. Capturing still images in JPEG format

    Steve Pietrowicz (srp@ncsa.uiuc.edu) says this can be done by getting inside the rendering cycle and saving out the contents of each frame. Effectively what you do is extend Canvas3D and override the postSwap() method. This method is called after J3D has rendered to the background buffer and then swapped it to screen so you know you have a completed frame.

    Don't call postSwap() directly. Set a flag in another method which you can call from within your program, and then call repaint() from within that method.

    Once the postSwap method is called, check the flag. If it has been set, you then use the readRaster() method to dump the raw bytes from the frame. You now have the option of directly dumping those bytes to disk and then post processing them or directly saving them as JPEG/MPEG/whatever.

    Peter Kunszt provided the code to show how this can be done in your own programs. Click here for the code to CapturingCanvas3D.java .

    Back to top

      

    [ Copyright Info ] [ FAQ Home ] [ J3D.org Home ] [ Tutorials ] [ Utilities ] [ Books ] [ Contact Us ]