473,395 Members | 1,418 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

A Question about ctypes and a function f(void **)

Hello,
I have a C function f(void**,int *), in which it writes some
information (it is a RGB32 image).

Here is what i do
rowlength=c_int()
data=c_void_p()
d=pointer(data)
f(d,byref(rowlength)
The call works (no segmentation fault), now how do i access the data
in d? Because i need to pass it to a another function QImage that
takes void* as its first parameter.

If i do d.contents i get c_void_p(3067478024L)

All suggestions welcome.
Regards
Saptarshi
Aug 11 '08 #1
1 4444
sapsi <sa************@gmail.comwrote:
I have a C function f(void**,int *), in which it writes some
information (it is a RGB32 image).

Here is what i do
rowlength=c_int()
data=c_void_p()
d=pointer(data)
f(d,byref(rowlength)
The call works (no segmentation fault), now how do i access the data
in d? Because i need to pass it to a another function QImage that
takes void* as its first parameter.

If i do d.contents i get c_void_p(3067478024L)
You almost answered your own question!

d.contents is a c_void_p ie a (void *) so you can pass d.contents to
QImage directly I would have thought.

If you want to actually read the data from python then you'll need to
cast it to some other pointer type than c_void_p first, eg
>>d
c_void_p(136692916)
>>s = c_char_p(d.value)
s
c_char_p(136692916)
>>s.value
'hello'
>>>
or use ctypes.memmove to copy the data out to somewhere else.

--
Nick Craig-Wood <ni**@craig-wood.com-- http://www.craig-wood.com/nick
Aug 11 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: brian | last post by:
question about Onload function can one define more than one function for Onload ? <body Onload="function1()"> or can one define multiple functions one after another like <body Onload="f() g()...
3
by: Tao.Young | last post by:
Hi, I met with a very strange problem: the same function will generate different results, but when i uncomment Line1, it'll get the same results. anyone can tell me why? the code is...
1
by: Bob Hairgrove | last post by:
Why can I do this: template<typename A, typename B=A> struct X { /*...*/ }; whereas this gives me an error about an undeclared identifier with MSVC++ 7.1: struct A { A(int arg1, int...
0
by: p.lavarre | last post by:
Now at http://pyfaq.infogami.com/suggest we have: FAQ: How do I declare that CTypes function returns void? A: c_void = None is not doc'ed, but is suggested by: <class 'ctypes.c_void_p'> ...
0
by: p.lavarre | last post by:
Now at http://pyfaq.infogami.com/suggest we have: FAQ: How do I declare that a CTypes function returns unsigned char? A: c_uchar = ctypes.c_ubyte This irregularity actually is doc'ed, it's...
9
by: Gilbert | last post by:
Hi, In the code-behind, i have this function: Public Function myfunction(ByVal myvar As Object) As String dim x as string = myvar ..... Return x End Function
2
by: Wayne Shu | last post by:
Hi everyone, Today I meet a problem about virtual function. Consider the following little program. #include <iostream> class base { int i;
9
by: Matt | last post by:
Hi friends, Okay so well, I have quite a problem right now with a file stream. What I am doing is to use the Cannon SDK dlls to get control over my old Cannon A60 Camera for some surveillance...
20
by: xiao | last post by:
Hi~ every one~ I have a queston about fread function. if i have a code like this: (nscrdh and data are defined as two dementional arrays and both of them were stored in the same binary file) ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.