woodcutter Apr 27, 2008
==='Image conversion and screen dump for LB4.03 utilising pct_dll.dll=== ' 'DLL source - http://www.tek-tips.com/faqs.cfm?fid=4824 (Visual FoxPro forum) 'DLL author has given permission for the dll to be distributed via the above link. 'Contact the author (James Khan, [[mailto:njjane@21cn.com|njjane@21cn.com]]) if you wish to use his DLL in 'commercial applications. 'The dll has six functions '1 copy window or screen to bmp '2 copy screen area to bmp '3 convert bmp to jpeg '4 convert jpg to bmp '5 get bmp dimensions '6 get jpg dimensions nomainwin WindowWidth=500 open "pct_dll.dll demo" for text as #1 #1, "!trapclose [quit]" hW=hwnd(#1) calldll #user32, "GetParent", _ hW as long, _ hP as long open "pct_dll.dll" for dll as #conv #1, "pct_dll.dll demo";chr$(13) '1 window to bmp dest$=DefaultDir$+"\window.bmp" 'hP=0 'for full screen dump calldll #conv, "formtobmp", hP as ulong, dest$ as ptr, r as long if r=0 then r$="Successful" else r$="failed" #1, "screen dump to window.bmp ";r$ '2 screen area to bmp x1=50:x2=250 y1=50:y2=250 dest$=DefaultDir$+"\screenArea.bmp" calldll #conv, "formtobmpA", dest$ as ptr, x1 as long,_ y1 as long, x2 as long, y2 as long, r as long if r=0 then r$="Successful" else r$="failed" #1, "screen area dump to screenArea.bmp ";r$ '3 bmp to jpeg source$="ssl.bmp":dest$="ssl.jpg" 'return zero = success, 1 = fail calldll #conv, "tojpeg", source$ as ptr, dest$ as ptr, r as long if r=0 then r$="Successful" else r$="failed" #1, "Conversion bmp to jpg ";r$ '4 jpg to bmp source$="ssl.jpg":dest$="ssl2.bmp" 'return zero = success, 1 = fail calldll #conv, "tobmp", source$ as ptr, dest$ as ptr, r as long if r=0 then r$="Successful" else r$="failed" #1, "Conversion bmp to jpg ";r$ '5 get bmp dimension struct width, nwidth as long struct height, nheight as long bmpfilename$="ssl2.bmp" calldll #conv,"getbmpdimension", bmpfilename$ as ptr, width as struct, height as struct,r as long #1, "bmp WxH - ";width.nwidth.struct;"x";height.nheight.struct if r<>0 then #1, "Unable to get dimensions of bmp!" width.nwidth.struct=0:height.nheight.struct=0 '6 get jpg dimension jpgfname$="ssl.jpg" calldll #conv,"getjpgdimension", jpgfname$ as ptr, width as struct, height as struct,r as long #1, "jpg WxH - ";width.nwidth.struct;"x";height.nheight.struct if r<>0 then #1 "Unable to get dimensions of jpg!" close #conv wait [quit] close #1 end