diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 2001-01-30 09:57:13 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 2001-01-30 09:57:13 (GMT) |
commit | 87eb4f8bb35be113017fcb8e703677a0a056234d (patch) | |
tree | 7d819736135137b01371b59ebf714491848a4c92 /Mac/Modules/qd/Qdmodule.c | |
parent | 69c327988a43bf3b4de5394af5193c449cbcde14 (diff) | |
download | cpython-87eb4f8bb35be113017fcb8e703677a0a056234d.zip cpython-87eb4f8bb35be113017fcb8e703677a0a056234d.tar.gz cpython-87eb4f8bb35be113017fcb8e703677a0a056234d.tar.bz2 |
New internal function BMObj_NewCopied() which copies the BitMap. Used to get the screenBits bitmap.
Diffstat (limited to 'Mac/Modules/qd/Qdmodule.c')
-rw-r--r-- | Mac/Modules/qd/Qdmodule.c | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/Mac/Modules/qd/Qdmodule.c b/Mac/Modules/qd/Qdmodule.c index 7c9d49b..34476d4 100644 --- a/Mac/Modules/qd/Qdmodule.c +++ b/Mac/Modules/qd/Qdmodule.c @@ -11,7 +11,7 @@ #include <QuickDraw.h> #if !ACCESSOR_CALLS_ARE_FUNCTIONS -#define GetPortBitMapForCopyBits(port) (((GrafPort)(port))->portBits) +#define GetPortBitMapForCopyBits(port) ((const struct BitMap *)&((GrafPort *)(port))->portBits) #define GetPortPixMap(port) (((CGrafPtr)(port))->portPixMap) #define GetPortBounds(port, bounds) (*(bounds) = (port)->portRect, (bounds)) #define GetPortForeColor(port, color) (*(color) = (port)->rgbFgColor, (color)) @@ -79,6 +79,8 @@ #define QDIsPortBuffered(port) 0 #endif /* !TARGET_API_MAC_CARBON */ +staticforward PyObject *BMObj_NewCopied(BitMapPtr); + /* ** Parse/generate RGB records */ @@ -115,8 +117,6 @@ PyObject *QdFI_New(itself) itself->widMax, itself->leading); } - - static PyObject *Qd_Error; /* ---------------------- Object type GrafPort ---------------------- */ @@ -584,7 +584,7 @@ static PyObject *QDGA_getattr(self, name) if ( strcmp(name, "screenBits") == 0 ) { BitMap rv; GetQDGlobalsScreenBits(&rv); - return BMObj_New(&rv); + return BMObj_NewCopied(&rv); } if ( strcmp(name, "thePort") == 0 ) return GrafObj_New(GetQDGlobalsThePort()); @@ -4521,7 +4521,7 @@ static PyObject *Qd_GetQDGlobalsScreenBits(_self, _args) return NULL; GetQDGlobalsScreenBits(&screenBits); _res = Py_BuildValue("O&", - BMObj_New, &screenBits); + BMObj_NewCopied, &screenBits); return _res; } @@ -6162,6 +6162,24 @@ static PyMethodDef Qd_methods[] = { +/* Like BMObj_New, but the original bitmap data structure is copied (and +** released when the object is released) +*/ +PyObject *BMObj_NewCopied(itself) + BitMapPtr itself; +{ + BitMapObject *it; + BitMapPtr itself_copy; + + if ((itself_copy=(BitMapPtr)malloc(sizeof(BitMap))) == NULL) + return PyErr_NoMemory(); + *itself_copy = *itself; + it = (BitMapObject *)BMObj_New(itself_copy); + it->referred_bitmap = itself_copy; + return (PyObject *)it; +} + + void initQd() { |