public virtual void Extract([NotNull] RandomAccessReader reader, [NotNull] Com.Drew.Metadata.Metadata metadata) { // TODO review whether the 'tagPtr' values below really do require RandomAccessReader or whether SequentialReader may be used instead IccDirectory directory = new IccDirectory(); try { int profileByteCount = reader.GetInt32(IccDirectory.TagProfileByteCount); directory.SetInt(IccDirectory.TagProfileByteCount, profileByteCount); // For these tags, the int value of the tag is in fact it's offset within the buffer. Set4ByteString(directory, IccDirectory.TagCmmType, reader); SetInt32(directory, IccDirectory.TagProfileVersion, reader); Set4ByteString(directory, IccDirectory.TagProfileClass, reader); Set4ByteString(directory, IccDirectory.TagColorSpace, reader); Set4ByteString(directory, IccDirectory.TagProfileConnectionSpace, reader); SetDate(directory, IccDirectory.TagProfileDatetime, reader); Set4ByteString(directory, IccDirectory.TagSignature, reader); Set4ByteString(directory, IccDirectory.TagPlatform, reader); SetInt32(directory, IccDirectory.TagCmmFlags, reader); Set4ByteString(directory, IccDirectory.TagDeviceMake, reader); int temp = reader.GetInt32(IccDirectory.TagDeviceModel); if (temp != 0) { if (temp <= unchecked ((int)(0x20202020))) { directory.SetInt(IccDirectory.TagDeviceModel, temp); } else { directory.SetString(IccDirectory.TagDeviceModel, GetStringFromInt32(temp)); } } SetInt32(directory, IccDirectory.TagRenderingIntent, reader); SetInt64(directory, IccDirectory.TagDeviceAttr, reader); float[] xyz = new float[] { reader.GetS15Fixed16(IccDirectory.TagXyzValues), reader.GetS15Fixed16(IccDirectory.TagXyzValues + 4), reader.GetS15Fixed16(IccDirectory.TagXyzValues + 8) }; directory.SetObject(IccDirectory.TagXyzValues, xyz); // Process 'ICC tags' int tagCount = reader.GetInt32(IccDirectory.TagTagCount); directory.SetInt(IccDirectory.TagTagCount, tagCount); for (int i = 0; i < tagCount; i++) { int pos = IccDirectory.TagTagCount + 4 + i * 12; int tagType = reader.GetInt32(pos); int tagPtr = reader.GetInt32(pos + 4); int tagLen = reader.GetInt32(pos + 8); sbyte[] b = reader.GetBytes(tagPtr, tagLen); directory.SetByteArray(tagType, b); } } catch (IOException ex) { directory.AddError("Exception reading ICC profile: " + ex.Message); } metadata.AddDirectory(directory); }
/// <summary> /// Performs the Jfif data extraction, adding found values to the specified /// instance of /// <see cref="Com.Drew.Metadata.Metadata"/> /// . /// </summary> public virtual void Extract([NotNull] RandomAccessReader reader, [NotNull] Com.Drew.Metadata.Metadata metadata) { JfifDirectory directory = new JfifDirectory(); metadata.AddDirectory(directory); try { // For JFIF, the tag number is also the offset into the segment int ver = reader.GetUInt16(JfifDirectory.TagVersion); directory.SetInt(JfifDirectory.TagVersion, ver); int units = reader.GetUInt8(JfifDirectory.TagUnits); directory.SetInt(JfifDirectory.TagUnits, units); int height = reader.GetUInt16(JfifDirectory.TagResx); directory.SetInt(JfifDirectory.TagResx, height); int width = reader.GetUInt16(JfifDirectory.TagResy); directory.SetInt(JfifDirectory.TagResy, width); } catch (IOException me) { directory.AddError(me.Message); } }