ActiveMIL中object调用与数组的解决方法

来源:互联网 发布:刮骨疗毒 知乎 编辑:程序博客网 时间:2024/04/29 08:43

ACtiveMIL引入后要获得某一点的像素需要使用Get方法

原型:
public virtual new void Get ( System.Object userArray , Matrox.ActiveMIL.ImFormatConstants format , Matrox.ActiveMIL.ImBandConstants band , System.Int32 offsetX , System.Int32 offsetY , System.Int32 sizeX , System.Int32 sizeY )

userArray只能使用object类型,实际上是一个数组,若要访问数组需要将object 变量安如下声明:
     object obuf=new byte[SizeX,SizeY];

然后在用一个临时的数组变量访问
    Img.Get(ref obuf,ImFormatConstants.imPlanar,ImBandConstants.imGreen,
                    0,0,imgTemp.SizeX,imgTemp.SizeY);
    byte[,] buf=(byte[,])obuf;
    Text=buf[100,100].ToString();

不知道谁有更好的方法啊