0

Suppose that I am drawing a set of images using java graphics objects. Suppose that I java is outputting these images to my monitor. Where is the file or files that are sent to the monitor card (the graphical representation files). How can I take this file and save it to disk, or how can I take this file and write it to an array, or how can I take these files and combine the results of their output (to the monitor) into a single file for saving? I don't want to use a screen shot feature, I want to be able to redirect (xor capture also) the output to the monitor to some sort of byte-stream. I note that monitors are much better than semaphores, when you are talking about display capabilities; I don't need a counter example.

I might not be asking the correct question. It might be that I want to capture the file while it is still in User Space, before it is put into 'Device Space'. I would like to try and capture the byte stream so that I can convert it to MPEG-4 format. I either need a streaming output from the MPEG-4 converter, coming from the streaming input, or else, I need to take static images at discrete times and convert the images.

What format will the output from User Space be in? What format will the Device Space output be in? Try to keep speculation to a minimum.

http://docs.oracle.com/javame/config/cdc/opt-pkgs/api/jsr927/index.html

I guess that Java has made a means of displaying AWT objects on a television screen. (Java TV).

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Ryan Zoerner
  • 63
  • 1
  • 10
  • Basically you need to render what's on the screen to a `BufferedImage`, from there you can save it. Start by having a look at [this](http://stackoverflow.com/questions/12575201/how-to-save-a-image-on-jframe/12575259#12575259) and [this](http://stackoverflow.com/questions/12984207/cannot-convert-current-canvas-data-into-image-in-java/12984332#12984332) from some ideas. From my understanding, most people who do this type of thing (screen capture), tend to use a similar process and pool n times a second to grab the frames – MadProgrammer Nov 09 '12 at 22:55
  • Check out [Movie Maker](http://www.randelshofer.ch/monte/) which can do full screen transcription to MOV using JMF at around 20 FPS. For more modern solutions see things like Xuggle or jffmpeg. *Capturing screenshots and saving images (or bitmaps) to file (or archive) is neither easy nor quick. My experience suggest it needs to be done direct to video for any worthwhile (high FPS) result.* – Andrew Thompson Nov 10 '12 at 01:22

1 Answers1

1

In Java both the "user" and "device" data are handled via images and rasters. If you dig a little deeper in the source files you'll see that the SunGraphics2D, which is used for drawing behind the scenes, uses pipes (SunGraphics2D lines 154-159) which again uses Blits to transfer the graphics data onto an image (or a 2-dimensional screen). And both the graphics and pipes are programmed to do only this. So it is as MadProgrammer said - you need to render the graphics on an image to extract it. And this is basically as low-level as you get before the native implementations kick in.

This can be done in parallel with the normal paint-mechanisms running in Java. the thread MadProgrammer mentioned gives excellent examples really.

Community
  • 1
  • 1
Jens Egholm
  • 2,730
  • 3
  • 22
  • 35