コード例 #1
0
        public static AdobeJpegDirectory ProcessBytes([NotNull] string filePath)
        {
            Com.Drew.Metadata.Metadata metadata = new Com.Drew.Metadata.Metadata();
            new AdobeJpegReader().Extract(new SequentialByteArrayReader(FileUtil.ReadBytes(filePath)), metadata);
            AdobeJpegDirectory directory = metadata.GetFirstDirectoryOfType <AdobeJpegDirectory>();

            NUnit.Framework.Assert.IsNotNull(directory);
            return(directory);
        }
コード例 #2
0
        public virtual void TestReadAdobeJpegMetadata1()
        {
            AdobeJpegDirectory directory = ProcessBytes("Tests/Data/adobeJpeg1.jpg.appe");

            Sharpen.Tests.IsFalse(Sharpen.Extensions.ConvertToString(directory.GetErrors()), directory.HasErrors());
            Sharpen.Tests.AreEqual(4, directory.GetTagCount());
            Sharpen.Tests.AreEqual(1, directory.GetInt(AdobeJpegDirectory.TagColorTransform));
            Sharpen.Tests.AreEqual(25600, directory.GetInt(AdobeJpegDirectory.TagDctEncodeVersion));
            Sharpen.Tests.AreEqual(128, directory.GetInt(AdobeJpegDirectory.TagApp14Flags0));
            Sharpen.Tests.AreEqual(0, directory.GetInt(AdobeJpegDirectory.TagApp14Flags1));
        }
コード例 #3
0
 public virtual void Extract([NotNull] SequentialReader reader, [NotNull] Com.Drew.Metadata.Metadata metadata)
 {
     Com.Drew.Metadata.Directory directory = new AdobeJpegDirectory();
     metadata.AddDirectory(directory);
     try
     {
         reader.SetMotorolaByteOrder(false);
         if (!reader.GetString(Preamble.Length).Equals(Preamble))
         {
             directory.AddError("Invalid Adobe JPEG data header.");
             return;
         }
         directory.SetInt(AdobeJpegDirectory.TagDctEncodeVersion, reader.GetUInt16());
         directory.SetInt(AdobeJpegDirectory.TagApp14Flags0, reader.GetUInt16());
         directory.SetInt(AdobeJpegDirectory.TagApp14Flags1, reader.GetUInt16());
         directory.SetInt(AdobeJpegDirectory.TagColorTransform, reader.GetInt8());
     }
     catch (IOException ex)
     {
         directory.AddError("IO exception processing data: " + ex.Message);
     }
 }
コード例 #4
0
 public virtual void Extract([NotNull] SequentialReader reader, [NotNull] Com.Drew.Metadata.Metadata metadata)
 {
     Com.Drew.Metadata.Directory directory = new AdobeJpegDirectory();
     metadata.AddDirectory(directory);
     try
     {
         reader.SetMotorolaByteOrder(false);
         if (!reader.GetString(Preamble.Length).Equals(Preamble))
         {
             directory.AddError("Invalid Adobe JPEG data header.");
             return;
         }
         directory.SetInt(AdobeJpegDirectory.TagDctEncodeVersion, reader.GetUInt16());
         directory.SetInt(AdobeJpegDirectory.TagApp14Flags0, reader.GetUInt16());
         directory.SetInt(AdobeJpegDirectory.TagApp14Flags1, reader.GetUInt16());
         directory.SetInt(AdobeJpegDirectory.TagColorTransform, reader.GetInt8());
     }
     catch (IOException ex)
     {
         directory.AddError("IO exception processing data: " + ex.Message);
     }
 }