static Softy.Texture LoadTexture(Texture2D source)
 {
     Color32[]     pixels   = source.GetPixels32(0);
     Softy.Color[] mypixels = new Softy.Color[source.width * source.height];
     for (var i = 0; i < pixels.Length; ++i)
     {
         mypixels[i] = new Softy.Color(pixels[i].r, pixels[i].g, pixels[i].b, pixels[i].a);
     }
     return(new Softy.Texture(mypixels, source.width));
 }
        public static Texture LoadTexture(string fileName)
        {
            BitmapSource          bitmapSource    = new BitmapImage(new Uri(fileName, UriKind.RelativeOrAbsolute));
            FormatConvertedBitmap newBitmapSource = new FormatConvertedBitmap();

            newBitmapSource.BeginInit();
            newBitmapSource.Source            = bitmapSource;
            newBitmapSource.DestinationFormat = PixelFormats.Bgra32;
            newBitmapSource.EndInit();
            byte[] rawBytes = new byte[newBitmapSource.PixelWidth * newBitmapSource.PixelHeight * 4];
            newBitmapSource.CopyPixels(rawBytes, newBitmapSource.PixelWidth * 4, 0);
            Softy.Color[] rawImage = new Softy.Color[newBitmapSource.PixelWidth * newBitmapSource.PixelHeight];
            for (int i = 0; i < newBitmapSource.PixelWidth * newBitmapSource.PixelHeight; ++i)
            {
                rawImage[i] = new Softy.Color(rawBytes[i * 4 + 2], rawBytes[i * 4 + 1], rawBytes[i * 4 + 0], rawBytes[i * 4 + 3]);
            }
            Texture texture = new Texture(rawImage, newBitmapSource.PixelWidth);

            return(texture);
        }