Click here to Skip to main content
15,042,814 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi every one I am trying to call the DLL function with pointer parameters,
but my params which I have to refer are in jagged array , so I now have to refer array to pointer and pass pointer values to call DLL function.

note: I am using VISUAL STUDIO 2010

What I have tried:

the DLL function
[DllImport("BYRTORGB.dll")]
 public unsafe static extern void bayer2rgb24(byte* dst1, byte* src2, Int32 width, Int32 height);


the code I am calling to the DLL function.

unsafe
 {
   byte[][] dbuff = new byte[k][];
   fixed (byte* source = xBufs[k], dest = dbuff[k])
                                           {
   bayer2rgb24( dest, source, width, height);
   fs.Write(dbuff[k], 0, dbuff[k].Length);
Posted
Updated 31-Oct-17 1:21am
v2

1 solution

When you asked this question 2 days ago: How to convert byte[] ato byte in C#[^]
You were told:
Quote:
You can't directly pass a two dimensional array, because the "arrangement" of the data is not the same.
Even worse, what you are trying to apss is not a "basic" 2D array - it's a jagged array - which means that the lines are not all the same length, or even present in some cases.
Since the name dst implies that the one dimensional array is going to be used by the called function as an output, it is vitally important to get ti right, and a jagged array is definitely not suitable, as it's first dimension is actually an array of references to individual arrays of bytes.


You cannot pass a jagged array to your function assuming that it will work: You need to create a 1D array of bytes, pass that, and probably post-process it into your 2D jagged array once you have the data, and can work out where to "break" the array.
   
Comments
Balaraj Nayak 31-Oct-17 8:30am
   
can you please write code for it. I am not understanding how to do it.
OriginalGriff 31-Oct-17 8:39am
   
I can't.
I have no idea what that method does, what you are trying to make it do, what your data looks like, what the data returned by the method is going to be or is organised like.
Basically, I know nothing at all about your application, and you know everything! I cannot do you job for you as I have no idea what your job is! :laugh:
Balaraj Nayak 31-Oct-17 8:51am
   
here I have received streamed data and stored it in xbufs[k][]; (its a bayer .raw format)
and now the DLL function bayer2rgb has to take it as a source and dbuff as destination and convert from bayer to rgb. that's the concept I am working on.
Balaraj Nayak 31-Oct-17 8:53am
   
as you said above creating 1d array and post-processing etc ,for that can you write general concept code if possible, so that I can adopt that into my project .

thanks
OriginalGriff 31-Oct-17 9:01am
   
No - because we have no idea what your streamed data looks like, how it's organized, or anything. Even if we guessed, we couldn't even begin to test any solution because
1) we don't have your data (and no, I don't want you to try sending to to me),
2) we don't have your DLL to process it (and no, I don't want you to try sending to to me),
and
3) we don't have any idea what you are expecting to get as a result.

You seem to be trying to do this by "bolting together" random pieces of code in a selection of languages and hoping it will all sort itself out. That isn't a viable strategy: you need to sit down, and think about the task and what that entails instead. Nobody can do that for you!
Balaraj Nayak 31-Oct-17 9:06am
   
anyway thank for spending your valuable time to help me
thanks..
OriginalGriff 31-Oct-17 9:10am
   
You're welcome!
Good luck...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900