当前位置: 首页>>代码示例>>C++>>正文


C++ GDALColorTable::CreateColorRamp方法代码示例

本文整理汇总了C++中GDALColorTable::CreateColorRamp方法的典型用法代码示例。如果您正苦于以下问题:C++ GDALColorTable::CreateColorRamp方法的具体用法?C++ GDALColorTable::CreateColorRamp怎么用?C++ GDALColorTable::CreateColorRamp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GDALColorTable的用法示例。


在下文中一共展示了GDALColorTable::CreateColorRamp方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Init_ILImage


//.........这里部分代码省略.........
    // 

    if ((image.pagesize.c==1)&&(node=CPLGetXMLNode(defimage,"Palette"))) {
         int entries=static_cast<int>(getXMLNum(node,"Size",255));
         GDALPaletteInterp eInterp=GPI_RGB;
         // A flag to convert from HLS to HSV
         bool is_hsv=false;
         CPLString pModel=CPLGetXMLValue(node,"Model","RGB");
         if (!pModel.empty()) {
             if (pModel.find("HSV")!=string::npos) {
                 eInterp=GPI_HLS;
                 is_hsv=true;
             } else if (pModel.find("HLS")!=string::npos)
                 eInterp=GPI_HLS;
             else if (pModel.find("CMYK")!=string::npos) eInterp=GPI_CMYK;
             // Can it do LuminanceAlpha?
             else if (pModel.find("L")!=string::npos) eInterp=GPI_Gray;
             // RGBA and RGB are the same
             else if (pModel.find("RGB")!=string::npos) eInterp=GPI_RGB;
             else {
                 CPLError(CE_Failure, CPLE_AppDefined,
                     "GDAL MRF: Palette Model %s is unknown, use RGB,RGBA,HSV,HLS,CMYK or L",
                     pModel.c_str());
                 return CE_Failure;
             }
         }

         if ((entries>0)&&(entries<257)) {
             int start_idx, end_idx;
             GDALColorEntry ce_start={0,0,0,255},ce_end={0,0,0,255};

             // Create it and initialize it to nothing
             GDALColorTable *poColorTable = new GDALColorTable(eInterp);
             poColorTable->CreateColorRamp(0,&ce_start,entries-1,&ce_end);
             // Read the values
             CPLXMLNode *p=CPLGetXMLNode(node,"Entry");
             if (p) {
                 // Initialize the first entry, just in case
                 ce_start=GetXMLColorEntry(p);
                 if (is_hsv) ce_start=HSVSwap(ce_start);
                 start_idx=static_cast<int>(getXMLNum(p,"idx",0));
                 if (start_idx<0) {
                    CPLError(CE_Failure, CPLE_AppDefined,
                        "GDAL MRF: Palette index %d not allowed",start_idx);
                    delete poColorTable;
                    return CE_Failure;
                 }
                 poColorTable->SetColorEntry(start_idx,&ce_start);
                 while (NULL!=(p=SearchXMLSiblings(p,"Entry"))) {
                     // For every entry, create a ramp
                     ce_end=GetXMLColorEntry(p);
                     if (is_hsv) ce_end=HSVSwap(ce_end);
                     end_idx=static_cast<int>(getXMLNum(p,"idx",start_idx+1));
                     if ((end_idx<=start_idx)||(start_idx>=entries)) {
                         CPLError(CE_Failure, CPLE_AppDefined,
                             "GDAL MRF: Index Error at index %d",end_idx);
                         delete poColorTable;
                         return CE_Failure;
                     }
                     poColorTable->CreateColorRamp(start_idx,&ce_start,
                                                   end_idx,&ce_end);
                     ce_start=ce_end;
                     start_idx=end_idx;
                 }
             }
开发者ID:nasajpl,项目名称:tiledwms,代码行数:66,代码来源:marfa_dataset.cpp


注:本文中的GDALColorTable::CreateColorRamp方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。