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
4cc17089 1Attribute VB_Name = "GrpApi"\r
2Option Explicit\r
3\r
4' ShadowFlare GRP Library. (c) ShadowFlare Software 2002-2006\r
5\r
6' Any comments or suggestions are accepted at blakflare@hotmail.com (ShadowFlare)\r
7\r
8Type GRPHEADER\r
9 nFrames As Integer\r
10 wMaxWidth As Integer\r
11 wMaxHeight As Integer\r
12End Type\r
13\r
14Public Const HORIZONTAL_FLIP As Long = &H1& ' Flips the graphic horizontally\r
15Public Const VERTICAL_FLIP As Long = &H2& ' Flips the graphic vertically\r
16Public Const SHADOW_COLOR As Long = &H4& ' Causes the graphic to be drawn in one color\r
17 ' Second byte of flags is the red component of\r
18 ' the shadow's color, third byte is green,\r
19 ' fourth byte is blue; like this:\r
20 ' 'SHADOW_COLOR Or &HBBGGRR00'\r
21Public Const ALPHA_BLEND As Long = &H8& ' Blends the graphic with what it is being drawn over.\r
22 ' The dwAlpha parameter will only be used when this\r
23 ' flag is specified. dwAlpha is an RGB value\r
24 ' (&HBBGGRR).\r
25 ' Note: Because of the extra calculations required,\r
26 ' alpha blended graphics take longer to draw\r
4d7b76a0 27Public Const USE_INDEX As Long = &H10& ' Only valid when used with a custom SetPixel function.\r
28 ' This flag cannot be used in combination with\r
29 ' ALPHA_BLEND or SHADOW_COLOR\r
30 ' When this flag is used, the index to a color in the\r
31 ' palette will be passed to your custom SetPixel\r
32 ' function instead of the actual color.\r
4cc17089 33\r
34' Palette is an array of 256 Longs. Pass the first element of the array to these functions,\r
35' rather than the actual array\r
36' For LoadPalette and LoadGrp, lpFileName may be a file in an open mpq archive\r
37' or a file not in an archive\r
38Declare Function LoadPalette Lib "Grpapi.dll" (ByVal lpFileName As String, dwPalette As Long) As Boolean\r
39Declare Function LoadGrp Lib "Grpapi.dll" (ByVal lpFileName As String) As Long\r
40Declare Function DestroyGrp Lib "Grpapi.dll" (ByVal hGrp As Long) As Boolean\r
41Declare Function DrawGrp Lib "Grpapi.dll" (ByVal hGrp As Long, ByVal hdcDest As Long, ByVal nXDest As Long, ByVal nYDest As Long, ByVal nFrame As Integer, dwPalette As Long, ByVal dwFlags As Long, ByVal dwAlpha As Long) As Boolean\r
42Declare Function GetGrpInfo Lib "Grpapi.dll" (ByVal hGrp As Long, GrpInfo As GRPHEADER) As Boolean\r
43\r
44Declare Function GetDC Lib "User32.dll" (ByVal hWnd As Long) As Long\r
45Declare Function ReleaseDC Lib "User32.dll" (ByVal hWnd As Long, ByVal hDC As Long) As Long\r
46\r
4d7b76a0 47' An array of the raw image data to encode should be passed to lpImageData. To do this,\r
48' pass the first byte of the array to the function. The size of the buffer containing\r
49' the data should be nFrames * wMaxWidth * wMaxHeight * 2\r
50' and the values should be arranged row by row of the frame, with the top row first.\r
51' After all the rows of a frame have been put into the buffer, the rows of the next frame\r
52' go after it. For transparent pixels, they should be set to -1. All other pixels should\r
53' have the high order byte set to zero, meaning that they should not be negative and the\r
54' values should not exceed 255 (&HFF). The values used for the colors are indexes into the\r
55' color palette.\r
56' Pass True to bNoCompress if you need an uncompressed GRP.\r
57' Pass a variable to nGrpSize to receive the size in bytes of the resulting encoded GRP.\r
58' The return value of this function is actually a pointer to the GRP data. This is what your\r
59' program should save to a file. The size of this buffer is the value received by nGrpSize.\r
60' When your program is done with the returned buffer, it should call DestroyGrp on the\r
61' buffer that was returned by this function to free up the memory from it.\r
62' The pointer returned by this function can also be directly used by DrawGrp or GetGrpInfo.\r
63Declare Function CreateGrp Lib "Grpapi.dll" (ByRef lpImageData As Integer, ByVal nFrames As Integer, ByVal wMaxWidth As Integer, ByVal wMaxHeight As Integer, ByVal bNoCompress As Boolean, ByRef nGrpSize As Long) As Long\r
64\r
65' Use this function to make a copy the memory at the location returned by CreateGrp.\r
66' Pass the address ByVal to Source. Pass either a byte array or a string to Destination.\r
67' The size of the array or string must be at least the size of the GRP data before\r
68' attempting to copy it to the array or string.\r
69' To pass a byte array, pass the first byte of the array ByRef. To pass a string,\r
70' pass the string ByVal.\r
71Declare Sub CopyMemory Lib "Kernel32.dll" _\r
72 Alias "RtlMoveMemory" ( _\r
73 ByRef Destination As Any, _\r
74 ByRef Source As Any, _\r
75 ByVal Length As Long)\r
76\r
4cc17089 77' Call these to have DrawGrp use custom functions for reading and drawing pixels\r
78' so that you can have it read from and write to a buffer, for example.\r
79' Requires Visual Basic 5 or higher\r
80'\r
81' The functions must be in this form:\r
82'\r
83' Function GetPixelProc (ByRef value As any_type, X As Long, Y As Long) As Long\r
84' Sub SetPixelProc (ByRef value As any_type, X As Long, Y As Long, clrColor As Long)\r
85'\r
86' or\r
87'\r
88' Function GetPixelProc (ByVal value As any_type, X As Long, Y As Long) As Long\r
89' Sub SetPixelProc (ByVal value As any_type, X As Long, Y As Long, clrColor As Long)\r
90'\r
91' Replace "any_type" with whatever type you want. This parameter gets the data from\r
92' DrawGrp's hdcDest parameter. You can either pass a number to DrawGrp and use the\r
93' "ByVal" versions of the above functions, or you can use AddressOf to get a reference\r
94' to a variable and use it for the "ByRef" versions.\r
95' GetPixelProc should return an RGB color value.\r
96Declare Sub SetFunctionGetPixel Lib "Grpapi.dll" (lpGetPixelProc As Long)\r
97Declare Sub SetFunctionSetPixel Lib "Grpapi.dll" (lpSetPixelProc As Long)\r
98\r
99' Call this to make a different Storm.dll-compatible MPQ library be used (like SFMPQ).\r
100Declare Function SetMpqDll Lib "Grpapi.dll" (ByVal lpDllFileName As String) As Boolean\r
101\r
102' These no longer need to be called\r
103Declare Function LoadGrpApi Lib "Grpapi.dll" () As Boolean\r
104Declare Sub FreeGrpApi Lib "Grpapi.dll" ()\r