![]() |
I have been looking for a long time for a JPEG package that will allow me to show a JPEG file in my program, espically in FoxPro. I never found one that didn't cost hundreds of dollars and didn't need complicated programming. Thanks for excellent works of Independent JPEG Group's software of IJG JPEG library and thanks for CHRISDL@PAGESZ.NET's MFC examples, I wrote a win32 JPG api dll by my myself. You can call it to show a JPG file in your program by only one sentence: showjpg(fliename,hwnd,left,top). No more is needed to know. Below is a screen shot of a form of VFP5.0: . ![]() Win32 JPG API is composed of only four functions: 1. long showjpg(char *fliename, long hwnd, long left, long top) This function show a JPG file in a window at (left,top). Here hwnd is handle of the window. If return 1, then all is ok. Example: rs=showjpg("c:\jpgdemo\demo.jpg",hwnd,10,10) 2. long jpg_to_bmp(char *jpgfilename, char *bmpfilename) This function copy a JPG file to a BMP file. VB, VC, and FoxPro support BMP, so you can also show a JPG file by this way. If return 1, then all is ok. Example: rs=jpg_to_bmp("c:\jpgdemo\demo.jpg","c:\temp\demo.bmp") 3. long to_clip(long hwnd, long type) This function copy a screen shot of a window(like above) to the clipboard, then you can paste it to any picture program to edit. Here type is type of copy(0=all window,1=client area). Example: rs=to_clip(hwnd,0) 4. long copy_to_bmp(long hwnd, char *bmpfilename, long type) This function copy a screen shot of a window to a BMP file. Here type is type of copy(0=all window,1=client area). Example: rs=copy_to_bmp("c:\temp\demo.bmp",hwnd,0) . Its usage is vary simple. Below is a example of how to use it in Visual FoxPro. The form is like above. 1.Init of form (Declare JPG Functions in foxjpg.exe) SET Library TO "c:\foxjpg\Foxtools.fll" DECLARE long showjpg IN "c:\foxjpg\jpg.exe"; STRING name, long hwnd, long l, long t DECLARE long jpg_to_bmp IN "c:\foxjpg\jpg.exe"; STRING name, STRING name1 DECLARE long showjpg IN "c:\foxjpg\jpg.exe"; STRING name, long hwnd, long l, long t DECLARE long copy_to_bmp IN "c:\foxjpg\jpg.exe"; long hwnd, STRING name, long area DECLARE long to_clip IN "c:\foxjpg\jpg.exe"; long hwnd, long area 2.Click of Show Button (Show a JPG file in form) hwnd=_whtohwnd(_WGetPort( )) // Get handle of this form =showjpg("c:\foxjpg\mountain.jpg",hwnd,10,8) // Show picture at (x=10,y=8) 3.Click of Copy Button (Copy Form to Clipboard) hwnd=_whtohwnd(_WGetPort( )) =to_clip(hwnd,0) 4.Click of CopyTo Button (Copy Form to a BMP file) hwnd=_whtohwnd(_WGetPort( )) =copy_to_bmp(hwnd,"c:\foxjpg\demo.bmp",0) 5.Click of SaveAs Button (Save a JPG file as a BMP file) =jpg_to_bmp("c:\foxjpg\cloud.jpg","c:\foxjpg\cloud.bmp") 6.Click of Close (Close form) clear dlls thisform.release . Download a JPGAPI32(160KB) (need mfc42d.dll) . Shareware Registration If you want to remove the unregister message, you can register the software by paying to me US$20. This will encourage me to keep on developing new programs and enhancing the old ones. My email is: heliso@public.wuhan.cngb.com . |