Beispiel #1
0
        public override void GetTagData(byte[] iccData, int index, ICCHeader header)
        {
            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);
            //Input
            InputValues = new LUT8[InputChannelCount]; int c = 0;
            for (int i = 0; i < InputChannelCount; i++)
            {
                int dataIndex = index + 40 + Lut8Length * i;
                InputValues[i] = new LUT8(iccData, dataIndex);;
            }
            //CLUT
            byte[] tmp = new byte[16];

            for (int i = 0; i < 16; i++)
            {
                tmp[i] = CLUTGridPointCount;
            }
            CLUTValues = new CLUT8(iccData, index + 40 + (256 * InputChannelCount), InputChannelCount, OutputChannelCount, tmp, IsLittleEndian);
            //Output
            int clut8Length = (int)Math.Pow(CLUTGridPointCount, InputChannelCount) * OutputChannelCount;

            OutputValues = new LUT8[OutputChannelCount]; c = 0;
            for (int i = 0; i < OutputChannelCount; i++)
            {
                OutputValues[i] = new LUT8(iccData, CLUTValues.end + c);
                c += 256;
            }
        }
Beispiel #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);
            }
        }
        //public MultiLocalizedUnicodeTag(bool isPlaceHolder)
        //{
        //    IsPlaceHolder = isPlaceHolder;
        //}
        public override void GetTagData(byte[] iccData, int index, ICCHeader header)
        {
            if (!IsPlaceHolder)
            {
                //Number of records (4 bytes)
                RecordCount = (int)HighEndianReader.GetUint32(iccData, index, IsLittleEndian);
                //Record size (has to be 12 as for V4.3) (4 bytes)
                RecordSize = (int)HighEndianReader.GetUint32(iccData, index + 4, IsLittleEndian);
                //Records
                LanguageCode = new string[RecordCount];
                CountryCode  = new string[RecordCount];
                StringLength = new int[RecordCount];
                StringOffset = new int[RecordCount];
                //int end = idx + 8 + RecordCount * RecordSize; int c = 0;

                for (int i = 0; i < RecordCount; i++)
                {
                    int dataEntryPoint = index + 8 + RecordSize * i;
                    LanguageCode[i] = HighEndianReader.GetASCII(iccData, dataEntryPoint, 2);
                    //Country Code (2 bytes)
                    CountryCode[i] = HighEndianReader.GetASCII(iccData, dataEntryPoint + 2, 2);
                    //Record string length (4 bytes)
                    StringLength[i] = (int)HighEndianReader.GetUint32(iccData, dataEntryPoint + 4, IsLittleEndian);
                    //Record offset (4 bytes)
                    StringOffset[i] = (int)HighEndianReader.GetUint32(iccData, dataEntryPoint + 8, IsLittleEndian);;
                }
                //The strings
                Text = new LocalizedString[RecordCount];
                for (int i = 0; i < RecordCount; i++)
                {
                    Text[i] = new LocalizedString(LanguageCode[i], CountryCode[i], iccData, index - 8 + StringOffset[i], StringLength[i]);
                }
            }
        }
        private static void GetCurve(byte[] iccData, int Offset, ref ICCTagData[] data, int idx, int InputChannelCount)
        {
            //Signature (4 bytes + 4 bytes reserved)
            TypeSignature t = (TypeSignature)HighEndianReader.GetUint32(iccData, Offset, BitConverter.IsLittleEndian);

            if (t != TypeSignature.curve && t != TypeSignature.parametricCurve)
            {
                return;
            }
            //Curve
            data = new ICCTagData[InputChannelCount];
            int end = idx + Offset;

            for (int i = 0; i < InputChannelCount; i++)
            {
                if (t == TypeSignature.curve)
                {
                    data[i] = new CurveTag();
                    data[i].GetTagData(iccData, idx, null);
                    //end = ((CurveTag)data[i]).end;
                }
                else if (t == TypeSignature.parametricCurve)
                {
                    data[i] = new ParametricCurveTag();
                    data[i].GetTagData(iccData, idx, null);
                    //end = ((ParametricCurveTagDataEntry)data[i]).end;
                }
                end += (end % 4) + 8;
            }
        }
