public override void GetTagData(byte[] iccData, int index, ICCHeader header)
        {
            //Number of channels (2 bytes)
            ChannelCount = HighEndianReader.GetUInt16(iccData, index, IsLittleEndian);
            //Count of measurement types (2 bytes)
            MeasurmentTypesCount = HighEndianReader.GetUInt16(iccData, index + 2, IsLittleEndian);
            //Offsets (4 bytes each)
            Offset = new int[MeasurmentTypesCount];
            int dataEntryPoint;

            for (int i = 0; i < MeasurmentTypesCount; i++)
            {
                dataEntryPoint = index + 4 + i * 4;
                Offset[i]      = (int)HighEndianReader.GetUint32(iccData, dataEntryPoint, IsLittleEndian);
            }
            //int end = idx + 4 + 4 * MeasurmentTypesCount; int c = 0;
            //for (int i = idx + 4; i < end; i += 4) { Offset[c] = (int)Helper.GetUInt32(i); c++; }
            //Response curve structures
            Curves = new ResponseCurve[MeasurmentTypesCount];
            for (int i = 0; i < MeasurmentTypesCount; i++)
            {
                dataEntryPoint = index - 8 + Offset[i];
                Curves[i]      = new ResponseCurve(iccData, dataEntryPoint, ChannelCount, IsLittleEndian);
            }
        }
Example #2
0
        public override void GetTagData(byte[] iccData, int index, ICCHeader header)
        {
            //Number of input channels (2 bytes)
            InputChannelCount = HighEndianReader.GetUInt16(iccData, index);
            //Number of output channels (2 bytes)
            OutputChannelCount = HighEndianReader.GetUInt16(iccData, index + 2);
            //Number of processing elements (4 bytes)
            ProcessingElementCount = (int)HighEndianReader.GetUint32(iccData, index + 4);
            //Process element positions table (8 bytes each)
            PositionTable = new PositionNumber[ProcessingElementCount];
            //int end = idx + 8 + 8 * ProcessingElementCount; int c = 0;

            for (int i = 0; i < ProcessingElementCount; i++)
            {
                int dataEntryPoint = index + 8 + 8 * i;
                PositionTable[i] = new PositionNumber(iccData, dataEntryPoint);
            }

            //for (int i = idx + 8; i < end; i += 8) { PositionTable[c] = new PositionNumber(i); c++; }
            //Data
            Data = new MultiProcessElement[ProcessingElementCount];
            for (int i = 0; i < ProcessingElementCount; i++)
            {
                Data[i] = MultiProcessElement.CreateElement(iccData, PositionTable[i].Offset);
            }
        }
Example #3
0
        internal OneDimensionalCurve(byte[] iccData, int idx)
        {
            bool isLittleEndian = BitConverter.IsLittleEndian;

            //Number of segments (2 bytes) (plus 2 bytes reserved)
            SegmentCount = HighEndianReader.GetUInt16(iccData, idx, isLittleEndian);
            //Break points (4 bytes each)
            BreakPoints = new double[SegmentCount - 1];
            for (int i = 0; i < SegmentCount - 1; i++)
            {
                int dataEntryPoint = idx + 4 + 4 * i;
                BreakPoints[i] = HighEndianReader.GetFloat32(iccData, dataEntryPoint, isLittleEndian);
            }
            int dataEntryForSegments = idx + 4 + SegmentCount * 4; int c = 0;
            int lastSegmentLength = 0;

            //for (int i = idx + 4; i < iend; i += 4) { BreakPoints[c] = HighEndianReader.GetFloat32(iccData,i, isLittleEndian); c++; }
            //Segments
            Segments = new CurveSegment[SegmentCount];
            //int start = iend; iend += 1; c = 0;
            for (int i = 0; i < SegmentCount; i++)
            {
                dataEntryForSegments += lastSegmentLength;
                Segments[i]           = CurveSegment.GetCurve(iccData, dataEntryForSegments);
                lastSegmentLength     = Segments[i].LengthInByte;
            }
            //for (int i = start; i < SegmentCount; i++) { Segments[i] = CurveSegment.GetCurve(iccData,iend); iend += Segments[i].LengthInByte;  }
            //end += iend;
        }
 public override void GetCurveData(byte[] iccData, int index, bool isLittleEndian)
 {
     //Encoded value of the function type (2 bytes) (plus 2 bytes reserved)
     formula = HighEndianReader.GetUInt16(iccData, index, isLittleEndian);
     if (formula != 1 && formula != 2 && formula != 3)
     {
         throw new CorruptProfileException("FormulaCurveElement");
     }
     //Parameters (4 bytes each)
     if (formula == 0 || formula == 1)
     {
         gamma = HighEndianReader.GetFloat32(iccData, index + 4, isLittleEndian);
     }
     if (formula == 0 || formula == 1 || formula == 2)
     {
         a = HighEndianReader.GetFloat32(iccData, index + 8, isLittleEndian);
         b = HighEndianReader.GetFloat32(iccData, index + 12, isLittleEndian);
         c = HighEndianReader.GetFloat32(iccData, index + 16, isLittleEndian);
         //end = idx + 20;
         LengthInByte = 20;
     }
     if (formula == 1 || formula == 2)
     {
         d = HighEndianReader.GetFloat32(iccData, index + 20, isLittleEndian);; end = index + 24; LengthInByte = 24;
     }
     if (formula == 2)
     {
         e = HighEndianReader.GetFloat32(iccData, index + 24, isLittleEndian);; end = index + 24; LengthInByte = 24;
     }
 }
