Copy to correct offset.

Offset into image is y * stride, not y * bpp.
This commit is contained in:
Fraser 2014-02-21 19:35:34 +00:00 committed by thefiddler
parent 5b4f75ab68
commit 2bb0f945f9

View file

@ -32,8 +32,9 @@ namespace Examples.Tutorial
for (int y = 0; y < bitmap.Height; ++y) for (int y = 0; y < bitmap.Height; ++y)
{ {
var offset = new IntPtr(data.Scan0.ToInt64() + (data.Stride * y)); var offset = new IntPtr(data.Scan0.ToInt64() + (data.Stride * y));
var stride = bitmap.Width * 4;
System.Runtime.InteropServices.Marshal.Copy( System.Runtime.InteropServices.Marshal.Copy(
offset, rgba, y * 4, bitmap.Width * 4); offset, rgba, y * stride, stride);
} }
var cursor = new OpenTK.MouseCursor(rgba, bitmap.Width, bitmap.Height, 0, 0); var cursor = new OpenTK.MouseCursor(rgba, bitmap.Width, bitmap.Height, 0, 0);