Rick Strahl's Weblog  

Wind, waves, code and everything in between...
.NET • C# • Markdown • WPF • All Things Web
Contact   •   Articles   •   Products   •   Support   •   Advertise
Sponsored by:
Markdown Monster - The Markdown Editor for Windows

Image Capture with SnagIt in VFP


:P
On this page:

Today I spent some time making a few requested enhancements to Help Builder and one thing I wanted to do for a while is add support for doing image capture with SnagIt via its COM interface. One of the really nice features in SnagIt is the object capture (by just clicking on any Screen element) and it's a breeze to implement this and add it to your own applications assuming your customers have SnagIt installed (there's no 'runtime' licensing). However, given that I've recently demo'd this new feature this doesn't seem to be a problem - most of the people either already knew or where already using SnagIt for other things. Bonus!

I haven't used SnagIt all that much primarily because I tend to use PaintShop Pro for image capture mainly because it produces smaller images than any other capture utility I've used. However, I got SnagIt as part of a bundle with CamTasia and decided to install it today, and certainly SnagIt is a wonderful tool for the process of capturing. Anyway, to add this functionality was wonderfully smooth:

Function CaptureImageWithSnagIt
LOCAL oSnag as SnagIt.ImageCapture.1, lcFile

oSnag = CREATEOBJECT("SnagIt.ImageCapture.1")
oSnag.EnablePreviewWindow = .t. oSnag.Input = 10 && Object oSnag.Output= 2 && sioFile oSnag.OutputImageFile.Filename = "captured_Image.png" oSnag.OutputImageFile.FileType= 5 && siftPNG IF !EMPTY(this.cSaveDirectory) oSnag.OutputImageFile.Directory = this.cSavedirectory ELSE oSnag.OutputImageFile.Directory = SYS(5) + CURDIR() + "images" ENDIF oSnag.OutputImageFile.FileType= 5 && siftPNG oSnag.Capture() DO WHILE .t. if oSnag.IsCaptureDone() EXIT ENDIF DOEVENTS WAIT WINDOW "" TIMEOUT .01 ENDDO lcFile = LOWER(oSnag.LastFileWritten) IF EMPTY(lcFile) RETURN ENDIF *** If EditControl was passed paste into it IF VARTYPE(THIS.oEditControl) = "O" AND ; THIS.oEditControl.SelStart = THIS.nEditControlSelStart this.InsertLink( lcFile,THIS.oEditControl) ENDIF oSnag = .F.

This code is part of a class so there are a few references to internal properties, but you should be able to get the general idea here. The odd thing about the interface is that the capture itself is synchronous, but the file save operation is asynchronous. This threw me for a loop as I had a hard time getting the LastFileWritten property retrieved. Waiting in a loop until completed fixed this issue.

 


The Voices of Reason


 

Manu
May 12, 2004

# re: Image Capture with SnagIt in VFP

I'm using Irfanview and its command-line abilities.

I'm using this simple command to make my captures :

RUN /N SYS\i_view32.exe /capture /convert=&lcDump..GIF

I'm using it in my Global Error Handler.

Martín Salías
June 10, 2004

# re: Image Capture with SnagIt in VFP

SnagIt is a hell of a product. Something I use that didn't see at any other place: Scrollable captures. You can make SnagIt to capture a snapshot of a Web Page, for example, which is longer than the actual height of your browser window. It just automatically scrolls down while capturing. Pretty cool!

# Andrew MacNeill - AKSEL Solutions: June 2004


West Wind  © Rick Strahl, West Wind Technologies, 2005 - 2024