Current News Archived News Search News Discussion Forum Old Forum Install Programs More Downloads... Troubleshooting Source Code Format Specs. Misc. Information Non-SF Stuff Links Small banner for links to this site: |
1 /*\r
2 \r
3 ShadowFlare GRP Library. (c) ShadowFlare Software 2002\r
4 \r
5 Any comments or suggestions are accepted at blakflare@hotmail.com (ShadowFlare)\r
6 */\r
7 \r
8 #ifndef GRPAPI_INCLUDED\r
9 #define GRPAPI_INCLUDED\r
10 \r
11 #include <windows.h>\r
12 \r
13 #ifdef GRPAPI_EXPORTS\r
14 #define GRPAPI __declspec(dllexport)\r
15 #else\r
16 #define GRPAPI __declspec(dllimport)\r
17 #endif\r
18 \r
19 #ifdef __cplusplus\r
20 extern "C" {\r
21 #endif\r
22 \r
23 // These no longer need to be called\r
24 extern void LoadGrpApiLib();\r
25 extern void FreeGrpApiLib();\r
26 \r
27 typedef struct {\r
28 WORD nFrames;\r
29 WORD wMaxWidth;\r
30 WORD wMaxHeight;\r
31 } GRPHEADER;\r
32 \r
33 #define HORIZONTAL_FLIP 0x00000001 // Flips the graphic horizontally\r
34 #define VERTICAL_FLIP 0x00000002 // Flips the graphic vertically\r
35 #define SHADOW_COLOR 0x00000004 // Causes the graphic to be drawn in one color\r
36 // Second byte of flags is the red component of\r
37 // the shadow's color, third byte is green,\r
38 // fourth byte is blue; like this:\r
39 // SHADOW_COLOR|0xBBGGRR00\r
40 // This can be accomplished by using the left shift\r
41 // operator like this: SHADOW_COLOR|(color << 8)\r
42 #define ALPHA_BLEND 0x00000008 // Blends the graphic with what it is being drawn over.\r
43 // The dwAlpha parameter will only be used when this\r
44 // flag is specified. dwAlpha is an RGB value\r
45 // (0xBBGGRR).\r
46 // Note: Because of the extra calculations required,\r
47 // alpha blended graphics take longer to draw\r
48 #define USE_INDEX 0x00000010 // Only valid when used with a custom SetPixel function.\r
49 // This flag cannot be used in combination with\r
50 // ALPHA_BLEND or SHADOW_COLOR\r
51 // When this flag is used, the index to a color in the\r
52 // palette will be passed to your custom SetPixel\r
53 // function instead of the actual color.\r
54 \r
55 // Palette is an array of 256 DWORD's\r
56 // For LoadPalette and LoadGrp, lpFileName may be a file in an open mpq archive\r
57 // or a file not in an archive\r
58 typedef BOOL (WINAPI* funcLoadPalette)(LPCSTR lpFileName, DWORD *dwPaletteBuffer);\r
59 typedef HANDLE (WINAPI* funcLoadGrp)(LPCSTR lpFileName);\r
60 typedef BOOL (WINAPI* funcDestroyGrp)(HANDLE hGrp);\r
61 typedef BOOL (WINAPI* funcDrawGrp)(HANDLE hGrp, HDC hdcDest, int nXDest, int nYDest, WORD nFrame, DWORD *dwPalette, DWORD dwFlags, DWORD dwAlpha);\r
62 typedef BOOL (WINAPI* funcGetGrpInfo)(HANDLE hGrp, GRPHEADER *GrpInfo);\r
63 typedef BOOL (WINAPI* funcGetGrpFrameInfo)(HANDLE hGrp, WORD nFrame, DWORD *nLeft, DWORD *nTop, DWORD *nWidth, DWORD *nHeight);\r
64 extern funcLoadPalette LoadPalette;\r
65 extern funcLoadGrp LoadGrp;\r
66 extern funcDestroyGrp DestroyGrp;\r
67 extern funcDrawGrp DrawGrp;\r
68 extern funcGetGrpInfo GetGrpInfo;\r
69 extern funcGetGrpFrameInfo GetGrpFrameInfo;\r
70 \r
71 // A pointer to the raw image data to encode should be passed to lpImageData. The size of\r
72 // the buffer containing the data should be nFrames * wMaxWidth * wMaxHeight * sizeof(short)\r
73 // and the values should be arranged row by row of the frame, with the top row first.\r
74 // After all the rows of a frame have been put into the buffer, the rows of the next frame\r
75 // go after it. For transparent pixels, they should be set to -1. All other pixels should\r
76 // have the high order byte set to zero, meaning that they should not be negative and the\r
77 // values should not exceed 255 (0xFF). The values used for the colors are indexes into the\r
78 // color palette.\r
79 // Pass TRUE to bNoCompress if you need an uncompressed GRP.\r
80 // Pass a pointer to a DWORD value to nGrpSize to receive the size in bytes of the resulting encoded GRP.\r
81 // The return value of this function is actually a pointer to the GRP data. This is what your\r
82 // program should save to a file. The size of this buffer is the value received by nGrpSize.\r
83 // When your program is done with the returned buffer, it should call DestroyGrp on the\r
84 // buffer that was returned by this function to free up the memory from it.\r
85 // The pointer returned by this function can also be directly used by DrawGrp or GetGrpInfo.\r
86 typedef HANDLE (WINAPI* funcCreateGrp)(signed short *lpImageData, WORD nFrames, WORD wMaxWidth, WORD wMaxHeight, BOOL bNoCompress, DWORD *nGrpSize);\r
87 extern funcCreateGrp CreateGrp;\r
88 \r
89 typedef COLORREF (WINAPI* GETPIXELPROC)(\r
90 HDC hDC, // same value as hdcDest from DrawGrp,\r
91 // does not need to be used as an HDC,\r
92 // can be used for any other type of pointer\r
93 int X, // x-coordinate of pixel\r
94 int Y // y-coordinate of pixel\r
95 );\r
96 typedef void (WINAPI* SETPIXELPROC)(\r
97 HDC hDC, // same value as hdcDest from DrawGrp,\r
98 // does not need to be used as an HDC,\r
99 // can be used for any other type of pointer\r
100 int X, // x-coordinate of pixel\r
101 int Y, // y-coordinate of pixel\r
102 COLORREF clrColor // new pixel color\r
103 );\r
104 \r
105 // Call these to have DrawGrp use custom functions for reading and drawing pixels\r
106 // so that you can have it read from and write to a buffer, for example.\r
107 typedef void (WINAPI* funcSetFunctionGetPixel)(GETPIXELPROC lpGetPixelProc);\r
108 typedef void (WINAPI* funcSetFunctionSetPixel)(SETPIXELPROC lpSetPixelProc);\r
109 extern funcSetFunctionGetPixel SetFunctionGetPixel; // Only used with ALPHA_BLEND\r
110 extern funcSetFunctionSetPixel SetFunctionSetPixel;\r
111 \r
112 // Call this to make a different Storm.dll-compatible MPQ library be used (like SFMPQ).\r
113 typedef BOOL (WINAPI* funcSetMpqDll)(LPCSTR lpDllFileName);\r
114 extern funcSetMpqDll SetMpqDll;\r
115 \r
116 // These no longer need to be called\r
117 typedef BOOL (WINAPI* funcLoadGrpApi)();\r
118 typedef void (WINAPI* funcFreeGrpApi)();\r
119 extern funcLoadGrpApi LoadGrpApi;\r
120 extern funcFreeGrpApi FreeGrpApi;\r
121 \r
122 #ifdef __cplusplus\r
123 }; // extern "C" \r
124 #endif\r
125 \r
126 #endif\r
|