Click here to Skip to main content
15,796,456 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

In this line I am trying to convert Long to Intptr (it is throwing a error like long cannot be converted to Intptr)

Marshal.Copy(byteArray, tmpBmp.Width * (tmpBmp.Height - 1 - i), DirectCast(CLng(bmpDat1.Scan0) + tmpBmp.Width * i, IntPtr), tmpBmp.Width)<br />

Can anyone please fix it?
Thank you
Updated 22-Mar-11 3:37am

1 solution

Dim x As IntPtr
Dim y As Integer = 123
x = New IntPtr(y)

EDIT ==============

Since the method you're calling (Marshal.Copy) takes an IntPtr, you shouldn't be making the calculation result a long to begin with.

Dim value as Integer = bmpDat1.Scan0 + tmpBmp.Width * i
Marshal.Copy(byteArray, tmpBmp.Width * (tmpBmp.Height - 1 - i), new IntPtr(value), tmpBmp.Width)
Share this answer
Sergey Alexandrovich Kryukov 22-Mar-11 13:32pm    
Correct, a 5.

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