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