Hjg.Pngcs.PngReader.GetMetadata C# (CSharp) Method

GetMetadata() public method

Returns the ancillary chunks available
see GetChunksList
public GetMetadata ( ) : Hjg.Pngcs.Chunks.PngMetadata
return Hjg.Pngcs.Chunks.PngMetadata
        public PngMetadata GetMetadata()
        {
            if (FirstChunksNotYetRead())
                ReadFirstChunks();
            return metadata;
        }

Usage Example

コード例 #1
0
        private void btnOpen_Click( object sender, RoutedEventArgs e )
        {
            CommonOpenFileDialog openDialog = new CommonOpenFileDialog();
              openDialog.ShowPlacesList = true;
              openDialog.Multiselect = false;
              openDialog.IsFolderPicker = false;
              openDialog.AddToMostRecentlyUsedList = true;
              openDialog.Filters.Add( new CommonFileDialogFilter( "PNG images", "*.png" ) );
              if ( openDialog.ShowDialog( this ) == CommonFileDialogResult.Ok ) {
            soureFilePath = openDialog.FileName;
            // get comment meta
            using ( FileStream fileStream = new FileStream( soureFilePath, FileMode.Open, FileAccess.Read ) ) {
              pngReader = new PngReader( fileStream );
              // 参考自Hjg.Pngcs的SampleCustomChunk项目
              // get last line: this forces loading all chunks
              pngReader.ReadChunksOnly();
              tblkComment.Text = pngReader.GetMetadata().GetTxtForKey( Key_SemanticInfo );
              pngReader.End();
              fileStream.Close();
            }

            image.BeginInit();
            image.Source = new BitmapImage( new Uri( soureFilePath ) );
            image.EndInit();
              }
        }