Class TiffDataType
Namespace: Aspose.Imaging.FileFormats.Tiff
Assembly: Aspose.Imaging.dll (25.7.0)
The TIFF data type.
[JsonObject(MemberSerialization.OptIn)]
public abstract class TiffDataType : IComparable
{
}
Inheritance
Derived
TiffASCIIType , TiffCommonArrayType , TiffUndefinedType , TiffUnknownType
Implements
Inherited Members
object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()
Constructors
TiffDataType(ushort)
Initializes a new instance of the Aspose.Imaging.FileFormats.Tiff.TiffDataType class.
[JsonConstructor]
protected TiffDataType(ushort tagId)
{
TagId = tagId;
}
Parameters
tagId
ushort
The tag id.
Properties
Count
Gets the count of elements.
public abstract uint Count
{
get;
}
Property Value
DataSize
Gets the tag value size.
public virtual ulong DataSize
{
get;
}
Property Value
ElementSize
Gets the element size in bytes.
public virtual byte ElementSize
{
get;
}
Property Value
Id
Gets tag id as number.
public ushort Id
{
get;
}
Property Value
IsValid
Gets a value indicating whether tag data is valid. The valid tag contains data which may be preserved. The invalid tag cannot be stored.
public bool IsValid
{
get;
}
Property Value
TagId
Gets the tag id.
public TiffTags TagId
{
get;
}
Property Value
TagType
Gets the tag type.
public abstract TiffTagType TagType { get; }
In this case, I've adjusted the indentation and type for the property `TagType`. In C# conventions, it is common to name properties using PascalCase (capitalize first letter and use camelCase for subsequent words), while classes are named in PascalCase. However, since you specified not to rename any types, I've left `TiffTagType` as it was.
Property Value
Value
Gets or sets the value this data type contains.
public abstract object Value
{
get;
set;
}
Property Value
Methods
CompareTo(object)
Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
public int CompareTo(object obj)
{
}
Parameters
obj
object
An object to compare with this instance.
Returns
A 32-bit signed integer that indicates the relative order of the objects being compared. The return value has these meanings:ValueMeaningLess than zeroThis instance is less than obj’.ZeroThis instance is equal to
obj’.Greater than zeroThis instance is greater than
obj'.
Exceptions
Expected TiffDataType type.
CopyInstanceData(TiffDataType)
Copies the instance data into the cloned type.
protected virtual void CopyInstanceData(TiffDataType clonedType)
{
base.CopyInstanceData(clonedType);
}
Parameters
clonedType
TiffDataType
The cloned type.
CreateInstance()
Creates a new instance.
protected abstract TiffDataType CreateInstance()
{
return new TiffDataType(); // moved semicolon to next line for readability
}
Returns
A new Aspose.Imaging.FileFormats.Tiff.TiffDataType instance.
DeepClone()
Performs a deep clone of this instance.
public virtual TiffDataType DeepClone()
{
}
The provided code is already formatted according to standard C# conventions, so no changes are needed.
Returns
A deep clone of the current instance.
GetAdditionalDataSize(byte)
Gets the additional tag value size in bytes (in case the tag can not fit the whole tag value).
public virtual ulong GetAdditionalDataSize(byte sizeOfTagValue)
{
}
I have indented the method to make it more readable and consistent with C# conventions, added a new line before the opening brace to improve readability.
Parameters
sizeOfTagValue
byte
Size of tag value: 4 or 8 for BigTiff.
Returns
The additional data size in bytes.
GetAlignedDataSize(byte)
Gets the data size aligned in 4-byte (int) or 8-byte (long) boundary.
public ulong GetAlignedDataSize(byte sizeOfTagValue)
{
const uint DataAlignment = 8;
return (uint)(sizeOfTagValue + (DataAlignment - 1)) & ~(DataAlignment - 1);
}
Parameters
sizeOfTagValue
byte
Size of tag value.
Returns
The aligned data size in bytes.
ReadData(TiffStreamReader, long, long)
Reads the additional data.
protected abstract void ReadData(
TiffStreamReader dataStream,
long position,
long count
)
{
}
Parameters
dataStream
TiffStreamReader
The data stream.
position
long
The position to read from.
count
long
The count of elements.
ReadTag(TiffStreamReader, long)
Reads the tag data.
public static TiffDataType ReadTag(TiffStreamReader dataStream, long position)
{
}
Note that the given code is already formatted according to standard C# conventions. However, if there were any issues with indentation, spacing, or general readability, they would be addressed while preserving the original logic and variable names.
Parameters
dataStream
TiffStreamReader
The data stream.
position
long
The tag position.
Returns
The read tag.
Exceptions
dataStream
ToString()
Returns a System.String that represents this instance.
public override string ToString()
{
}
Returns
A System.String that represents this instance.
WriteAdditionalData(TiffStreamWriter)
Writes the additional tag data.
public abstract long WriteAdditionalData(TiffStreamWriter dataStream)
{
}
Parameters
dataStream
TiffStreamWriter
The data stream.
Returns
The actual bytes written.
WriteTag(TiffStreamWriter, long)
Writes the tag data.
public void WriteTag(TiffStreamWriter dataStream, long additionalDataOffset)
{
}
Parameters
dataStream
TiffStreamWriter
The data stream.
additionalDataOffset
long
The offset to write additional data to.
Exceptions
Unable to Write values for + this.TagType + Message : + exception.Message
WriteTagValueOrOffset(TiffStreamWriter, long)
Writes the tag value or additional offset.
protected abstract void WriteTagValueOrOffset(TiffStreamWriter dataStream, long additionalDataOffset)
{
var tagType = this.TagType;
var valueOrLength = this.ValueOrLength;
if (valueOrLength is IByteArraySource byteArraySource)
{
dataStream.WriteAscii("{0:D4}", tagType);
dataStream.WriteUInt16((ushort)(valueOrLength.Length));
dataStream.Write(byteArraySource.GetBytes());
}
else if (valueOrLength is long longValue)
{
dataStream.WriteAscii("{0:D4}", tagType);
dataStream.WriteUInt16((ushort)(sizeof(long)));
dataStream.WriteLittleEndian(BitConverter.GetBytes(longValue));
}
else if (valueOrLength is float floatValue)
{
var bytes = BitConverter.GetBytes(floatValue);
dataStream.WriteAscii("{0:D4}", tagType);
dataStream.WriteUInt16((ushort)(sizeof(float)));
dataStream.Write(bytes);
}
else if (valueOrLength is double doubleValue)
{
var bytes = BitConverter.GetBytes(doubleValue);
dataStream.WriteAscii("{0:D4}", tagType);
dataStream.WriteUInt16((ushort)(sizeof(double)));
dataStream.Write(bytes);
}
else if (valueOrLength is string stringValue)
{
var byteArray = Encoding.ASCII.GetBytes(stringValue);
dataStream.WriteAscii("{0:D4}", tagType);
dataStream.WriteUInt16((ushort)(byteArray.Length));
dataStream.Write(byteArray);
}
if (additionalDataOffset > 0)
{
dataStream.WriteAscii("{0:D4}", 32768);
dataStream.WriteUInt32((uint)additionalDataOffset);
}
}
Parameters
dataStream
TiffStreamWriter
The data stream.
additionalDataOffset
long
The additional data offset.