I have written an image processing program in VB, but I am interested in seeing if some of the complex calculations can be made to run faster by switching them to a DLL in PB. The common operation in all of the subs or functions of the DLL would be to receive an existing 2D array of single precision numbers from VB, modify the array values, and then pass the array back to VB.
From my reading of the online help manual it seems that this could be done by manipulating an absolute array overlay in PB. From my current understanding the DLL routines could look something like the following:
DECLARE Sub ModifyVBMatrix( ByRef first_element as Single, C as Long, R as Long) Export
Dim I as Long, J as Long
Dim PB_array(0 to C-1, 0 to R-1) as Single at first_element
For I= 0 to R-1
For J=0 to C-1
PB_array(J,I)= "something complicated"
Next J
Next I
End Sub
Where first_element is the (0,0) element of the VB array with C columns and R rows.
The fundamental question is whether or not this is a valid approach? If the approach is valid, will this simple method work, or do I have to use the more elaborate method of calling the API's for manipulating VB SafeArrays in order to get the parameters for dimensioning the PB_array() ?
From my reading of the online help manual it seems that this could be done by manipulating an absolute array overlay in PB. From my current understanding the DLL routines could look something like the following:
DECLARE Sub ModifyVBMatrix( ByRef first_element as Single, C as Long, R as Long) Export
Dim I as Long, J as Long
Dim PB_array(0 to C-1, 0 to R-1) as Single at first_element
For I= 0 to R-1
For J=0 to C-1
PB_array(J,I)= "something complicated"
Next J
Next I
End Sub
Where first_element is the (0,0) element of the VB array with C columns and R rows.
The fundamental question is whether or not this is a valid approach? If the approach is valid, will this simple method work, or do I have to use the more elaborate method of calling the API's for manipulating VB SafeArrays in order to get the parameters for dimensioning the PB_array() ?
Comment