コード例 #1
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;
     }
 }
コード例 #3
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;
 }
コード例 #4
0
        public CLUTf32(byte[] iccData, int idx, int InputChannelCount, int OutputChannelCount, byte[] GridPointCount, bool isLittleEndian)
        {
            this.InputChannelCount  = InputChannelCount;
            this.OutputChannelCount = OutputChannelCount;
            this.GridPointCount     = GridPointCount;
            //Points
            int l = 0; int k = 0;

            for (int i = 0; i < InputChannelCount; i++)
            {
                l += (int)Math.Pow(GridPointCount[i], InputChannelCount) / InputChannelCount;
            }
            Values = new double[l][];
            for (int i = 0; i < l; i++)
            {
                Values[i] = new double[OutputChannelCount];
                for (int o = 0; o < OutputChannelCount; o++)
                {
                    Values[i][o] = HighEndianReader.GetFloat32(iccData, idx + k, isLittleEndian); k += 4;
                }
            }
            this.end = idx + l * OutputChannelCount * 4;
        }