Beispiel #5
0
 public ParametricCurve(ushort type, byte[] iccData, int index, bool isLittleEndian)
 {
     _type      = type;
     g          = HighEndianReader.GetS15Fixed16NumberToDouble(iccData, index, isLittleEndian);
     segmentEnd = index + 4;
     if (type == 1 || type == 2 || type == 3 || type == 4)
     {
         a          = HighEndianReader.GetS15Fixed16NumberToDouble(iccData, segmentEnd, isLittleEndian);
         b          = HighEndianReader.GetS15Fixed16NumberToDouble(iccData, segmentEnd + 4, isLittleEndian);
         segmentEnd = segmentEnd + 4;
     }
     if (type == 2 || type == 3 || type == 4)
     {
         c          = HighEndianReader.GetS15Fixed16NumberToDouble(iccData, segmentEnd, isLittleEndian);
         segmentEnd = segmentEnd + 4;
     }
     if (type == 3 || type == 4)
     {
         d          = HighEndianReader.GetS15Fixed16NumberToDouble(iccData, segmentEnd, isLittleEndian);
         segmentEnd = segmentEnd + 4;
     }
     if (type == 4)
     {
         e = HighEndianReader.GetS15Fixed16NumberToDouble(iccData, segmentEnd, isLittleEndian);
         f = HighEndianReader.GetS15Fixed16NumberToDouble(iccData, segmentEnd + 4, isLittleEndian);
         //segmentEnd = idx + 28;
     }
 }
Beispiel #6
0
        internal static CurveSegment GetCurve(byte[] iccData, int idx)
        {
            //Tag signature (4 bytes) (plus 4 bytes reserved)
            CurveSegment          curve;
            CurveSegmentSignature t = (CurveSegmentSignature)HighEndianReader.GetUint32(iccData, idx);

            if (t == CurveSegmentSignature.FormulaCurve)
            {
                curve = new FormulaCurveElement();
                curve.GetCurveData(iccData, idx + 8, false);

                return(curve);
            }
            else if
            (t == CurveSegmentSignature.SampledCurve)
            {
                curve = new SampledCurveElement();
                curve.GetCurveData(iccData, idx + 8, false);
                return(curve);
            }
            else
            {
                throw new CorruptProfileException("CurveSegment");
            }
        }
Beispiel #7
0
        public override void GetTagData(byte[] iccData, int index, ICCHeader header)
        {
            //Count, specifying number of structures in the array (4 bytes)
            NumberCount = (int)HighEndianReader.GetUint32(iccData, index, IsLittleEndian);
            //Positions table for profile identifiers
            PositionTable = new PositionNumber[NumberCount];
            int dataEntryPoint = 0;;

            for (int i = 0; i < NumberCount; i++)
            {
                dataEntryPoint   = index + 4 + 8 * i;
                PositionTable[i] = new PositionNumber(iccData, i, IsLittleEndian);
            }
            //Profile ID (16 bytes)
            dataEntryPoint += 8;
            ProfileID       = HighEndianReader.GetProfileID(iccData, dataEntryPoint);
            dataEntryPoint += 16;
            //Profile description
            ProfileDescription = new MultiLocalizedUnicodeTag()
            {
                IsPlaceHolder = false
            };
            ProfileDescription.GetTagData(iccData, dataEntryPoint, header);
            //ICCTagData t = new ICCTagData();
        }
        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);
            }
        }
 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;
     }
 }
Beispiel #10
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 GetTagData(byte[] iccData, int index, ICCHeader header)
 {
     UnnomalizedIlluminant = new XYZNumber(iccData, index, IsLittleEndian);
     //Un-normalized CIEXYZ values for surround (12 bytes)
     UnnomalizedSurround = new XYZNumber(iccData, index + 12, IsLittleEndian);
     //Standard illuminant (4 bytes)
     Illuminant = (StandardIlluminant)HighEndianReader.GetUint32(iccData, index + 24, IsLittleEndian);
 }
Beispiel #12
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);
     }
 }
 public XYZNumber(byte[] arr, int index, bool isLittleEndian)
 {
     X   = HighEndianReader.GetS15Fixed16NumberToDouble(arr, index, isLittleEndian);
     Y   = HighEndianReader.GetS15Fixed16NumberToDouble(arr, index + 4, isLittleEndian);
     Z   = HighEndianReader.GetS15Fixed16NumberToDouble(arr, index + 8, isLittleEndian);
     XYZ = new double[3] {
         X, Y, Z
     };
 }
Beispiel #14
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);
        }
 public override void GetTagData(byte[] iccData, int index, ICCHeader header)
 {
     ColorantCount  = HighEndianReader.GetUint32(iccData, index, IsLittleEndian);
     ColorantNumber = new byte[ColorantCount];
     for (int i = 1; i < ColorantCount; i++)
     {
         int startIndex = index + 4 + i;
         ColorantNumber[i] = iccData[startIndex];
     }
 }