Example #5
0
        public override void GetTagData(byte[] iccData, int index, ICCHeader header)
        {
            uint f = HighEndianReader.GetUInt16(iccData, index, IsLittleEndian);

            IsASCII = f == 0;
            //Data
            Data = new byte[dataSize - 12];
            Array.Copy(iccData, index + 4, Data, 0, dataSize - 12);
        }
Example #6
0
 public LUT16(byte[] iccData, int index, int ValueCount, bool isLittleEndian)
 {
     Values = new ushort[ValueCount];
     for (int i = 0; i < ValueCount; i++)
     {
         int dataIndex = index + i * 2;
         Values[i] = HighEndianReader.GetUInt16(iccData, dataIndex, isLittleEndian);
     }
 }
Example #7
0
        internal static MultiProcessElement CreateElement(byte[] iccData, int idx, bool isLittleEndian = false)
        {
            //Tag signature (byte position 0 to 3) (4 to 7 are zero)
            multiProcessElementSignature t = (multiProcessElementSignature)HighEndianReader.GetUint32(iccData, idx);
            //Number of input channels (2 bytes)
            ushort InputChannelCount = HighEndianReader.GetUInt16(iccData, idx + 8);
            //Number of output channels (2 bytes)
            ushort OutputChannelCount = HighEndianReader.GetUInt16(iccData, idx + 10, isLittleEndian);

            return(GetElement(t, iccData, idx + 12, InputChannelCount, OutputChannelCount));
        }
        public override void GetTagData(byte[] iccData, int index, ICCHeader header)
        {
            int arrayNumber = (int)(dataSize - 8) / 2;

            Data = new UInt16[arrayNumber];
            for (int i = 0; i < arrayNumber; i++)
            {
                int dataIndex = index + i * 2;
                Data[i] = HighEndianReader.GetUInt16(iccData, dataIndex, IsLittleEndian);
            }
        }
 public override void GetTagData(byte[] iccData, int index, ICCHeader header)
 {
     ColorantCount = HighEndianReader.GetUint32(iccData, index, IsLittleEndian);
     //Number of the colorant to be printed first
     ColorantData = new ColorantData[ColorantCount];
     for (int i = 0; i < ColorantCount; i++)
     {
         //Colorant name (32 bytes)
         int    startIndex = index + 4 + i * 38;
         string name       = HighEndianReader.GetASCII(iccData, startIndex, 32);
         //PCS values (6 bytes (2 bytes each))
         ushort pcs1 = HighEndianReader.GetUInt16(iccData, startIndex + 32, IsLittleEndian);
         ushort pcs2 = HighEndianReader.GetUInt16(iccData, startIndex + 34, IsLittleEndian);
         ushort pcs3 = HighEndianReader.GetUInt16(iccData, startIndex + 36, IsLittleEndian);
     }
 }
 public override void GetTagData(byte[] iccData, int index, ICCHeader header)
 {
     CurvePointCount = HighEndianReader.GetUint32(iccData, index, IsLittleEndian);
     CurveData       = new double[CurvePointCount];
     if (CurvePointCount == 1)
     {
         CurveData[0] = HighEndianReader.GetU8Fixed8NumberToDouble(iccData, index + 4, IsLittleEndian);
         //end = index + 6;
     }
     else
     {
         for (int i = 0; i < CurvePointCount; i++)
         {
             int startIndex = index + 4 + 2 * i;
             CurveData[i] = HighEndianReader.GetUInt16(iccData, startIndex, IsLittleEndian) / 65535d;
         }
         //int c = 0; end = (idx + 4) + (int)CurvePointCount * 2;
     }
 }
 public override void GetTagData(byte[] iccData, int index, ICCHeader header = null)
 {
     ChannelCount = HighEndianReader.GetUInt16(iccData, index, IsLittleEndian);
     ColorantType = (EnumConst.ColorantEncoding)HighEndianReader.GetUInt16(iccData, index + 2, IsLittleEndian);
     if (ColorantType == EnumConst.ColorantEncoding.Unknown)
     {
         ChannelValues = new double[ChannelCount][];
         for (int i = 0; i < ChannelCount; i++)
         {
             ChannelValues[i] = new double[2];
             int startIndex = (index + 4) + i * 8;
             ChannelValues[i][0] = HighEndianReader.GetU16Fixed16NumberToDouble(iccData, startIndex, IsLittleEndian);
             ChannelValues[i][1] = HighEndianReader.GetU16Fixed16NumberToDouble(iccData, startIndex + 4, IsLittleEndian);
         }
     }
     else
     {
         ChannelValues = GetChannelValueByEncoding(ColorantType);
     }
 }
