Esempio n. 1
0
 int getRasterLayerColormapValues(Layer* pLayer, uint32_t* pColormap)
 {
    RasterLayer* pRaster = dynamic_cast<RasterLayer*>(pLayer);
    if (pRaster == NULL || pColormap == NULL)
    {
       setLastError(SIMPLE_BAD_PARAMS);
       return 1;
    }
    const std::vector<ColorType>& colormap = pRaster->getColorMap().getTable();
    if (colormap.size() != 256)
    {
       setLastError(SIMPLE_NO_MEM);
       return 1;
    }
    for (size_t idx = 0; idx < colormap.size(); ++idx)
    {
       pColormap[idx] = encodeColor(colormap[idx]);
    }
    setLastError(SIMPLE_NO_ERROR);
    return 0;
 }
Esempio n. 2
0
 uint32_t getRasterLayerColormapName(Layer* pLayer, char* pName, uint32_t nameSize)
 {
    RasterLayer* pRaster = dynamic_cast<RasterLayer*>(pLayer);
    if (pRaster == NULL)
    {
       setLastError(SIMPLE_BAD_PARAMS);
       return 0;
    }
    std::string name = pRaster->getColorMap().getName();
    if (nameSize == 0)
    {
       return name.size() + 1;
    }
    else if (name.size() > nameSize - 1) // extra char for the null
    {
       setLastError(SIMPLE_BUFFER_SIZE);
       return 0;
    }
    memcpy(pName, name.c_str(), name.size());
    pName[name.size()] = '\0';
    setLastError(SIMPLE_NO_ERROR);
    return name.size();
 }