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




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