physical address of a byteArray that external lib can use

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

physical address of a byteArray that external lib can use

Howard Oh
Hi.

How can I get an address of a bytearray, that is compatible with the
external libraries?

To tell by story, I want to set the imageBits instance variable of
DIBSection with dolphin bytearray address.
To me imageBits doesn't seem to be initialized(allocated) correctly when
DIBSection object be created.

Long time no see. But I'm back.
Hwa Jong Oh


Reply | Threaded
Open this post in threaded view
|

Re: physical address of a byteArray that external lib can use

Bill Schwab
Hwa Jong,

> How can I get an address of a bytearray, that is compatible with the
> external libraries?

That's usually pretty easy - just pass the byte array; the VM automatically
passes the address for you.  If you are mapping the external function
yourself (writing the callout method in an external library subclass), you
can declare the pointer argument to be lpvoid.  There are some rare
cirumstances when you have to tinker with #yourAddress or other selectors,
but, a byte array should work fine with the defaults.  As an aside, the most
complicated situation I've seen was one in which I was passing a pointer
passed to me on to another COM interface, and I had to re-wrap it because I
ended up with an unwanted indirection.  I'm a firm believer that the
automatic pass by address saves us from ourselves far more often than it
causes problems.


> To tell by story, I want to set the imageBits instance variable of
> DIBSection with dolphin bytearray address.
> To me imageBits doesn't seem to be initialized(allocated) correctly when
> DIBSection object be created.

See Ian's goodies.  He has a device independent bitmap class that should
help you.  Be _very_ careful if you intend to manipulate the image bits
directly.  It's generally easier (and always safer) to create a canvas on a
bitmap (even one of Ian's DI ones) and draw on it to change the bits.

Have a good one,

Bill

--
Wilhelm K. Schwab, Ph.D.
[hidden email]