Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Is there a efficient way to take a screenshot in Java?

 
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys.

I am planning to write a "Terminal Service" or "VNC" pure Java program (no native code), that is Plataform-independent and efficient. So, I was planning initially to take screenshots of the screen, about 3 a second minimum.

I wrote this code (below), but each screenshot takes about 300ms to be taken, on a 900MHz Athlon machine, 1024x768x32Bit resolution. I tested then on a Athlon XP 2700+ machine, and it took about 100ms to take a 1280x1024x32Bit screenshot.

I need to reduce this time to about 30ms on a fast machine and 100ms on a slow machine (like Pentium III 500MHz), is there any way to do that?

Any ideias, code, links etc would be VERY welcome.

My code:



Thanks for any reply!
 
bengt hammarlund
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
another question...

I just tested the same program with the same 900MHz machine, but a 16Bit (1024x768).

The time it took for each screenshot increased!! It went to about 300ms to 400ms! Testing again on 32Bit, it took the usal 300ms. I guess my video hardware is optimized for 32Bit color...?

so, the speed of the screenshot depends on how fast is the graphics card?

Please, if you got any spare time, test this code on your machine(s) and post the avarage time for each screenshot, and your computer configuration (CPU, Graphics card).

Thanks for any help!
 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This was my output :

190
220
160
191
150
170
160
231
170
170

Intel Pentium 4, 1600
512 Mb SDRAM
Radeon 9600 Pro, 256 Mb RAM
Resoulution, 1024*768


kind regards
Igor
 
bengt hammarlund
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for the reply.

As you can see, it's a bit too slow for my needs. I need a faster way!
 
Ranch Hand
Posts: 1071
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To my understanding the way the better VNC programs work is by installing their own video driver and capturing the native draw commands. I don't think you can do a pure Java implementation of that.
 
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is my output

125
109
125
141
109
125
109
110
125
109
Finished

Pentium IV HT 3.3 Ghz
512 Mb RAM
128 Mb Video

Gio :-)
 
bengt hammarlund
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for the replyes guys. I don't think I can do it in Java, actually. I would have to:
1) control mouse and keyboard devices from remote computer (is it possible?)
2) get screenshots, at least 3 per second, and hopefuly get from screen only what changed to send to remote computer view client (don't think it's possible too)

I think that both problems above demand native code, so a pure Java implementation is, at least in my head, impossible.

Thanks for all your help guys!
 
Why does your bag say "bombs"? The reason I ask is that my bag says "tiny ads" and it has stuff like this:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic