| 1 |
|
| 2 |
#include "defextern.h" |
| 3 |
|
| 4 |
|
| 5 |
#ifndef STRICT |
| 6 |
#define STRICT |
| 7 |
#endif |
| 8 |
|
| 9 |
#include <windows.h> |
| 10 |
#include "mes.h" |
| 11 |
#include "initial.h" |
| 12 |
#include "file.h" |
| 13 |
#include "status.h" |
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
#pragma pack(push) |
| 18 |
#pragma pack(1) |
| 19 |
|
| 20 |
|
| 21 |
typedef struct PictureInfo |
| 22 |
{ |
| 23 |
long left, top; // WJˇéĘu |
| 24 |
long width; // ćĚ |
| 25 |
long height; // ł |
| 26 |
WORD x_density; // ćfĚ
˝űü§x |
| 27 |
WORD y_density; // ćfĚźűü§x |
| 28 |
short color; // PćfĚbit |
| 29 |
HLOCAL info; // ćĚeLXgwb_ |
| 30 |
} PictureInfo; |
| 31 |
|
| 32 |
#pragma pack(pop) |
| 33 |
|
| 34 |
|
| 35 |
typedef int (CALLBACK *SPI_PROGRESS)(int, int, long); |
| 36 |
typedef int (__stdcall *SPI_GetPluginInfo)(int infono, LPSTR buf,int buflen); |
| 37 |
typedef int (__stdcall *SPI_IsSupported)(LPSTR filename, DWORD dw); |
| 38 |
typedef int (__stdcall *SPI_GetPictureInfo)(LPSTR buf, long len, |
| 39 |
unsigned int flag, struct PictureInfo *lpInfo); |
| 40 |
typedef int (__stdcall *SPI_GetPicture)(LPSTR buf, long len, unsigned int flag, |
| 41 |
HANDLE *pHBInfo, HANDLE *pHBm, |
| 42 |
SPI_PROGRESS lpPrgressCallback, long lData); |
| 43 |
|
| 44 |
SPI_GetPluginInfo GetPluginInfo; |
| 45 |
SPI_IsSupported IsSupported; |
| 46 |
SPI_GetPictureInfo GetPictureInfo; |
| 47 |
SPI_GetPicture GetPicture; |
| 48 |
|
| 49 |
|
| 50 |
HMODULE handle=NULL; |
| 51 |
|
| 52 |
|
| 53 |
BOOL getFnc(); |
| 54 |
char *searchSpi(char *ext, char *newdir); |
| 55 |
BOOL spiLoadHdl(char *spi, char *dir); |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
void FreeSpi() |
| 60 |
{ |
| 61 |
if(handle!=NULL) FreeLibrary(handle); |
| 62 |
} |
| 63 |
|
| 64 |
|
| 65 |
#define jpgSpi_0 "ifjpeg.spi" |
| 66 |
char *jpgSpi=jpgSpi_0; |
| 67 |
char spi[MAX_PATH]; |
| 68 |
|
| 69 |
|
| 70 |
BOOL test( char *file, char *spi, char *dir) |
| 71 |
{ |
| 72 |
FreeSpi(); |
| 73 |
spiLoadHdl(spi, dir); |
| 74 |
BOOL ans =getFnc(); |
| 75 |
|
| 76 |
if(ans) |
| 77 |
{ |
| 78 |
DWORD d=(DWORD)getHandle(file); |
| 79 |
if(d!=0) |
| 80 |
{ |
| 81 |
if((*IsSupported)(file, d)==0) |
| 82 |
{ |
| 83 |
setstatus("bad"); |
| 84 |
ans= FALSE; |
| 85 |
} |
| 86 |
else |
| 87 |
{ |
| 88 |
setstatus(getExt(file)); |
| 89 |
} |
| 90 |
CloseHandle((HANDLE)d); |
| 91 |
} |
| 92 |
} |
| 93 |
FreeSpi(); |
| 94 |
return ans; |
| 95 |
} |
| 96 |
|
| 97 |
// gŁqext ŠçKvČspiđTˇ |
| 98 |
|
| 99 |
BOOL searchSpi(char *file, char *newf, char *path) |
| 100 |
{ |
| 101 |
char spiext[]="*.spi"; |
| 102 |
char buff[40]; |
| 103 |
int ans; |
| 104 |
ans =getnextfile(path, spiext, newf, _RESET); |
| 105 |
if( ans ==_END ) |
| 106 |
return FALSE; |
| 107 |
if( test( file, newf, path) ) |
| 108 |
return TRUE; |
| 109 |
while( 1 ) |
| 110 |
{ |
| 111 |
ans =getnextfile(path, spiext, newf, _NEXT); |
| 112 |
if( ans ==_END ) |
| 113 |
{ |
| 114 |
break; |
| 115 |
} |
| 116 |
if( test( file, newf, path) ) |
| 117 |
return TRUE; |
| 118 |
} |
| 119 |
return FALSE; |
| 120 |
} |
| 121 |
|
| 122 |
BOOL spiLoadHdl(char *spi, char *dir) |
| 123 |
{ |
| 124 |
BOOL ret = FALSE; |
| 125 |
SetCurrentDirectory( dir); |
| 126 |
handle = LoadLibrary( spi ); |
| 127 |
return ret; |
| 128 |
} |
| 129 |
|
| 130 |
BOOL getFnc() |
| 131 |
{ |
| 132 |
BOOL ret = FALSE; |
| 133 |
if (handle != NULL) { |
| 134 |
GetPluginInfo = (SPI_GetPluginInfo) GetProcAddress(handle, "GetPluginInfo"); |
| 135 |
IsSupported = (SPI_IsSupported) GetProcAddress(handle, "IsSupported"); |
| 136 |
GetPictureInfo = (SPI_GetPictureInfo) GetProcAddress(handle, "GetPictureInfo"); |
| 137 |
GetPicture = (SPI_GetPicture) GetProcAddress(handle, "GetPicture"); |
| 138 |
ret = (IsSupported != NULL) & (GetPictureInfo != NULL) & (GetPicture != NULL); |
| 139 |
} |
| 140 |
|
| 141 |
return ret; |
| 142 |
} |
| 143 |
|
| 144 |
|
| 145 |
BOOL spiLoad(char *ext) |
| 146 |
{ |
| 147 |
char spi[MAX_PATH]; |
| 148 |
if( searchSpi( ext, spi, getSpiDir()) ==FALSE) return FALSE; |
| 149 |
spiLoadHdl(spi, getSpiDir() ); |
| 150 |
return getFnc(); |
| 151 |
} |
| 152 |
|
| 153 |
|
| 154 |
BOOL spiLoadTest(char *str) |
| 155 |
{ |
| 156 |
BOOL ans =spiLoad(str); |
| 157 |
FreeSpi(); |
| 158 |
return ans; |
| 159 |
} |
| 160 |
|
| 161 |
|
| 162 |
HBITMAP loadbmp(char *file, HLOCAL &inf, HLOCAL &bm) |
| 163 |
{ |
| 164 |
if(GetPicture != NULL) |
| 165 |
(*GetPicture)(file, 0, 0, &inf, &bm, NULL, 1); |
| 166 |
return (HBITMAP) bm; |
| 167 |
} |