WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Miscellaneous

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Take a Snapshot of Currently Active Window and Convert BMP to JPG

Keywords: 	 Convert JPG to BMP pixie

The following takes a snapshot of the current active window and then creates a JPG of it.
;Take snapshot of currently active window (client area)
;Convert to BMP to JPG

;Takes a bitmap snapshot of the screen and pastes it to the clipboard.
Snapshot(1)

;returns the size of buffer needed for a subsequent BinaryAlloc, 
;but doesn't attempt to place the contents of clipboard into a buffer
size=BinaryClipGet(0,8)

;allocates a data buffer
bb=BinaryAlloc(size)

;read file format type CF_DIB
BinaryClipGet(bb,8)

; need to add first 14 bytes to make it 
; a BMP file format
bmpdatasize=14
bb2=BinaryAlloc(size + bmpdatasize)

;The characters identifying the bitmap.
;'BM' - Windows 3.1x, 95, NT, ...
BinaryPokeStr(bb2, 0, "BM") 

;Complete file size in bytes.
BinaryPoke4(bb2,2,size + bmpdatasize)

;Reserved
BinaryPoke4(bb2,6,0)

;Data offset
headersize=BinaryPeek4(bb,0)
dataoffset = headersize + bmpdatasize
BinaryPoke4(bb2,10,dataoffset)
BinaryCopy(bb2,bmpdatasize,bb,0,size)
BinaryWrite(bb2,"c:\temp\screenshot.bmp")
BinaryFree(bb)
BinaryFree(bb2)


AddExtender("WWIMG34I.DLL")

img1="c:\temp\screenshot.BMP"
img2="c:\temp\screenshot.JPG"

ImgConvert(img1,img2)


Message("All","Done")

Article ID:   W15181
File Created: 2002:09:05:13:50:22
Last Updated: 2002:09:05:13:50:22