How to make a screenshot?

Started by mueer01, December 19, 2023, 11:58:35 PM

Previous topic - Next topic

mueer01

Hi all,

I used the example from the function snapshot(). It works, but generates a bitmap only.
Is there any way to generate a screenshot as .jpg or .png ?

Regards,
Erhard

td

You would need to perform the conversion yourself. There are several ways to accomplish the task and examples of a few of those methods can be found in the Tech Database. Unfortunately, some of the conversion techniques involve the deprecated Pixie extender or the deprecated ImageMagic COM automation interfaces. There are still several other approaches available for use with WinBatch including Gnuplot and Jim's Omnibus extender which may have some image conversion capacity. I have not used either one so I have no opinion on which option is the best.  You can still download the Pixie extender (WWIMG34I.DLL) but it is not supported and has not been tested for about 10 years.

Other WinBatch users may have better suggestions and if so, will hopefully post on this topic thread.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

JTaylor

Yes.  My Omnibus Extender will do the conversion.   May be other, better, solutions but can't say.    I still use the Pixie extender in some things, I think, and it still seems to work okay so that might be a solution as well.  Would, obviously, have to test for what you are doing.

         http://www.jtdata.com/anonymous/wbOmnibus.zip

Jim

td

"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

nrr

I use SnagIt from Techsmith.  It is reasonably priced and can capture screen shots and much more, including making a video of everything happening on the screen ... great for creating a training video.  They do provide a free trial.
Nick

td

Here is a simple WinBatch solution using WIL CLR hosting(.Net) to convert from .bmp to .jpg format.

Code (winbatch) Select
ObjectClrOption("useany", "System.Drawing")

SysDrawImg = ObjectClrNew("System.Drawing.Image")
Image = SysDrawImg.FromFile("C:\Temp\116_1611.bmp") ; <Your bmp here>
JpegGuid = ObjectClrNew("System.Guid", "b96b3cae-0728-11d3-9d7b-0000f81ef32e") ; Do not ask
ImageFormat = ObjectClrNew("System.Drawing.Imaging.ImageFormat", JpegGuid )
Image.Save("C:\Temp\Example.jpg", ImageFormat.Jpeg)  ; <Your jpeg here>
Image.Finalize() ; Free resources.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

td

A slightly more convoluted example that creates a jpeg file without an intermediate bmp file.

Code (winbatch) Select
; Formate a screen snapshot shot.
SnapShot(3)
size=BinaryClipGet(0,8)
hBmp=BinaryAlloc(size)
BinaryClipGet(hBmp,8)
hBmp2=BinaryAlloc(size + 14)
BinaryPokeStr(hBmp2, 0, "BM")
BinaryPoke4(hBmp2,2,size + 14)
BinaryPoke4(hBmp2,6,0)
headersize=BinaryPeek4(hBmp,0)
dataoffset = headersize + 14
BinaryPoke4(hBmp2,10,dataoffset)
BinaryCopy(hBmp2,14,hBmp,0,size)

aBmp = ObjectType("array|i1", hBmp2)

ObjectClrOption("useany", "System.IO")
MemStream = ObjectClrNew("System.IO.MemoryStream", aBmp)
BinaryFree(hBmp)
BinaryFree(hBmp2)

ObjectClrOption("useany", "System.Drawing")

SysDrawImg = ObjectClrNew("System.Drawing.Image")
Image = SysDrawImg.FromStream(MemStream) ; Bmp stream
JpegGuid = ObjectClrNew("System.Guid", "b96b3cae-0728-11d3-9d7b-0000f81ef32e") ; Do not ask
ImageFormat = ObjectClrNew("System.Drawing.Imaging.ImageFormat", JpegGuid )
Image.Save("C:\Temp\Example.jpg", ImageFormat.Jpeg)  ; <Your jpeg here>
Image.Finalize() ; Free resources.
exit
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade