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