[pywin32-checkins] pywin32/Pythonwin win32bitmap.cpp,1.2,1.3
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Mark H. <mha...@us...> - 2005-12-06 21:53:24
|
Update of /cvsroot/pywin32/pywin32/Pythonwin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11008 Modified Files: win32bitmap.cpp Log Message: Allow GetBitmapBits to return a string or a list of ints (strings being *much* faster). Index: win32bitmap.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32bitmap.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** win32bitmap.cpp 26 Jun 2005 12:59:33 -0000 1.2 --- win32bitmap.cpp 6 Dec 2005 21:53:16 -0000 1.3 *************** *** 459,466 **** } ! // @pymethod tuple|PyBitmap|GetBitmapBits|Returns the bitmap bits. static PyObject *ui_get_bitmap_bits( PyObject *self, PyObject *args ) { ! if (!PyArg_ParseTuple(args,"")) return NULL; CBitmap *pBitmap = ui_bitmap::GetBitmap( self ); --- 459,469 ---- } ! // @pymethod tuple/string|PyBitmap|GetBitmapBits|Returns the bitmap bits. static PyObject *ui_get_bitmap_bits( PyObject *self, PyObject *args ) { ! // @pyparm int|asString|0|If False, the result is a tuple of ! // integers, if True, the result is a Python string ! int asString = 0; ! if (!PyArg_ParseTuple(args,"|i", &asString)) return NULL; CBitmap *pBitmap = ui_bitmap::GetBitmap( self ); *************** *** 478,484 **** RETURN_ERR("GetBitmapBits failed on bitmap"); } ! PyObject* rc = PyTuple_New(cnt); ! for (UINT i = 0; i < cnt; i++) { ! PyTuple_SetItem(rc, i, Py_BuildValue("i", (int)bits[i])); } free(bits); --- 481,492 ---- RETURN_ERR("GetBitmapBits failed on bitmap"); } ! PyObject* rc; ! if (asString) { ! rc = PyString_FromStringAndSize(bits, cnt); ! } else { ! rc = PyTuple_New(cnt); ! for (UINT i = 0; i < cnt; i++) { ! PyTuple_SetItem(rc, i, PyInt_FromLong((long)bits[i])); ! } } free(bits); |