Example #12
0
        public override void GetTagData(byte[] iccData, int index, ICCHeader header)
        {
            //Channel counts (1 byte each)
            InputChannelCount  = iccData[index];
            OutputChannelCount = iccData[index + 1];
            CLUTGridPointCount = iccData[index + 2];
            //1 byte reserved
            //Matrix (4 bytes each)
            Matrix = HighEndianReader.GetMatrix(iccData, index + 4, 3, 3, false, IsLittleEndian);
            //Number of input table entries
            InputTableEntryCount = HighEndianReader.GetUInt16(iccData, index + 40, IsLittleEndian);
            //Number of output table entries
            OutputTableEntryCount = HighEndianReader.GetUInt16(iccData, index + 42, IsLittleEndian);
            //Input
            InputValues = new LUT16[InputChannelCount]; int c = 0;
            for (int i = 0; i < InputChannelCount; i++)
            {
                int dataIndex = InputTableEntryCount * 2 * i + 44 + index;
                InputValues[i] = new LUT16(iccData, dataIndex, InputTableEntryCount, IsLittleEndian);
                c += InputTableEntryCount * 2;
            }
            //CLUT
            int CLUTLength = (int)Math.Pow(CLUTGridPointCount, InputChannelCount) * OutputChannelCount * 2;

            byte[] tmp = new byte[16];
            for (int i = 0; i < 16; i++)
            {
                tmp[i] = CLUTGridPointCount;
            }
            CLUTValues = new CLUT16(iccData, index + 44 + c, InputChannelCount, OutputChannelCount, tmp);
            //Output
            OutputValues = new LUT16[OutputChannelCount];
            c            = 0;
            for (int i = 0; i < OutputChannelCount; i++)
            {
                OutputValues[i] = new LUT16(iccData, CLUTValues.end + c, OutputTableEntryCount, IsLittleEndian);
                c += OutputTableEntryCount * 2;
            }
        }
Example #13
0
 public NamedColor(byte[] iccData, int index, int deviceCoordinateCount, bool isLittleEndian)
 {
     //Root name (32 bytes)
     ColorRootName = HighEndianReader.GetASCII(iccData, index, 32);
     //PCS coordinates (6 bytes) (2 bytes each)
     PCScoordinates    = new ushort[3];
     PCScoordinates[0] = HighEndianReader.GetUInt16(iccData, index + 32, isLittleEndian);
     PCScoordinates[1] = HighEndianReader.GetUInt16(iccData, index + 34, isLittleEndian);
     PCScoordinates[2] = HighEndianReader.GetUInt16(iccData, index + 36, isLittleEndian);
     //Device coordinates (2 bytes each)
     if (deviceCoordinateCount > 0)
     {
         DeviceCoordinates = new ushort[deviceCoordinateCount];
         for (int i = 0; i < 2 * deviceCoordinateCount; i++)
         {
             int dataEntryIndex = index + 38 + i * 2;;
             DeviceCoordinates[i] = HighEndianReader.GetUInt16(iccData, dataEntryIndex, isLittleEndian);
         }
         //int end = (idx + 38) + 2 * deviceCoordinateCount; int c = 0;
         //for (int i = idx + 38; i < end; i++) { DeviceCoordinates[c] = Helper.GetUInt16(i); c++; }
     }
 }
        public CLUT16(byte[] iccData, int index, int inputChannels, int outputChannels, byte[] gridPoint, bool isLittleEndian = false)
        {
            this.InputChannelCount  = inputChannels;
            this.OutputChannelCount = outputChannels;
            this.GridPointCount     = gridPoint;
            //Points
            int l = 0; int k = 0;

            for (int i = 0; i < InputChannelCount; i++)
            {
                l += (int)Math.Pow(GridPointCount[i], InputChannelCount) / InputChannelCount;
            }
            Values = new ushort[l][];
            for (int i = 0; i < l; i++)
            {
                Values[i] = new ushort[OutputChannelCount];
                for (int o = 0; o < OutputChannelCount; o++)
                {
                    Values[i][o] = HighEndianReader.GetUInt16(iccData, index + k, isLittleEndian); k += 2;
                }
            }
            this.end = index + l * OutputChannelCount * 2;
        }
 //internal int end;
 public override void GetTagData(byte[] iccData, int index, ICCHeader header)
 {
     FunctionType = HighEndianReader.GetUInt16(iccData, index, IsLittleEndian);
     //2 bytes reserved
     Curve = new ParametricCurve(FunctionType, iccData, index, IsLittleEndian);
 }