private static unsafe MouseCursor PlatformFromPixels(
            IReadOnlyPixelMemory <Color> data, int width, int height, Point origin)
        {
            var surface = IntPtr.Zero;
            var handle  = IntPtr.Zero;

            try
            {
                fixed(Color *ptr = data.GetPixelSpan())
                {
                    surface = SDL.CreateRGBSurfaceFrom(
                        (IntPtr)ptr, width, height, 32, data.ByteStride,
                        0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000);
                }

                if (surface == IntPtr.Zero)
                {
                    throw new InvalidOperationException(
                              "Failed to create surface for mouse cursor.", new Exception(SDL.GetError()));
                }

                handle = SDL.Mouse.CreateColorCursor(surface, origin.X, origin.Y);
                if (handle == IntPtr.Zero)
                {
                    throw new InvalidOperationException(
                              "Failed to create mouse cursor from surface.", new Exception(SDL.GetError()));
                }
            }
            finally
            {
                if (surface != IntPtr.Zero)
                {
                    SDL.FreeSurface(surface);
                }
            }
            return(new MouseCursor(handle));
        }