Esempio n. 1
0
        public MainWindow()
        {
            InitializeComponent();

            NoteType.Items.Add(new KeyValuePair <string, double>("Full", 4));
            NoteType.Items.Add(new KeyValuePair <string, double>("1/2", 2));
            NoteType.Items.Add(new KeyValuePair <string, double>("1/4", 1));
            NoteType.Items.Add(new KeyValuePair <string, double>("1/8", 0.5));
            NoteType.Items.Add(new KeyValuePair <string, double>("1/16", 0.25));
            NoteType.Items.Add(new KeyValuePair <string, double>("1/32", 0.128));
            NoteType.Items.Add(new KeyValuePair <string, double>("1/64", 0.064));
            NoteType.SelectedIndex = 4;

            NoteCenter.Items.Add("Eb5");
            NoteCenter.Items.Add("C4");
            NoteCenter.Items.Add("C3");
            NoteCenter.Items.Add("C2");
            NoteCenter.SelectedIndex = 2;

            Uri iconUri = new Uri("pack://application:,,,/ImageToMidi.ico", UriKind.RelativeOrAbsolute);

            this.Icon = BitmapFrame.Create(iconUri);

            image.Source = this.Icon;
            bitmap       = PixelMidi.ImageSourceToBitmap(this.Icon as BitmapSource);
        }
Esempio n. 2
0
        internal async void LoadImage(string text, bool IsBase64 = false)
        {
            if (IsBase64)
            {
                using (MemoryStream imageStream = new MemoryStream())
                {
                    imageStream.Position = 0;
                    var    base64 = Regex.Replace(text, @"data:image/.*?;base64,", "", RegexOptions.IgnoreCase);
                    byte[] arr    = Convert.FromBase64String(base64);
                    await imageStream.WriteAsync(arr, 0, arr.Length);

                    await imageStream.FlushAsync();

                    imageStream.Seek(0, SeekOrigin.Begin);
                    var result = new BitmapImage();
                    result.BeginInit();
                    result.StreamSource = imageStream;
                    result.CacheOption  = BitmapCacheOption.OnLoad;
                    result.EndInit();
                    LoadImage(result);
                }
            }
            else
            {
                p2m.FileName = System.IO.Path.GetFileNameWithoutExtension(text);

                bitmap       = PixelMidi.LoadBitmap(text);
                image.Source = PixelMidi.BitmapToImageSource(PixelMidi.GrayScale(bitmap));

                //p2m.GetPixelMidi(bitmap, !MultiTrack.IsChecked.Value);
            }
        }
Esempio n. 3
0
 internal void LoadImage(BitmapSource source)
 {
     if (source is BitmapSource)
     {
         bitmap       = PixelMidi.ImageSourceToBitmap(source as BitmapSource);
         image.Source = PixelMidi.BitmapToImageSource(PixelMidi.GrayScale(bitmap));
     }
 }
Esempio n. 4
0
 private void InvertImage_Click(object sender, RoutedEventArgs e)
 {
     p2m.InvertSource = InvertImage.IsChecked.Value;
     if (p2m.InvertSource)
     {
         image.Source = PixelMidi.BitmapToImageSource(PixelMidi.Invert(bitmap));
     }
     else
     {
         image.Source = PixelMidi.BitmapToImageSource(bitmap);
     }
     //p2m.GetPixelMidi(bitmap);
 }
Esempio n. 5
0
 internal void LoadImage(Stream stream, bool IsDib = true)
 {
     try
     {
         if (stream is Stream)
         {
             if (IsDib)
             {
                 bitmap = BitmapFromDib(stream);
             }
             else
             {
                 bitmap = new System.Drawing.Bitmap(stream);
             }
             image.Source = PixelMidi.BitmapToImageSource(PixelMidi.GrayScale(bitmap));
         }
     }
     catch (Exception) { }
 }
Esempio n. 6
0
        internal void LoadImage(Uri url)
        {
            try
            {
                if (url is Uri)
                {
                    BitmapImage img = new BitmapImage();
                    img.BeginInit();
                    img.UriSource   = url;
                    img.CacheOption = BitmapCacheOption.OnLoad;
                    img.EndInit();

                    if (img is BitmapSource)
                    {
                        bitmap       = PixelMidi.ImageSourceToBitmap(img as BitmapSource);
                        image.Source = PixelMidi.BitmapToImageSource(PixelMidi.GrayScale(bitmap));
                    }
                }
            }
            catch (Exception) { }
        }