Skip to content

Commit

Permalink
Merge pull request #44 from Hoikas/pymipmap
Browse files Browse the repository at this point in the history
Expose plMipmap::CompressImage to Python
  • Loading branch information
zrax committed Jul 12, 2014
2 parents afc9e96 + 5c33825 commit 58aba41
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions Python/PRP/Surface/pyMipmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,26 @@ static PyObject* pyMipmap_DecompressImage(pyMipmap* self, PyObject* args) {
return img;
}

static PyObject* pyMipmap_CompressImage(pyMipmap* self, PyObject* args) {
int level, dataSize;
char* data;
if (!PyArg_ParseTuple(args, "is#", &level, &data, &dataSize)) {
PyErr_SetString(PyExc_TypeError, "CompressImage expects an int and a binary string");
return NULL;
}
try {
self->fThis->CompressImage(level, data, dataSize);
} catch (hsBadParamException& ex) {
PyErr_SetString(PyExc_RuntimeError, ex.what());
return NULL;
} catch (hsNotImplementedException& ex) {
PyErr_SetString(PyExc_NotImplementedError, ex.what());
return NULL;
}
Py_INCREF(Py_None);
return Py_None;
}

static PyObject* pyMipmap_getWidth(pyMipmap* self, void*) {
return PyInt_FromLong(self->fThis->getWidth());
}
Expand Down Expand Up @@ -319,6 +339,9 @@ static PyMethodDef pyMipmap_Methods[] = {
{ "DecompressImage", (PyCFunction)pyMipmap_DecompressImage, METH_VARARGS,
"Params: level\n"
"Deompresses the specified mip level and returns the uncompressed RGBA buffer" },
{ "CompressImage", (PyCFunction)pyMipmap_CompressImage, METH_VARARGS,
"Params: level, data\n"
"Compresses the specified mip level" },
{ NULL, NULL, 0, NULL }
};

Expand Down

0 comments on commit 58aba41

Please sign in to comment.