Commit | Line | Data |
14362b19 |
1 | /*\r |
2 | \r |
ecca31ff |
3 | ShadowFlare GRP Library. (c) ShadowFlare Software 2002-2006\r |
14362b19 |
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 |
8531f378 |
42 | // This can be accomplished by using the left shift\r |
43 | // operator like this: SHADOW_COLOR|(color << 8)\r |
14362b19 |
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 |
8531f378 |
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 |
14362b19 |
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 |
6ae30656 |
65 | BOOL GRPAPI WINAPI GetGrpFrameInfo(HANDLE hGrp, WORD nFrame, DWORD *nLeft, DWORD *nTop, DWORD *nWidth, DWORD *nHeight);\r |
14362b19 |
66 | \r |
4d7b76a0 |
67 | // A pointer to the raw image data to encode should be passed to lpImageData. The size of\r |
68 | // the buffer containing the data should be nFrames * wMaxWidth * wMaxHeight * sizeof(short)\r |
69 | // and the values should be arranged row by row of the frame, with the top row first.\r |
70 | // After all the rows of a frame have been put into the buffer, the rows of the next frame\r |
71 | // go after it. For transparent pixels, they should be set to -1. All other pixels should\r |
72 | // have the high order byte set to zero, meaning that they should not be negative and the\r |
73 | // values should not exceed 255 (0xFF). The values used for the colors are indexes into the\r |
74 | // color palette.\r |
75 | // Pass TRUE to bNoCompress if you need an uncompressed GRP.\r |
76 | // Pass a pointer to a DWORD value to nGrpSize to receive the size in bytes of the resulting encoded GRP.\r |
77 | // The return value of this function is actually a pointer to the GRP data. This is what your\r |
78 | // program should save to a file. The size of this buffer is the value received by nGrpSize.\r |
79 | // When your program is done with the returned buffer, it should call DestroyGrp on the\r |
80 | // buffer that was returned by this function to free up the memory from it.\r |
81 | // The pointer returned by this function can also be directly used by DrawGrp or GetGrpInfo.\r |
03269fee |
82 | HANDLE GRPAPI WINAPI CreateGrp(signed short *lpImageData, WORD nFrames, WORD wMaxWidth, WORD wMaxHeight, BOOL bNoCompress, DWORD *nGrpSize);\r |
c483a082 |
83 | \r |
ecca31ff |
84 | typedef COLORREF (WINAPI* GETPIXELPROC)(\r |
85 | HDC hDC, // same value as hdcDest from DrawGrp,\r |
86 | // does not need to be used as an HDC,\r |
87 | // can be used for any other type of pointer\r |
88 | int X, // x-coordinate of pixel\r |
89 | int Y // y-coordinate of pixel\r |
90 | );\r |
91 | typedef void (WINAPI* SETPIXELPROC)(\r |
92 | HDC hDC, // same value as hdcDest from DrawGrp,\r |
93 | // does not need to be used as an HDC,\r |
94 | // can be used for any other type of pointer\r |
95 | int X, // x-coordinate of pixel\r |
96 | int Y, // y-coordinate of pixel\r |
97 | COLORREF clrColor // new pixel color\r |
98 | );\r |
99 | \r |
100 | // Call these to have DrawGrp use custom functions for reading and drawing pixels\r |
101 | // so that you can have it read from and write to a buffer, for example.\r |
ff024783 |
102 | void GRPAPI WINAPI SetFunctionGetPixel(GETPIXELPROC lpGetPixelProc); // Only used with ALPHA_BLEND\r |
ecca31ff |
103 | void GRPAPI WINAPI SetFunctionSetPixel(SETPIXELPROC lpSetPixelProc);\r |
104 | \r |
105 | // Call this to make a different Storm.dll-compatible MPQ library be used (like SFMPQ).\r |
106 | BOOL GRPAPI WINAPI SetMpqDll(LPCSTR lpDllFileName);\r |
107 | \r |
14362b19 |
108 | // These no longer need to be called\r |
109 | BOOL GRPAPI WINAPI LoadGrpApi();\r |
110 | void GRPAPI WINAPI FreeGrpApi();\r |
111 | \r |
112 | #ifdef __cplusplus\r |
113 | }; // extern "C" \r |
114 | #endif\r |
115 | \r |
116 | #endif\r |