Beispiel #16
0
        public override void GetElementData(byte[] iccData, int index, int inputChannel, int outputChannel, bool isLittleEndian)
        {
            this.InputChannelCount  = (ushort)inputChannel;
            this.OutputChannelCount = (ushort)outputChannel;
            //Matrix IxO (4 bytes each)
            MatrixIxO = HighEndianReader.GetMatrix(iccData, index, inputChannel, outputChannel, true, BitConverter.IsLittleEndian);
            //Matrix Ox1 (4 bytes each)

            MatrixOx1 = HighEndianReader.GetMatrix(iccData, index + (4 * inputChannel * outputChannel), outputChannel, true);
        }
        public override void GetTagData(byte[] iccData, int index, ICCHeader header)
        {
            int dataLength = (int)(dataSize - 8) / 4;

            Data = new double[dataLength];
            for (int i = 0; i < dataLength; i++)
            {
                int dataIndex = index + i * 4;
                Data[i] = HighEndianReader.GetU16Fixed16NumberToDouble(iccData, dataIndex, IsLittleEndian);
            }
        }
        public override void GetTagData(byte[] iccData, int index, ICCHeader header)
        {
            int arrayNumber = (int)(dataSize - 8) / 8;

            Data = new UInt64[arrayNumber]; int c = 0;
            for (int i = 0; i < arrayNumber; i++)
            {
                int dataIndex = index + i * 8;
                Data[i] = HighEndianReader.GetUint64(iccData, dataIndex, IsLittleEndian);
            }
        }
Beispiel #19
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)
 {
     Observer = (StandardObserver)HighEndianReader.GetUint32(iccData, index, IsLittleEndian);
     //nCIEXYZ tristimulus values for measurement backing
     XYZBacking = new XYZNumber(iccData, index + 4, IsLittleEndian);
     //Measurement geometry (4 bytes)
     Geometry = (MeasurementGeometry)HighEndianReader.GetUint32(iccData, index, IsLittleEndian);
     //Measurement flare (4 bytes)
     Flare = HighEndianReader.GetU16Fixed16NumberToDouble(iccData, index + 24, IsLittleEndian);
     //Standard illuminant (4 bytes)
     Illuminant = (StandardIlluminant)HighEndianReader.GetUint32(iccData, index + 24, IsLittleEndian);
 }
Beispiel #21
0
        public override void GetTagData(byte[] iccData, int index, ICCHeader header)
        {
            DescriptionCount = (int)HighEndianReader.GetUint32(iccData, index);
            //Profile description structures
            Descriptions = new ProfileDescription[DescriptionCount];
            int end = index + 4;

            for (int i = 0; i < DescriptionCount; i++)
            {
                Descriptions[i] = new ProfileDescription(iccData, end, header); end = Descriptions[i].end;
            }
        }
Beispiel #22
0
 public override void GetCurveData(byte[] iccData, int index, bool isLittleEndian)
 {
     //The number of entries (4 bytes)
     EntryCount = (int)HighEndianReader.GetUint32(iccData, index, BitConverter.IsLittleEndian);
     //Curve entries (4 bytes each)
     CurveEntries = new double[EntryCount];
     end          = index + 4 + 4 * EntryCount;
     for (int i = 0; i < EntryCount; i++)
     {
         int dataEntryPoint = index + 4 + i * 4;
         CurveEntries[i] = HighEndianReader.GetFloat32(iccData, dataEntryPoint, BitConverter.IsLittleEndian);
     }
     LengthInByte = EntryCount * 4 + 4;
 }
 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)
        {
            //Number of Input Channels (1 byte)
            InputChannelCount = iccData[index];
            //Number of Output Channels (1 byte)
            OutputChannelCount = iccData[index + 1];
            //Reserved for padding (2 bytes)
            //Offset to first "B" curve (4 bytes)
            BCurveOffset = (int)HighEndianReader.GetUint32(iccData, index + 4, IsLittleEndian);
            //Offset to matrix (4 bytes)
            MatrixOffset = (int)HighEndianReader.GetUint32(iccData, index + 8, IsLittleEndian);
            MCurveOffset = (int)HighEndianReader.GetUint32(iccData, index + 12, IsLittleEndian);
            //Offset to CLUT (4 bytes)
            CLUTOffset = (int)HighEndianReader.GetUint32(iccData, index + 16, IsLittleEndian);
            //Offset to first "A" curve (4 bytes)
            ACurveOffset = (int)HighEndianReader.GetUint32(iccData, index + 20, IsLittleEndian);

            //Curves
            if (BCurveOffset != 0)
            {
                GetCurve(iccData, ACurveOffset, ref curveB, index, InputChannelCount);
            }
            if (MCurveOffset != 0)
            {
                GetCurve(iccData, ACurveOffset, ref curveM, index, InputChannelCount);
            }
            if (CLUTOffset != 0)
            {
                CLUTValues = CLUT.GetCLUT(iccData, index - 8 + CLUTOffset, false, InputChannelCount, OutputChannelCount);
            }
            if (ACurveOffset != 0)
            {
                GetCurve(iccData, ACurveOffset, ref curveA, index, InputChannelCount);
            }

            //Matrix
            if (MatrixOffset != 0)
            {
                int i = MatrixOffset + index - 8;
                //Matrix 3x3 (4 bytes each)
                Matrix3x3 = HighEndianReader.GetMatrix(iccData, 3, 3, i, false, IsLittleEndian);
                //Matrix 3x1 (4 bytes each)
                Matrix3x1 = HighEndianReader.GetMatrix(iccData, 3, i + 36, false, 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);
     }
 }
