private void PrintMetadata(System.Windows.Media.ImageMetadata metadata, string fullQuery)
        {
            BitmapMetadata theMetadata = metadata as BitmapMetadata;

            if (theMetadata != null)
            {
                foreach (string query in theMetadata)
                {
                    string tempQuery = fullQuery + query;
                    // query string here is relative to the previous metadata reader.
                    object o = theMetadata.GetQuery(query);
                    //richTextBox1.Text += "\n" + tempQuery + ", " + query + ", " + o;
                    Console.WriteLine(tempQuery + ", " + query + ", " + o);
                    BitmapMetadata moreMetadata = o as BitmapMetadata;
                    if (moreMetadata != null)
                    {
                        PrintMetadata(moreMetadata, tempQuery);
                    }
                }
            }
        }
Esempio n. 2
0
        private void btnChangePic_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog openFileDialog = new Microsoft.Win32.OpenFileDialog();
            openFileDialog.ShowDialog();
            BitmapImage bi = new BitmapImage(new Uri(openFileDialog.FileName));

            System.Windows.Media.ImageMetadata im = bi.Metadata;
            MessageBox.Show(im.ToString());

            WriteableBitmap bitmap = new WriteableBitmap(bi);

            imgPicture.Source = bi;

            //bitmap

/*            BitmapImage bi = new BitmapImage(new Uri(openFileDialog.FileName));
 *          imgPicture.Source = bi;
 *
 *          int stride = bi.PixelWidth * 4;
 *          int size = bi.PixelHeight * stride;
 *          byte[] pixels = new byte[size];
 *          bi.CopyPixels(pixels, stride, 0);
 *
 *
 *
 *          int x = 0;
 *          int y = 0;
 *          int index = y * stride + 4 * x;
 *
 *
 *          byte red = pixels[index];
 *          byte green = pixels[index + 1];
 *          byte blue = pixels[index + 2];
 *          byte alpha = pixels[index+3];
 *          MessageBox.Show(red.ToString()+", " + green.ToString() + ", " + blue.ToString());
 */
        }