Click here to Skip to main content
15,891,033 members
Home / Discussions / C#
   

C#

 
GeneralRe: Calling C++ Image API from C# Pin
_Erik_13-Jan-11 6:47
_Erik_13-Jan-11 6:47 
GeneralRe: Calling C++ Image API from C# Pin
econner13-Jan-11 6:49
econner13-Jan-11 6:49 
GeneralRe: Calling C++ Image API from C# Pin
_Erik_13-Jan-11 6:55
_Erik_13-Jan-11 6:55 
GeneralRe: Calling C++ Image API from C# Pin
econner13-Jan-11 13:38
econner13-Jan-11 13:38 
GeneralRe: Calling C++ Image API from C# Pin
_Erik_14-Jan-11 1:51
_Erik_14-Jan-11 1:51 
GeneralRe: Calling C++ Image API from C# Pin
econner14-Jan-11 9:12
econner14-Jan-11 9:12 
GeneralRe: Calling C++ Image API from C# Pin
_Erik_14-Jan-11 10:22
_Erik_14-Jan-11 10:22 
GeneralRe: Calling C++ Image API from C# Pin
econner14-Jan-11 11:38
econner14-Jan-11 11:38 
Ok, below are the changes I tried. However, I am receiving an error of: "Attempted to read or write protected memory. This is often an indication that other memory is corrupt."


[DllImport("scandll.dll")]
private extern static int WScanSelectBuf(MY_IMAGE image_down, MY_IMAGE image_up, int select);


public static int ScanSelectBuf(MY_IMAGE image_down, MY_IMAGE image_up, int select)
{
   return WScanSelectBuf(image_down, image_up, select);
}


int nWidth = 100;
int nHeight = 200;

img1.width = nWidth;
img1.height = nHeight;
img1.info = 8; // 8bit

img2.width = nWidth;
img2.height = nHeight;
img2.info = 8; // 8bit

byte[] buffer1 = new byte[2 * img1.width * img1.height];
byte[] buffer2 = new byte[2 * img2.width * img2.height];

           
// Pin these two arrays in the managed heap
GCHandle bufferHandle1 = GCHandle.Alloc(buffer1, GCHandleType.Pinned);
GCHandle bufferHandle2 = GCHandle.Alloc(buffer2, GCHandleType.Pinned);

// Set the address of the buffers to each pbuf field
//img1.pbuf = bufferHandle1.AddrOfPinnedObject();
//img2.pbuf = bufferHandle2.AddrOfPinnedObject();

img1.pbuf = Marshal.UnsafeAddrOfPinnedArrayElement(buffer1, 0);
img2.pbuf = Marshal.UnsafeAddrOfPinnedArrayElement(buffer2, 0);


// And now we can make the P/Invoke call
ret = ScanSelectBuf(img1, img2, 0);

// Do not forget to free the handles
bufferHandle1.Free();
bufferHandle2.Free();

GeneralRe: Calling C++ Image API from C# Pin
econner14-Jan-11 12:07
econner14-Jan-11 12:07 
GeneralRe: Calling C++ Image API from C# Pin
econner14-Jan-11 12:30
econner14-Jan-11 12:30 
GeneralRe: Calling C++ Image API from C# Pin
econner15-Jan-11 5:16
econner15-Jan-11 5:16 
GeneralRe: Calling C++ Image API from C# Pin
_Erik_17-Jan-11 2:32
_Erik_17-Jan-11 2:32 
AnswerRe: Calling C++ Image API from C# Pin
Luc Pattyn13-Jan-11 5:18
sitebuilderLuc Pattyn13-Jan-11 5:18 
AnswerRe: Calling C++ Image API from C# [modified] Pin
econner13-Jan-11 6:11
econner13-Jan-11 6:11 
AnswerRe: Calling C++ Image API from C# Pin
Luc Pattyn13-Jan-11 6:22
sitebuilderLuc Pattyn13-Jan-11 6:22 
GeneralRe: Calling C++ Image API from C# Pin
econner13-Jan-11 6:49
econner13-Jan-11 6:49 
AnswerRe: Calling C++ Image API from C# Pin
Luc Pattyn13-Jan-11 6:56
sitebuilderLuc Pattyn13-Jan-11 6:56 
GeneralRe: Calling C++ Image API from C# Pin
econner13-Jan-11 7:00
econner13-Jan-11 7:00 
AnswerRe: Calling C++ Image API from C# Pin
jschell13-Jan-11 8:06
jschell13-Jan-11 8:06 
QuestionHow to record audio and modify the signal? Pin
softwarejaeger13-Jan-11 3:41
softwarejaeger13-Jan-11 3:41 
AnswerRe: How to record audio and modify the signal? Pin
Rob Philpott13-Jan-11 4:17
Rob Philpott13-Jan-11 4:17 
AnswerRe: How to record audio and modify the signal? Pin
Luc Pattyn13-Jan-11 4:28
sitebuilderLuc Pattyn13-Jan-11 4:28 
AnswerRe: How to record audio and modify the signal? Pin
_Erik_13-Jan-11 4:35
_Erik_13-Jan-11 4:35 
AnswerRe: How to record audio and modify the signal? Pin
Dalek Dave13-Jan-11 4:39
professionalDalek Dave13-Jan-11 4:39 
GeneralRe: How to record audio and modify the signal? Pin
softwarejaeger13-Jan-11 20:16
softwarejaeger13-Jan-11 20:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.