Beispiel #27
0
        public override void GetTagData(byte[] iccData, int index, ICCHeader header)
        {
            VendorSpecFlag = iccData.Get(index, index + 4);
            //VendorSpecFlag =  new byte[] { ICCProfile.DataBytes[idx], ICCProfile.DataBytes[idx + 1], ICCProfile.DataBytes[idx + 2], ICCProfile.DataBytes[idx + 3] };
            //Count of named colours (4 bytes)
            NamedColorCount = (int)HighEndianReader.GetUint32(iccData, index + 4, IsLittleEndian);
            //Number of device coordinates (4 bytes)
            DeviceCoordinateCount = (int)HighEndianReader.GetUint32(iccData, index + 8, IsLittleEndian);
            //Prefix for each colour name
            Prefix = HighEndianReader.GetASCII(iccData, index + 12, 32);
            //Suffix for each colour name
            Suffix = HighEndianReader.GetASCII(iccData, index + 44, 32);
            //Colors
            NamedColors = new NamedColor[NamedColorCount];

            for (int i = 0; i < NamedColorCount; i++)
            {
                int dataEntryIndex = index + 76 + (38 + 2 * DeviceCoordinateCount) * i;
                NamedColors[i] = new NamedColor(iccData, dataEntryIndex, DeviceCoordinateCount, IsLittleEndian);;
            }
        }
Beispiel #28
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;
            }
        }
Beispiel #29
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++; }
     }
 }
        internal ResponseCurve(byte[] iccData, int idx, int ChannelCount, bool isLittleEndian)
        {
            int dataEntryPoint = 0;

            //Measurement unit signature (4 bytes)
            CurveType = (CurveMeasurementEncodings)HighEndianReader.GetUint32(iccData, idx, isLittleEndian);
            //Counts of measurements in response arrays
            MeasurmentCounts = new int[ChannelCount];
            //int end = idx + 4 + 4 * ChannelCount; int c = 0;
            //for (int i = idx + 4; i < end; i += 4)
            //{ MeasurmentCounts[c] = (int)Helper.GetUInt32(i); c++; }

            for (int i = 0; i < ChannelCount; i++)
            {
                dataEntryPoint      = idx + 4 + i * 4;
                MeasurmentCounts[i] = (int)HighEndianReader.GetUint32(iccData, dataEntryPoint, isLittleEndian);
            }
            //PCSXYZ values
            XYZvalues = new XYZNumber[ChannelCount];
            for (int i = 0; i < ChannelCount; i++)
            {
                dataEntryPoint = idx + 4 + ChannelCount * 4 + i * 4;
                XYZvalues[i]   = new XYZNumber(iccData, dataEntryPoint, isLittleEndian);
            }
            //int start = end; end += 12 * ChannelCount; c = 0;
            //for (int i = start; i < end; i += 12) { XYZvalues[c] = new XYZNumber(i); c++; }
            //Response arrays
            int p = MeasurmentCounts.Sum();

            ResponseArrays = new Response16Number[p];
            for (int i = 0; i < p; i++)
            {
                dataEntryPoint   += 8;
                ResponseArrays[i] = new Response16Number(iccData, dataEntryPoint, isLittleEndian);
            }
            //start = end; end += 8 * p; c = 0;
            //for (int i = start; i < end; i += 8) { ResponseArrays[c] = new Response16Number(i); c++; }
        }