CSJ2K.Icc.Tags.ICCTag.createInstance C# (CSharp) Method

createInstance() public static method

Factory method for creating a tag of a specific type.
public static createInstance ( int signature, byte data, int offset, int count ) : ICCTag
signature int tag to create ///
data byte byte array containg embedded tag data ///
offset int to tag data in the array ///
count int size of tag data in bytes ///
return ICCTag
        public static ICCTag createInstance(int signature, byte[] data, int offset, int count)
        {
            int type = ICCProfile.getInt(data, offset);

            if (type == kdwTextDescType)
                return new ICCTextDescriptionType(signature, data, offset, count);
            else if (type == kdwTextType)
                return new ICCTextType(signature, data, offset, count);
            else if (type == kdwXYZType)
                return new ICCXYZType(signature, data, offset, count);
            else if (type == kdwXYZTypeReverse)
                return new ICCXYZTypeReverse(signature, data, offset, count);
            else if (type == kdwCurveType)
                return new ICCCurveType(signature, data, offset, count);
            else if (type == kdwCurveTypeReverse)
                return new ICCCurveTypeReverse(signature, data, offset, count);
            else if (type == kdwMeasurementType)
                return new ICCMeasurementType(signature, data, offset, count);
            else if (type == kdwSignatureType)
                return new ICCSignatureType(signature, data, offset, count);
            else if (type == kdwViewType)
                return new ICCViewType(signature, data, offset, count);
            else if (type == kdwDataType)
                return new ICCDataType(signature, data, offset, count);
            else
            {
                var bytes = BitConverter.GetBytes(type);
                throw new System.ArgumentException("bad tag type: " + System.Text.Encoding.UTF8.GetString(bytes, 0, bytes.Length) +
                                                   "(" + type + ")");
            }
        }

Usage Example

示例#1
0
		/// <summary> Ctor used by factory method.</summary>
		/// <param name="byte">raw tag data
		/// </param>
		protected internal ICCTagTable(byte[] data)
		{
            tagCount = ICCProfile.getInt(data, offTagCount);
			
			int offset = offTags;
			for (int i = 0; i < tagCount; ++i)
			{
                int signature = ICCProfile.getInt(data, offset);
                int tagOffset = ICCProfile.getInt(data, offset + ICCProfile.int_size);
                int length = ICCProfile.getInt(data, offset + 2 * ICCProfile.int_size);
				trios.Add(new Triplet(signature, tagOffset, length));
				offset += 3 * ICCProfile.int_size;
			}
			
			
			System.Collections.IEnumerator Enum = trios.GetEnumerator();
			//UPGRADE_TODO: Method 'java.util.Enumeration.hasMoreElements' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilEnumerationhasMoreElements'"
			while (Enum.MoveNext())
			{
				//UPGRADE_TODO: Method 'java.util.Enumeration.nextElement' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilEnumerationnextElement'"
				Triplet trio = (Triplet) Enum.Current;
				ICCTag tag = ICCTag.createInstance(trio.signature, data, trio.offset, trio.count);
				System.Object tempObject;
				tempObject = this[(System.Int32) tag.signature];
				this[(System.Int32) tag.signature] = tag;
				System.Object generatedAux2 = tempObject;
			}
		}