secile / UsbCamera

C# source code for using usb camera and web camera in WinForms/WPF. With only single CSharp source code. No external library required.
MIT License
179 stars 55 forks source link

Fix for running on x64 #1

Closed genejo closed 4 years ago

genejo commented 4 years ago

Thanks for the neat library!

Tried running after compiling for x64 and it broke. Found a fix - you may want to replace line 320:

var dst = new IntPtr(bmp_data.Scan0.ToInt32() + (stride * y));

with

var dst = IntPtr.Add(bmp_data.Scan0, stride * y);

to avoid manually interfering with pointer arithmetics.

secile commented 4 years ago

Thank you for your information. In my PC, your problem is not occur, but I understand what you say. Under x64, IntPtr value can be larger than 4byte, therefore Scan0.ToInt32() can be cause overflow exception.

I'll fix this problem future release. Thank you.