[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Making screenshots with Ruby

Thomas

12/26/2005 7:14:00 PM

Hello,

Can anyone help me with this one? Been looking for information about it,
but couldn't find any...

I want my program to make a screenshot of the screen (or better: a
specific window), and it should be able to get some data from the
screenshot (compare parts to other images)

Does anyone know how to tackle this problem?

Thanks,

Thomas

--
Posted via http://www.ruby-....


6 Answers

Antonio Cangiano

12/27/2005 1:32:00 AM

0

Thomas wrote:
> Hello,
>
> Can anyone help me with this one? Been looking for information about it,
> but couldn't find any...
>
> I want my program to make a screenshot of the screen (or better: a
> specific window), and it should be able to get some data from the
> screenshot (compare parts to other images)
>
> Does anyone know how to tackle this problem?

Using the excellent RMagick:
http://redux.imagemagick.org/RMagick/doc/image1.ht...

Cheers,
--
Antonio Cangiano
My Ruby blog: http://www.antonioca...

anne001

12/27/2005 6:05:00 AM

0

> I want my program to make a screenshot of the screen

I think the rubycocoa example simpleapp does that, you could look at
how they do it.

User

12/28/2005 10:53:00 PM

0

Unfortunately cacao is for mac, and the RMagick function is for x
(linux), while I need Windows... Any tips? Maybe there's a way using the
Win32 API?

I don't know how to create a "DestDC" for the bitblt function
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/bitmap...),
so I have no idea what to do... Currently I'm using a Visual Basic
program which takes a screenshot (using the clipboard, automatically
pressing the printscreen button) but ofcourse that's not a good
solution, and it needs harddrive access...

Thanks.

--
Posted via http://www.ruby-....


User

12/28/2005 11:02:00 PM

0

Oh and forgot to add - I'm using them later with RMagick, so I'd want
them loaded in memory in a way that RMagick can understand them, but if
it has to it can be saved to file too :)

--
Posted via http://www.ruby-....


bww00amdahl

12/30/2005 3:42:00 PM

0

I would be interestde in how you solved this

Regards,
Bryan Webb

guest@guest.com wrote:
> Oh and forgot to add - I'm using them later with RMagick, so I'd want
> them loaded in memory in a way that RMagick can understand them, but if
> it has to it can be saved to file too :)
>
> --
> Posted via http://www.ruby-....

Tim Hunter

12/30/2005 4:08:00 PM

0

guest@guest.com wrote:
> Oh and forgot to add - I'm using them later with RMagick, so I'd want
> them loaded in memory in a way that RMagick can understand them, but if
> it has to it can be saved to file too :)
>
There are a couple of ways to construct an RMagick image without reading
an image file. If the screenshot data is in a Ruby string in one of the
formats that ImageMagick/GraphicsMagick understands (JPEG, GIF, BMP, or
one of the 80+ others) then you can use Image.from_blob[1].

If the screenshot data is in a Ruby string (or an instance of any class
with a to_str method, such as NArray) and is simply "raw" pixel data in
scanline order (left-to-right, top-to-bottom) you use the
Image.import_pixels method. It's blindingly fast. (I'd give you a URL to
the doc, but the online doc is sufficiently out-of-date that it doesn't
describe how import_pixels exploits to_str. You can get the details from
your local copy of the RMagick doc.)

[1] http://www.simplesystems.org/RMagick/doc/image1.html...