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