/// <exception cref="System.IO.IOException"/> /// <exception cref="Com.Drew.Imaging.Jpeg.JpegProcessingException"/> public static void Main(string[] args) { if (args.Length < 1) { PrintUsage(); System.Environment.Exit(1); } string filePath = args[0]; if (!new FilePath(filePath).Exists()) { System.Console.Error.Println("File does not exist"); PrintUsage(); System.Environment.Exit(1); } ICollection<JpegSegmentType> segmentTypes = new HashSet<JpegSegmentType>(); for (int i = 1; i < args.Length; i++) { JpegSegmentType segmentType = JpegSegmentType.ValueOf(args[i].ToUpper()); if (!segmentType.canContainMetadata) { System.Console.Error.Printf("WARNING: Segment type %s cannot contain metadata so it may not be necessary to extract it%n", segmentType); } segmentTypes.Add(segmentType); } if (segmentTypes.Count == 0) { // If none specified, use all that could reasonably contain metadata Sharpen.Collections.AddAll(segmentTypes, JpegSegmentType.canContainMetadataTypes); } JpegSegmentData segmentData = JpegSegmentReader.ReadSegments(new FilePath(filePath), segmentTypes.AsIterable()); SaveSegmentFiles(filePath, segmentData); }
/// <summary>Gets the set of JPEG segment type identifiers.</summary> public virtual Iterable<JpegSegmentType> GetSegmentTypes() { ICollection<JpegSegmentType> segmentTypes = new HashSet<JpegSegmentType>(); foreach (sbyte segmentTypeByte in _segmentDataMap.Keys) { JpegSegmentType segmentType = JpegSegmentType.FromByte(segmentTypeByte); if (segmentType == null) { throw new InvalidOperationException("Should not have a segmentTypeByte that is not in the enum: " + Sharpen.Extensions.ToHexString(segmentTypeByte)); } segmentTypes.Add(segmentType); } return segmentTypes.AsIterable(); }
/// <summary>Gets the set of JPEG segment type identifiers.</summary> public virtual Iterable <JpegSegmentType> GetSegmentTypes() { ICollection <JpegSegmentType> segmentTypes = new HashSet <JpegSegmentType>(); foreach (sbyte segmentTypeByte in _segmentDataMap.Keys) { JpegSegmentType segmentType = JpegSegmentType.FromByte(segmentTypeByte); if (segmentType == null) { throw new InvalidOperationException("Should not have a segmentTypeByte that is not in the enum: " + Sharpen.Extensions.ToHexString(segmentTypeByte)); } segmentTypes.Add(segmentType); } return(segmentTypes.AsIterable()); }
public IIterator keys() { return(_storage.AsIterable().iterator()); }
/// <exception cref="System.IO.IOException"/> /// <exception cref="Com.Drew.Imaging.Jpeg.JpegProcessingException"/> public static void Main(string[] args) { if (args.Length < 1) { PrintUsage(); System.Environment.Exit(1); } string filePath = args[0]; if (!new FilePath(filePath).Exists()) { System.Console.Error.Println("File does not exist"); PrintUsage(); System.Environment.Exit(1); } ICollection <JpegSegmentType> segmentTypes = new HashSet <JpegSegmentType>(); for (int i = 1; i < args.Length; i++) { JpegSegmentType segmentType = JpegSegmentType.ValueOf(args[i].ToUpper()); if (!segmentType.canContainMetadata) { System.Console.Error.Printf("WARNING: Segment type %s cannot contain metadata so it may not be necessary to extract it%n", segmentType); } segmentTypes.Add(segmentType); } if (segmentTypes.Count == 0) { // If none specified, use all that could reasonably contain metadata Sharpen.Collections.AddAll(segmentTypes, JpegSegmentType.canContainMetadataTypes); } System.Console.Out.Println("Reading: " + filePath); JpegSegmentData segmentData = JpegSegmentReader.ReadSegments(new FilePath(filePath), segmentTypes.AsIterable()); SaveSegmentFiles(filePath, segmentData); }
/// <exception cref="Com.Drew.Imaging.Jpeg.JpegProcessingException"/> /// <exception cref="System.IO.IOException"/> public static void Process([NotNull] Com.Drew.Metadata.Metadata metadata, [NotNull] InputStream inputStream, [CanBeNull] Iterable <JpegSegmentMetadataReader> readers) { if (readers == null) { readers = AllReaders; } ICollection <JpegSegmentType> segmentTypes = new HashSet <JpegSegmentType>(); foreach (JpegSegmentMetadataReader reader in readers) { foreach (JpegSegmentType type in reader.GetSegmentTypes()) { segmentTypes.Add(type); } } JpegSegmentData segmentData = JpegSegmentReader.ReadSegments(new Com.Drew.Lang.StreamReader(inputStream), segmentTypes.AsIterable()); ProcessJpegSegmentData(metadata, readers, segmentData); }
/// <exception cref="System.IO.IOException"></exception> private void RecvWants() { HashSet<ObjectId> wantIds = new HashSet<ObjectId>(); bool isFirst = true; for (; ; ) { string line; try { line = pckIn.ReadString(); } catch (EOFException eof) { if (isFirst) { break; } throw; } if (line == PacketLineIn.END) { break; } if (!line.StartsWith("want ") || line.Length < 45) { throw new PackProtocolException(MessageFormat.Format(JGitText.Get().expectedGot, "want", line)); } if (isFirst && line.Length > 45) { string opt = Sharpen.Runtime.Substring(line, 45); if (opt.StartsWith(" ")) { opt = Sharpen.Runtime.Substring(opt, 1); } foreach (string c in opt.Split(" ")) { options.AddItem(c); } line = Sharpen.Runtime.Substring(line, 0, 45); } wantIds.AddItem(ObjectId.FromString(Sharpen.Runtime.Substring(line, 5))); isFirst = false; } if (wantIds.IsEmpty()) { return; } AsyncRevObjectQueue q = walk.ParseAny(wantIds.AsIterable (), true); try { for (; ; ) { RevObject o; try { o = q.Next(); } catch (IOException error) { throw new PackProtocolException(MessageFormat.Format(JGitText.Get().notValid, error .Message), error); } if (o == null) { break; } if (o.Has(WANT)) { } else { // Already processed, the client repeated itself. if (o.Has(ADVERTISED)) { o.Add(WANT); wantAll.AddItem(o); if (o is RevTag) { o = walk.Peel(o); if (o is RevCommit) { if (!o.Has(WANT)) { o.Add(WANT); wantAll.AddItem(o); } } } } else { throw new PackProtocolException(MessageFormat.Format(JGitText.Get().notValid, o.Name )); } } } } finally { q.Release(); } }
/// <exception cref="Com.Drew.Imaging.Jpeg.JpegProcessingException"/> /// <exception cref="System.IO.IOException"/> public static void Process(Com.Drew.Metadata.Metadata metadata, InputStream inputStream, Iterable<JpegSegmentMetadataReader> readers) { if (readers == null) { readers = AllReaders; } ICollection<JpegSegmentType> segmentTypes = new HashSet<JpegSegmentType>(); foreach (JpegSegmentMetadataReader reader in readers) { foreach (JpegSegmentType type in reader.GetSegmentTypes()) { segmentTypes.Add(type); } } JpegSegmentData segmentData = JpegSegmentReader.ReadSegments(new Com.Drew.Lang.StreamReader(inputStream), segmentTypes.AsIterable()); ProcessJpegSegmentData(metadata, readers, segmentData); }