コード例 #1
0
 public virtual void ProcessChunk([NotNull] string fourCC, [NotNull] sbyte[] payload)
 {
     //        System.out.println("Chunk " + fourCC + " " + payload.length + " bytes");
     if (fourCC.Equals("EXIF"))
     {
         new ExifReader().Extract(new ByteArrayReader(payload), _metadata);
     }
     else
     {
         if (fourCC.Equals("ICCP"))
         {
             new IccReader().Extract(new ByteArrayReader(payload), _metadata);
         }
         else
         {
             if (fourCC.Equals("XMP "))
             {
                 new XmpReader().Extract(payload, _metadata);
             }
             else
             {
                 if (fourCC.Equals("VP8X") && payload.Length == 10)
                 {
                     RandomAccessReader reader = new ByteArrayReader(payload);
                     reader.SetMotorolaByteOrder(false);
                     try
                     {
                         // Flags
                         //                boolean hasFragments = reader.getBit(0);
                         bool isAnimation = reader.GetBit(1);
                         //                boolean hasXmp = reader.getBit(2);
                         //                boolean hasExif = reader.getBit(3);
                         bool hasAlpha = reader.GetBit(4);
                         //                boolean hasIcc = reader.getBit(5);
                         // Image size
                         int           widthMinusOne  = reader.GetInt24(4);
                         int           heightMinusOne = reader.GetInt24(7);
                         WebpDirectory directory      = new WebpDirectory();
                         directory.SetInt(WebpDirectory.TagImageWidth, widthMinusOne + 1);
                         directory.SetInt(WebpDirectory.TagImageHeight, heightMinusOne + 1);
                         directory.SetBoolean(WebpDirectory.TagHasAlpha, hasAlpha);
                         directory.SetBoolean(WebpDirectory.TagIsAnimation, isAnimation);
                         _metadata.AddDirectory(directory);
                     }
                     catch (IOException e)
                     {
                         Sharpen.Runtime.PrintStackTrace(e, System.Console.Error);
                     }
                 }
             }
         }
     }
 }
コード例 #2
0
 public virtual void ProcessChunk([NotNull] string fourCC, [NotNull] sbyte[] payload)
 {
     //        System.out.println("Chunk " + fourCC + " " + payload.length + " bytes");
     if (fourCC.Equals("EXIF"))
     {
         new ExifReader().Extract(new ByteArrayReader(payload), _metadata);
     }
     else
     {
         if (fourCC.Equals("ICCP"))
         {
             new IccReader().Extract(new ByteArrayReader(payload), _metadata);
         }
         else
         {
             if (fourCC.Equals("XMP "))
             {
                 new XmpReader().Extract(payload, _metadata);
             }
             else
             {
                 if (fourCC.Equals("VP8X") && payload.Length == 10)
                 {
                     RandomAccessReader reader = new ByteArrayReader(payload);
                     reader.SetMotorolaByteOrder(false);
                     try
                     {
                         // Flags
                         //                boolean hasFragments = reader.getBit(0);
                         bool isAnimation = reader.GetBit(1);
                         //                boolean hasXmp = reader.getBit(2);
                         //                boolean hasExif = reader.getBit(3);
                         bool hasAlpha = reader.GetBit(4);
                         //                boolean hasIcc = reader.getBit(5);
                         // Image size
                         int widthMinusOne = reader.GetInt24(4);
                         int heightMinusOne = reader.GetInt24(7);
                         WebpDirectory directory = new WebpDirectory();
                         directory.SetInt(WebpDirectory.TagImageWidth, widthMinusOne + 1);
                         directory.SetInt(WebpDirectory.TagImageHeight, heightMinusOne + 1);
                         directory.SetBoolean(WebpDirectory.TagHasAlpha, hasAlpha);
                         directory.SetBoolean(WebpDirectory.TagIsAnimation, isAnimation);
                         _metadata.AddDirectory(directory);
                     }
                     catch (IOException e)
                     {
                         Sharpen.Runtime.PrintStackTrace(e, System.Console.Error);
                     }
                 }
             }
         }
     }
 }