Hi guys quick help with some code conversion if you please, developerfusion can't quite handle it.
[StructLayout(LayoutKind.Explicit)]
public struct Color32
{
[FieldOffset(3)]
public byte Alpha;
[FieldOffset(0)]
public int ARGB;
[FieldOffset(0)]
public byte Blue;
[FieldOffset(1)]
public byte Green;
[FieldOffset(2)]
public byte Red;
public Color32(IntPtr pSourcePixel)
{
this = (Quantizer.Color32)Marshal.PtrToStructure(pSourcePixel, typeof(Quantizer.Color32));
}
public Color Color
{
get
{
return Color.FromArgb(this.Alpha, this.Red, this.Green, this.Blue);
}
}
}
It's the
public Color32
bit I can't fathom.
Also
pSourcePixel = (IntPtr)(((long)pSourcePixel) + this._pixelSize);
Where localvariable
pSourcePixel
is type IntPtr is giving me grief, I'm getting the error:
Value of type 'Long' cannot be converted to 'System.IntPtr'
I'm messing about with a conversion of the OctreeQuantizer I'll understand what is going on inside it more if it's in VB (I know..... I'm trying to learn C# :sigh: )
Many thanks.
***********Update*******************************
Sorry, should have been more specific with the question.
' Methods
Public Sub New(ByVal pSourcePixel As IntPtr)
Me = DirectCast(Marshal.PtrToStructure(pSourcePixel, GetType(Quantizer.Color32)), Quantizer.Color32)
End Sub
Cannot be used since, 'Me' cannot be the target of an assignment.