I'm trying to convert the following two structures from their c++ versions to their vb.net versions. I cannot be sure which is the problem because both must be passed at the same time. The error I am getting is thrown by the object and indicates "Invalid structure size specified". I can cause this error on other objects when I either don't set the dwSize variable, leave off a parameter or change the parameter type incorrectly. Note that the dwSize parameter is supposed to contain the size of each structure. I'm successfully calculating that for my other structures and I'm using the same method on these and the results appear correct, so I do not believe the problem is found there. The object uses a lot of structures and the rest of them are working. These two are the only ones with a) an unsigned character pointer b) an unsigned long array and c) doubles.
C++ versions:
Expand|Select|Wrap|Line Numbers
- //
- // Texture data
- //
- typedef struct tagFACE_TEXTUREDATA
- {
- DWORD dwSize;
- LONG nTextureType;
- LONG nWidth;
- LONG nHeight;
- LONG nBitCount;
- DWORD dwPalette[256];
- BYTE* pImageData;
- CHAR szImageFile[260];
- LONG nColorTranslation;
- DWORD dwColor;
- LONG nTextureSize;
- LONG nTextureScaling;
- BYTE* pMaskData;
- CHAR szMaskFile[260];
- }
- FACE_TEXTUREDATA;
- //
- // Texture properties
- //
- typedef struct tagFACE_TEXTUREPROP
- {
- DWORD dwSize;
- DOUBLE eGloss;
- DOUBLE eContrast;
- BOOL bRepeat;
- DOUBLE eDropX;
- DOUBLE eDropY;
- DOUBLE ePlacingPointX;
- DOUBLE ePlacingPointY;
- DOUBLE eWidth;
- DOUBLE eHeight;
- LONG nTransformation;
- }
- FACE_TEXTUREPROP;
Expand|Select|Wrap|Line Numbers
- ' Texture data
- Public Structure FACE_TEXTUREDATA
- <MarshalAs(UnmanagedType.U4)> Public dwSize As UInteger
- <MarshalAs(UnmanagedType.I4)> Public nTextureType As Integer
- <MarshalAs(UnmanagedType.I4)> Public nWidth As Integer
- <MarshalAs(UnmanagedType.I4)> Public nHeight As Integer
- <MarshalAs(UnmanagedType.I4)> Public nBitCount As Integer
- <MarshalAs(UnmanagedType.ByValArray, ArraySubType:=UnmanagedType.U4, SizeConst:=256)> Public dwPalette() As UInteger
- <MarshalAs(UnmanagedType.I1)> Public pImageData As Byte
- <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=260)> Public szImageFile As String
- <MarshalAs(UnmanagedType.I4)> Public nColorTranslation As Integer
- <MarshalAs(UnmanagedType.U4)> Public dwColor As UInteger
- <MarshalAs(UnmanagedType.I4)> Public nTextureSize As Integer
- <MarshalAs(UnmanagedType.I4)> Public nTextureScaling As Integer
- <MarshalAs(UnmanagedType.I1)> Public pMaskData As Byte
- <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=260)> Public szMaskFile As String
- End Structure
- ' Texture properties
- Public Structure FACE_TEXTUREPROP
- <MarshalAs(UnmanagedType.U4)> Public dwSize As UInteger
- <MarshalAs(UnmanagedType.R8)> Public eGloss As Double
- <MarshalAs(UnmanagedType.R8)> Public eContrast As Double
- <MarshalAs(UnmanagedType.I4)> Public bRepeat As Integer
- <MarshalAs(UnmanagedType.R8)> Public eDropX As Double
- <MarshalAs(UnmanagedType.R8)> Public eDropY As Double
- <MarshalAs(UnmanagedType.R8)> Public ePlacingPointX As Double
- <MarshalAs(UnmanagedType.R8)> Public ePlacingPointY As Double
- <MarshalAs(UnmanagedType.R8)> Public eWidth As Double
- <MarshalAs(UnmanagedType.R8)> Public eHeight As Double
- <MarshalAs(UnmanagedType.I4)> Public nTransformation As Integer
- End Structure
Any help would be appreciated. I've pretty much exhasted my knowledge of this stuff a while ago. That said, I am very close to the finish line and if I can solve this, I believe that will be the last thing I need to make this work.