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