Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Screen Capture/JPG/BMP/Wallpaper

Graphics

Screen Capture/JPG/BMP/Wallpaper

by  baltman  Posted    (Edited  )
I've recieved permission from James Khan to post this information and redistribute his dll. The major features, described in more detail below, are:

Capture window or screen image into a bitmap file

Capture window or screen image into a bitmap file and specify an area of screen/window to save

Convert a bmp file to a jpg file

Convert a jpg file to a bmp file

Get a dimensions of a bitmap

Get a dimensions of a jpeg file

For additional sample code, please refer to Thread184-769626.

Thanks to TeknoSDS, you can currently download from:
ftp://tek-tips:tek-tips@69.14.191.20/tek-tips/pct_dll/pct_dll.zip

or

http://www.vfug.org/files/pct_dll.zip

My addition is code that works with James' dll to set the Windows Desktop Wallpaper using JPGs converted to BMPs on the fly:

lcWallpaper="C:\Documents and Settings\brian\My Documents\My Pictures\Img_0011.jpg"

Declare Integer tobmp IN "PCT_DLL.dll" ;
String jpgfilename, String bmpfilename

retval = tobmp(lcWallpaper,JUSTPATH(lcWallpaper)+"\"+JUSTSTEM(lcWallpaper)+".bmp")

lcWallpaper=JUSTPATH(lcWallpaper)+"\"+JUSTSTEM(lcWallpaper)+".bmp"

DO JpgWallPaper WITH lcWallpaper

PROCEDURE JpgWallPaper
PARAMETERS lcWallpaper
DECLARE INTEGER SystemParametersInfo IN WIN32API ;
INTEGER uiAction, INTEGER uiParam,;
STRING @pvParam, INTEGER fWinIni

SystemParametersInfo (20 , 0, @lcWallpaper, 3)

Brian

====================================================================================================
From James Khan:

Last year, I've spend a lot of time to develop a picture treatment dll, there are 6 functions in this dll,
they are:

1 formtobmp
2 formtobmpA
3 tojpeg
4 tobmp
5 getbmpdimension
6 getjpgdimension

Anybody who needs the (C++) source code of this dll, please email to njjane@21cn.com

James Khan
njjane@21cn.com
http://www.myf1.net/foxcryptor/
====================================================================================================

Important : To use PCT_DLL.dll, you must put it to your system directory or current directory!!!

--------------------------------------------------------------------------------
1 formtobmp
--------------------------------------------------------------------------------
Description:
Capture window or screen image into a bitmap file

Declaration:
Declare Integer formtobmp IN "PCT_DLL.dll" ;
integer hwnd,String bmpFileName

Parameters:
hwnd
Handle to the window to be saves to a bitmap file. If this parameter is zero, then saves desktop to a bitmap file.

bmpFileName
The bitmap filename to be save. Must include full path name.

Note:
The function returns a zero result on success,else 1 is returned.

Example in Visual FoxPro:

retVal = formtobmp(0,"c:\screen.bmp") && Save screen to file c:\screen.bmp
if retval = 0 && if success
messagebox("Capture screen ok! bmp file has been saved to file c:\screen.bmp")
endif

--------------------------------------------------------------------------------
2 formtobmpA
--------------------------------------------------------------------------------
Description:
Capture window or screen image into a bitmap file and specify an area of screen/window to save.

Declareation:
Declare Integer formtobmpA IN "PCT_DLL.dll" ;
string bmpfilename,integer nX,integer nY,integer nX2,integer nY2

Parameters:
bmpFileName
The bitmap filename to be save. must include full path name.
nX
x-coord of upper-left corner of bitmap file
nX2
x-coord of lower-right corner of bitmap file
nY
y-coord of upper-left corner of bitmap file
nY2
y-coord of lower-right corner of bitmap file

Note:
The function returns a zero result on success,else 1 is returned.

Example in Visual FoxPro:

retVal = formtobmpA("c:\screen0.bmp",20,20,400,400) && Save screen to file c:\screen.bmp
if retval = 0
messagebox("Capture screen ok!")
else
messagebox("Failure!")
endif

--------------------------------------------------------------------------------
3 tojpeg
--------------------------------------------------------------------------------
Description:
Convert a bmp file to a jpg file

Declaration:
Declare Integer tojpeg IN "PCT_DLL.dll" ;
String bmpfilename, String jpgfilename

Parameters:
bmpfilename
BMP filename to be convert.
jpgfilename
JPEG filename

Note:
The function returns a zero result on success, else 1 is returned.

Example in Visual FoxPro:

retval = tojpeg("c:\screen.bmp","c:\screen.jpg") && Convert c:\screen.bmp to c:\screen.jpg

if retval = 0
messagebox("Convert bitmap to jpeg ok!")
else
messagebox("Failure!")
endif

--------------------------------------------------------------------------------
4 tobmp
--------------------------------------------------------------------------------
Description:
Convert a jpg file to a bmp file

Declaration:
Declare Integer tobmp IN "PCT_DLL.dll" ;
String jpgfilename, String bmpfilename

Parameters:
jpgfilename
JPEG filename to be convert.
bmpfilename
BMP filename

Note:
The function returns a zero result on success, else 1 is returned.

Example in Visual FoxPro:

retval = tobmp("c:\screen.jpg","c:\screen2.bmp") && Convert c:\screen.jpg to c:\screen2.bmp
if retval = 0
messagebox("Convert jpeg to bitmap success!")
else
messagebox("Failure!")
endif

--------------------------------------------------------------------------------
5 getbmpdimension
--------------------------------------------------------------------------------
Description:
Get a dimensions of a bitmap

Declaration:
Declare Integer getbmpdimension IN "PCT_DLL.dll" ;
string bmpfilename, integer @ nwidth,integer @ nheight

Parameters:
bmpfilename
origin bitmap filename.

nwidth
bitmap's width measured in pixels.

nheight
bitmap's height measured in pixels.

Note:
if success, return value 0, else return 1.
if success, variable nwidth hold the bitmap's width ,variable nheight hold the bitmap's height.

Example in Visual FoxPro:

nwidth=0
nheight=0
retval = getbmpdimension("c:\screen.bmp",@ nwidth, @ nheight)
if retval = 0
messagebox("Width:"+str(nwidth)+chr(13)+"Height:"+str(nheight))
else
messagebox("Failure!")
endif

--------------------------------------------------------------------------------
6 getjpgdimension
--------------------------------------------------------------------------------
Description:
Get a dimensions of a jpeg file

Declaration:
Declare Integer getjpgdimension IN "PCT_DLL.dll" ;
string jpgfilename, integer @ nwidth,integer @ nheight

Parameters:
jpgfilename
origin jpeg filename.

nwidth
jpeg's width measured in pixels.

nheight
jpeg's height measured in pixels.

Note:
if success, return value 0, else return 1.
if success, variable nwidth hold the jpeg's width ,variable nheight hold the jpeg's height.

Example in Visual FoxPro:

nwidth=0
nheight=0
retval = getjpgdimension("c:\screen.jpg",@ nwidth, @ nheight)
if retval = 0
messagebox("Width:"+str(nwidth)+chr(13)+"Height:"+str(nheight))
endif

clear dlls
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top