/*static*/ PyObject *
ColorTableAttributes_GetColorTables(PyObject *self, PyObject *args)
{
    ColorTableAttributesObject *obj = (ColorTableAttributesObject *)self;
    int index;
    if(!PyArg_ParseTuple(args, "i", &index))
        return NULL;
    if(index < 0 || (size_t)index >= obj->data->GetColorTables().size())
    {
        char msg[400] = {'\0'};
        if(obj->data->GetColorTables().size() == 0)
            SNPRINTF(msg, 400, "In ColorTableAttributes::GetColorTables : The index %d is invalid because colorTables is empty.", index);
        else
            SNPRINTF(msg, 400, "In ColorTableAttributes::GetColorTables : The index %d is invalid. Use index values in: [0, %ld).",  index, obj->data->GetColorTables().size());
        PyErr_SetString(PyExc_IndexError, msg);
        return NULL;
    }

    // Since the new object will point to data owned by the this object,
    // we need to increment the reference count.
    Py_INCREF(self);

    PyObject *retval = PyColorControlPointList_Wrap(&obj->data->GetColorTables(index));
    // Set the object's parent so the reference to the parent can be decref'd
    // when the child goes out of scope.
    PyColorControlPointList_SetParent(retval, self);

    return retval;
}
Пример #2
0
/*static*/ PyObject *
MultiCurveAttributes_GetDefaultPalette(PyObject *self, PyObject *args)
{
    MultiCurveAttributesObject *obj = (MultiCurveAttributesObject *)self;
    // Since the new object will point to data owned by this object,
    // we need to increment the reference count.
    Py_INCREF(self);

    PyObject *retval = PyColorControlPointList_Wrap(&obj->data->GetDefaultPalette());
    // Set the object's parent so the reference to the parent can be decref'd
    // when the child goes out of scope.
    PyColorControlPointList_SetParent(retval, self);

    return retval;
}