Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
e9a9f926
Commit
e9a9f926
authored
Mar 03, 2000
by
Jack Jansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added methods getdata() and putdata() to obtain the data in a bitmap.
parent
f3130f45
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
0 deletions
+68
-0
Mac/Modules/qd/Qdmodule.c
Mac/Modules/qd/Qdmodule.c
+38
-0
Mac/Modules/qd/qdsupport.py
Mac/Modules/qd/qdsupport.py
+30
-0
No files found.
Mac/Modules/qd/Qdmodule.c
View file @
e9a9f926
...
...
@@ -297,7 +297,45 @@ static void BMObj_dealloc(self)
PyMem_DEL
(
self
);
}
static
PyObject
*
BMObj_getdata
(
_self
,
_args
)
BitMapObject
*
_self
;
PyObject
*
_args
;
{
PyObject
*
_res
=
NULL
;
int
from
,
length
;
char
*
cp
;
if
(
!
PyArg_ParseTuple
(
_args
,
"ii"
,
&
from
,
&
length
)
)
return
NULL
;
cp
=
_self
->
ob_itself
->
baseAddr
+
from
;
return
PyString_FromStringAndSize
(
cp
,
length
);
}
static
PyObject
*
BMObj_putdata
(
_self
,
_args
)
BitMapObject
*
_self
;
PyObject
*
_args
;
{
PyObject
*
_res
=
NULL
;
int
from
,
length
;
char
*
cp
,
*
icp
;
if
(
!
PyArg_ParseTuple
(
_args
,
"is#"
,
&
from
,
&
icp
,
&
length
)
)
return
NULL
;
cp
=
_self
->
ob_itself
->
baseAddr
+
from
;
memcpy
(
cp
,
icp
,
length
);
Py_INCREF
(
Py_None
);
return
Py_None
;
}
static
PyMethodDef
BMObj_methods
[]
=
{
{
"getdata"
,
(
PyCFunction
)
BMObj_getdata
,
1
,
"(int start, int size) -> string. Return bytes from the bitmap"
},
{
"putdata"
,
(
PyCFunction
)
BMObj_putdata
,
1
,
"(int start, string data). Store bytes into the bitmap"
},
{
NULL
,
NULL
,
0
}
};
...
...
Mac/Modules/qd/qdsupport.py
View file @
e9a9f926
...
...
@@ -310,6 +310,36 @@ for f in functions: module.add(f)
##for f in r_methods: r_object.add(f)
##for f in po_methods: po_object.add(f)
# Manual generator: get data out of a bitmap
getdata_body
=
"""
int from, length;
char *cp;
if ( !PyArg_ParseTuple(_args, "ii", &from, &length) )
return NULL;
cp = _self->ob_itself->baseAddr+from;
return PyString_FromStringAndSize(cp, length);
"""
f
=
ManualGenerator
(
"getdata"
,
getdata_body
)
f
.
docstring
=
lambda
:
"""(int start, int size) -> string. Return bytes from the bitmap"""
bm_object
.
add
(
f
)
# Manual generator: store data in a bitmap
putdata_body
=
"""
int from, length;
char *cp, *icp;
if ( !PyArg_ParseTuple(_args, "is#", &from, &icp, &length) )
return NULL;
cp = _self->ob_itself->baseAddr+from;
memcpy(cp, icp, length);
Py_INCREF(Py_None);
return Py_None;
"""
f
=
ManualGenerator
(
"putdata"
,
putdata_body
)
f
.
docstring
=
lambda
:
"""(int start, string data). Store bytes into the bitmap"""
bm_object
.
add
(
f
)
#
# We manually generate a routine to create a BitMap from python data.
#
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment