Forum: Ruby Making screenshots with Ruby

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
7a66a453f442aaa28183e8b21f8a8ec5?d=identicon&s=25 Thomas (Guest)
on 2005-12-26 20:13
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
0f07a2117ccce0aa66069cb31d22168f?d=identicon&s=25 Antonio Cangiano (Guest)
on 2005-12-26 20:35
(Received via mailing list)
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.html#capture

Cheers,
E29eaefee1709918198c8a4f55c42667?d=identicon&s=25 anne001 (Guest)
on 2005-12-27 07:10
(Received via mailing list)
> 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.
Abb249055208c7af4d35568e422dfd63?d=identicon&s=25 Guest (Guest)
on 2005-12-28 23:52
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=...),
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.
Abb249055208c7af4d35568e422dfd63?d=identicon&s=25 Guest (Guest)
on 2005-12-29 00:01
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 :)
697ee082a55df935c7d174b91389adba?d=identicon&s=25 unknown (Guest)
on 2005-12-31 12:27
(Received via mailing list)
I would be interestde in how you solved this

Regards,
Bryan Webb
37a3c73ffbf864e4b28f7f2384ee12ce?d=identicon&s=25 Timothy Hunter (tim-hunter)
on 2005-12-31 12:48
(Received via mailing list)
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.ht...
This topic is locked and can not be replied to.