本文整理汇总了C#中ByteVector.ToInt方法的典型用法代码示例。如果您正苦于以下问题:C# ByteVector.ToInt方法的具体用法?C# ByteVector.ToInt怎么用?C# ByteVector.ToInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ByteVector
的用法示例。
在下文中一共展示了ByteVector.ToInt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateIFDEntry
/// <summary>
/// Creates an IFDEntry from the given values. This method is used for
/// every entry. Custom parsing can be hooked in by overriding the
/// <see cref="ParseIFDEntry(ushort,ushort,uint,long,uint)"/> method.
/// </summary>
/// <param name="tag">
/// A <see cref="System.UInt16"/> with the tag of the entry.
/// </param>
/// <param name="type">
/// A <see cref="System.UInt16"/> with the type of the entry.
/// </param>
/// <param name="count">
/// A <see cref="System.UInt32"/> with the data count of the entry.
/// </param>
/// <param name="base_offset">
/// A <see cref="System.Int64"/> with the base offset which every
/// offsets in the IFD are relative to.
/// </param>
/// <param name="offset_data">
/// A <see cref="ByteVector"/> containing exactly 4 byte with the data
/// of the offset of the entry. Since this field isn't interpreted as
/// an offset if the data can be directly stored in the 4 byte, we
/// pass the <see cref="ByteVector"/> to easier interpret it.
/// </param>
/// <param name="max_offset">
/// A <see cref="System.UInt32"/> with the maximal offset to consider for
/// the IFD.
/// </param>
/// <returns>
/// A <see cref="IFDEntry"/> with the given parameter.
/// </returns>
private IFDEntry CreateIFDEntry (ushort tag, ushort type, uint count, long base_offset, ByteVector offset_data, uint max_offset)
{
uint offset = offset_data.ToUInt (is_bigendian);
// Fix the type for the IPTC tag.
// From http://www.awaresystems.be/imaging/tiff/tifftags/iptc.html
// "Often times, the datatype is incorrectly specified as LONG. "
if (tag == (ushort) IFDEntryTag.IPTC && type == (ushort) IFDEntryType.Long) {
type = (ushort) IFDEntryType.Byte;
}
var ifd_entry = ParseIFDEntry (tag, type, count, base_offset, offset);
if (ifd_entry != null)
return ifd_entry;
if (count > 0x10000000) {
// Some Nikon files are known to exhibit this corruption (or "feature").
file.MarkAsCorrupt ("Impossibly large item count");
return null;
}
// then handle the values stored in the offset data itself
if (count == 1) {
if (type == (ushort) IFDEntryType.Byte)
return new ByteIFDEntry (tag, offset_data[0]);
if (type == (ushort) IFDEntryType.SByte)
return new SByteIFDEntry (tag, (sbyte)offset_data[0]);
if (type == (ushort) IFDEntryType.Short)
return new ShortIFDEntry (tag, offset_data.Mid (0, 2).ToUShort (is_bigendian));
if (type == (ushort) IFDEntryType.SShort)
return new SShortIFDEntry (tag, (short) offset_data.Mid (0, 2).ToUShort (is_bigendian));
if (type == (ushort) IFDEntryType.Long)
return new LongIFDEntry (tag, offset_data.ToUInt (is_bigendian));
if (type == (ushort) IFDEntryType.SLong)
return new SLongIFDEntry (tag, offset_data.ToInt (is_bigendian));
}
if (count == 2) {
if (type == (ushort) IFDEntryType.Short) {
ushort [] data = new ushort [] {
offset_data.Mid (0, 2).ToUShort (is_bigendian),
offset_data.Mid (2, 2).ToUShort (is_bigendian)
};
return new ShortArrayIFDEntry (tag, data);
}
if (type == (ushort) IFDEntryType.SShort) {
short [] data = new short [] {
(short) offset_data.Mid (0, 2).ToUShort (is_bigendian),
(short) offset_data.Mid (2, 2).ToUShort (is_bigendian)
};
return new SShortArrayIFDEntry (tag, data);
}
}
if (count <= 4) {
if (type == (ushort) IFDEntryType.Undefined)
return new UndefinedIFDEntry (tag, offset_data.Mid (0, (int)count));
if (type == (ushort) IFDEntryType.Ascii) {
string data = offset_data.Mid (0, (int)count).ToString ();
//.........这里部分代码省略.........