首页 > 其他 > 详细

C#数据类型与对应ArcObject栅格数据类型

时间:2014-01-22 07:38:38      阅读:591      评论:0      收藏:0      [点我收藏+]

  数据类型匹配是写通用ArcObject程序必须考虑的事情。为了以后方便,整理了一下C#数据类型和与之对应的ArcObject栅格数据类型。ArcObject栅格数据机类型可参照ESRI.ArcGIS.Geodatabase.rstPixelType.

bubuko.com,布布扣

  顺便给出一个转换函数

bubuko.com,布布扣
/// <summary>
/// Convert the csharp value to the ArcObject pixel value.
/// </summary>
/// <param name="csharpValue">Cshapr value</param>
/// <param name="pixelValueType">The pixel type of ouput value</param>
/// <param name="pixelValue">Output pixel value</param>
/// <returns>A value indicating whether the convention is successful</returns>
public static bool CSharpValue2PixelValue(object csharpValue, rstPixelType pixelValueType, out object pixelValue)
{
    try
    {
        switch (pixelValueType)
        {
            case rstPixelType.PT_UCHAR:
                pixelValue = (object)Convert.ToByte(csharpValue);
                return true;
            case rstPixelType.PT_CHAR:
                pixelValue = (object)Convert.ToSByte(csharpValue);
                return true;
            case rstPixelType.PT_SHORT:
                pixelValue = (object)Convert.ToInt16(csharpValue);
                return true;
            case rstPixelType.PT_USHORT:
                pixelValue = (object)Convert.ToUInt16(csharpValue);
                return true;
            case rstPixelType.PT_CLONG:
                pixelValue = (object)Convert.ToInt32(csharpValue);
                return true;
            case rstPixelType.PT_ULONG:
                pixelValue = (object)Convert.ToUInt32(csharpValue);
                return true;
            case rstPixelType.PT_FLOAT:
                pixelValue = (object)Convert.ToSingle(csharpValue);
                return true;
            case rstPixelType.PT_DOUBLE:
                pixelValue = (object)Convert.ToDouble(csharpValue);
                return true;
            default:
                pixelValue = null;
                return false;
        }
    }
    catch (Exception)
    {
        pixelValue = null;
        return false;
    }
}
bubuko.com,布布扣

C#数据类型与对应ArcObject栅格数据类型

原文:http://www.cnblogs.com/PaoYu/p/3529155.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!