473,382 Members | 1,431 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,382 software developers and data experts.

Marshal float/double array at DLLImport of C++ function

I search on google, msdn,... and i not find no solutions. Any ideia?

----------------------------
C++ Example Source:

extern "C" __declspec(dllexport)
double * extract(int nrows,int ncols,int * RGB){
int i=0;
int j=ncols*nrows;
double* x;
x=(double*)calloc(1,sizeof(double)); // I
need return one double array
x[0]=((double)RGB[0]+RGB[1]+RGB[2])/3;
return x ;
}

extern "C" __declspec(dllexport)
double distance(double* img1, double* img2){
return img1[0]-img2[0];
}
--------------------------
C# code:

[DllImport("C:/Users/tiago/Desktop/teste.dll")]
[MarshalAs(UnmanagedType.LPArray, ArraySubType =
UnmanagedType.R8, SizeParamIndex = 1)]
public static extern Double[] extract(int nrows, int ncols,
int[] RGB);

[DllImport("C:/Users/tiago/Desktop/teste.dll")]
public static extern Double distance(Double[] img1, Double[]
img2);

---------------------------
Feb 15 '08 #1
0 5367

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

Similar topics

1
by: Eric Hendriks | last post by:
// In an unmanaged DLL the following function must be called: // int VFGeneralize(const BYTE * const * features); // "features" parameter is supposed to be an array of byte arrays. // function is...
9
by: Angel | last post by:
Hi again, I'm trying to call functions from a proprietary DLL but it's turned out to be more difficult than I thought. I have this W32.DLL which was written in C by USPS. They don't provide the...
1
by: Camilo Telles | last post by:
Sirs I have the foolowing structures in C #define POLY_MAX 8 // Número máximo de lados em um polígon typedef struct { // Um vértice do polígon double u, v; // texture space coord...
3
by: Tony Liu | last post by:
Dear All: I create a very simple DLL by using EVC to test the problem. (The platform I am working for those program is WinCE.NET) ******************************************************* The...
1
by: dhornyak | last post by:
I have been banging my head against the wall for a while now, and can't seem to id the problem. I've been through a ton of posts and the code doesn't seem any different. Can anybody see it? When...
14
by: Vertilka | last post by:
I need to read binary data file written by C++ program, using my C# application. How do i marshal the bytes i read with my C# code to .NET types. The data is numbers (integers float doubles...
0
by: jim4u | last post by:
I am porting a vb library to vb.net. The vb library has an external call to an unmanaged dll. Existing code: //External function declaration Private Declare Function Uncompress& Lib...
0
by: jim4u | last post by:
I am porting a vb library to vb.net. The vb library has an external call to an unmanaged dll. Existing code: //External function declaration Private Declare Function Uncompress& Lib...
3
by: coriscow | last post by:
Hi all!! I am developing an app for a Pocket PC platform on C#. However, I need to make use of a C written dll. The problem arises when calling the function ......... int capture_input( float32...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...

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.