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

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
Posted
Updated 22-Mar-11 2:37am
v2

1 solution

VB
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.

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

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