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




CommitLineData
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#ifndef GRPAPI_STATIC
15
16#ifdef GRPAPI_EXPORTS
17#define GRPAPI __declspec(dllexport)
18#else
19#define GRPAPI __declspec(dllimport)
20#endif
21
22#else
23#define GRPAPI
24#endif
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30typedef struct {
31 WORD nFrames;
32 WORD wMaxWidth;
33 WORD wMaxHeight;
34} GRPHEADER;
35
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.
57
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
61BOOL GRPAPI WINAPI LoadPalette(LPCSTR lpFileName, DWORD *dwPaletteBuffer);
62HANDLE GRPAPI WINAPI LoadGrp(LPCSTR lpFileName);
63BOOL GRPAPI WINAPI DestroyGrp(HANDLE hGrp);
64BOOL GRPAPI WINAPI DrawGrp(HANDLE hGrp, HDC hdcDest, int nXDest, int nYDest, WORD nFrame, DWORD *dwPalette, DWORD dwFlags, DWORD dwAlpha);
65BOOL GRPAPI WINAPI GetGrpInfo(HANDLE hGrp, GRPHEADER *GrpInfo);
66BOOL GRPAPI WINAPI GetGrpFrameInfo(HANDLE hGrp, WORD nFrame, DWORD *nLeft, DWORD *nTop, DWORD *nWidth, DWORD *nHeight);
67
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.
83HANDLE GRPAPI WINAPI CreateGrp(signed short *lpImageData, WORD nFrames, WORD wMaxWidth, WORD wMaxHeight, BOOL bNoCompress, DWORD *nGrpSize);
84
85typedef 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);
92typedef 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);
100
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.
103void GRPAPI WINAPI SetFunctionGetPixel(GETPIXELPROC lpGetPixelProc); // Only used with ALPHA_BLEND
104void GRPAPI WINAPI SetFunctionSetPixel(SETPIXELPROC lpSetPixelProc);
105
106// Call this to make a different Storm.dll-compatible MPQ library be used (like SFMPQ).
107BOOL GRPAPI WINAPI SetMpqDll(LPCSTR lpDllFileName);
108
109// These no longer need to be called
110BOOL GRPAPI WINAPI LoadGrpApi();
111void GRPAPI WINAPI FreeGrpApi();
112
113#ifdef __cplusplus
114}; // extern "C"
115#endif
116
117#endif