日期:2014-05-18  浏览次数:20889 次

编译错误,不知道是强类型问题还是指针问题
错误信息:运算符“.”无法应用于“Color32*”类型的操作数

相关代码:
  internal unsafe void AddColor(Color32 *pixel)
  {
  if (this._prefixColor == pixel.ARGB)
  {
  if (this._prefixNode == null)
  {
  this._prefixColor = pixel.ARGB;
  this._rootNode.AddColor(pixel, 0, this);
  }
  else
  {
  this._prefixNode.Increment(pixel);
  }
  }
  else
  {
  this._prefixColor = pixel.ARGB;
  this._rootNode.AddColor(pixel, 0, this);
  }
  }


[StructLayout(LayoutKind.Explicit)]
  internal struct Color32
  {
  [FieldOffset(3)]
  internal byte Alpha;
  [FieldOffset(0)]
  internal int ARGB;
  [FieldOffset(0)]
  internal byte Blue;
  [FieldOffset(1)]
  internal byte Green;
  [FieldOffset(2)]
  internal byte Red;

  internal Color32(int c)
  {
  this.Alpha = 0;
  this.Red = 0;
  this.Green = 0;
  this.Blue = 0;
  this.ARGB = c;
  }

  internal Color32(byte a, byte r, byte g, byte b)
  {
  this.ARGB = 0;
  this.Alpha = a;
  this.Red = r;
  this.Green = g;
  this.Blue = b;
  }

  internal System.Drawing.Color Color
  {
  get
  {
  return System.Drawing.Color.FromArgb(this.ARGB);
  }
  }
  }

------解决方案--------------------
internal unsafe void AddColor(Color32 *pixel) 

if (this._prefixColor == pixel.ARGB) 

if (this._prefixNode == null) 

this._prefixColor = pixel.ARGB; 
this._rootNode.AddColor(pixel, 0, this); 

else 

this._prefixNode.Increment(pixel); 


else 

this._prefixColor = pixel.ARGB; 
this._rootNode.AddColor(pixel, 0, this); 




改成
internal unsafe void AddColor(Color32 *pixel) 

if (this._prefixColor == pixel->ARGB) 

if (this._prefixNode == null) 

this._prefixColor = pixel->ARGB; 
this._rootNode.AddColor(pixel, 0, this); 

else 

this._prefixNode.Increment(pixel); 


else 

this._prefixColor = pixel->ARGB; 
this._rootNode.AddColor(pixel, 0, this);