public object Convert(object value, Type targetType,
                              object parameter, CultureInfo culture)
        {
            PixelMap pixelMap = (PixelMap)value;

            return(LibrariesConverters.BitmapToImageSource(pixelMap.GetBitmap()));
        }
        public object Convert(object value, Type targetType,
                              object parameter, CultureInfo culture)
        {
            Vector3[,] vectorMap = (Vector3[, ])value;
            DirectBitmap bitmap = new DirectBitmap(vectorMap.GetLength(0), vectorMap.GetLength(1));

            for (int i = 0; i < bitmap.Width; i++)
            {
                for (int j = 0; j < bitmap.Height; j++)
                {
                    Vector3 color = vectorMap[i, j];
                    bitmap.SetPixel(i, j, Color.FromArgb((byte)(color.X * 255), (byte)(color.Y * 255), (byte)(color.Z * 255)));
                }
            }
            return(LibrariesConverters.BitmapToImageSource(bitmap.Bitmap));
        }
        public void SetTexture(string index)
        {
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();

            dlg.Filter = "Image files (*.png;*.jpeg;*.jpg)|*.png;*.jpeg;*.jpg|All files (*.*)|*.*";;

            bool?result = dlg.ShowDialog();

            if (result == true)
            {
                string filename = dlg.FileName;
                int    i        = int.Parse(index);
                switch (i)
                {
                case 0:
                    Settings.TriangleSettingsList[i].PickedTriangleTexture =
                        LibrariesConverters.BitmapToVectors(new Bitmap(filename));
                    break;

                case 1:
                    Settings.TriangleSettingsList[i].PickedTriangleTexture =
                        LibrariesConverters.BitmapToVectors(new Bitmap(filename));
                    break;

                case 2:
                    Settings.NormalMap =
                        PixelMap.SlowLoad(new Bitmap(filename));
                    break;

                case 3:
                    Settings.HeightMap =
                        PixelMap.SlowLoad(new Bitmap(filename));
                    break;
                }
            }
        }
Esempio n. 4
0
 public object ConvertBack(object value, Type targetType,
                           object parameter, CultureInfo culture)
 {
     System.Windows.Media.Color color = (System.Windows.Media.Color)value;
     return(LibrariesConverters.ColorToVector(Color.FromArgb(color.R, color.G, color.B)));
 }