public virtual void Extract(sbyte[] segmentBytes, Com.Drew.Metadata.Metadata metadata, JpegSegmentType segmentType) { if (segmentBytes == null) { throw new ArgumentNullException("segmentBytes cannot be null"); } if (metadata == null) { throw new ArgumentNullException("metadata cannot be null"); } if (segmentType == null) { throw new ArgumentNullException("segmentType cannot be null"); } try { ByteArrayReader reader = new ByteArrayReader(segmentBytes); // // Check for the header preamble // try { if (!reader.GetString(0, JpegExifSegmentPreamble.Length).Equals(JpegExifSegmentPreamble)) { // TODO what do to with this error state? System.Console.Error.Println("Invalid JPEG Exif segment preamble"); return; } } catch (IOException e) { // TODO what do to with this error state? Sharpen.Runtime.PrintStackTrace(e, System.Console.Error); return; } // // Read the TIFF-formatted Exif data // new TiffReader().ProcessTiff(reader, new ExifTiffHandler(metadata, _storeThumbnailBytes), JpegExifSegmentPreamble.Length); } catch (TiffProcessingException e) { // TODO what do to with this error state? Sharpen.Runtime.PrintStackTrace(e, System.Console.Error); } catch (IOException e) { // TODO what do to with this error state? Sharpen.Runtime.PrintStackTrace(e, System.Console.Error); } }
public virtual Face[] GetRecognizedFaces() { sbyte[] bytes = GetByteArray(TagFaceRecognitionInfo); if (bytes == null) { return null; } RandomAccessReader reader = new ByteArrayReader(bytes); reader.SetMotorolaByteOrder(false); try { int faceCount = reader.GetUInt16(0); if (faceCount == 0) { return null; } Face[] faces = new Face[faceCount]; for (int i = 0; i < faceCount; i++) { int offset = 4 + i * 44; string name = Sharpen.Extensions.Trim(reader.GetString(offset, 20, "ASCII")); string age = Sharpen.Extensions.Trim(reader.GetString(offset + 28, 20, "ASCII")); faces[i] = new Face(reader.GetUInt16(offset + 20), reader.GetUInt16(offset + 22), reader.GetUInt16(offset + 24), reader.GetUInt16(offset + 26), name, Age.FromPanasonicString(age)); } return faces; } catch (IOException) { return null; } }