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




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