Beispiel #1
0
        internal override void setFromInfoCollection(TiffInfoCollection info)
        {
            base.setFromInfoCollection(info);

            StkInfoCollection allInfo = info as StkInfoCollection;

            if (allInfo == null)
            {
                return;
            }

            List <TiffDirData> dirTemp = new List <TiffDirData>();

            numPlane = allInfo.NumberOfPlanes;

            uint[] uic2 = new uint[6 * numPlane];

            if (allInfo.validUIC2tag())
            {
                for (int i = 0; i < Math.Min(numPlane, allInfo.ZDistance.Length); i++)
                {
                    if (allInfo.ZDistance[i] != null)
                    {
                        Array content = allInfo.ZDistance[i].Data.getContent();
                        if (content == null || content.Length <= 0)
                        {
                            continue;
                        }
                        uint[] temp = (uint[])content;
                        uic2[6 * i]     = temp[0];
                        uic2[6 * i + 1] = temp[1];
                    }
                    else
                    {
                        uic2[6 * i]     = 0;
                        uic2[6 * i + 1] = 0;
                    }
                }
                for (int i = 0; i < Math.Min(numPlane, allInfo.CreationTime.Length); i++)
                {
                    if (allInfo.CreationTime[i] != null)
                    {
                        Array content = allInfo.CreationTime[i].Data.getContent();
                        if (content == null || content.Length <= 0)
                        {
                            continue;
                        }
                        uint[] temp = (uint[])content;
                        uic2[6 * i + 2] = temp[0];
                        uic2[6 * i + 3] = temp[1];
                    }
                    else
                    {
                        uic2[6 * i + 2] = 0;
                        uic2[6 * i + 3] = 0;
                    }
                }
                for (int i = 0; i < Math.Min(numPlane, allInfo.ModifiedTime.Length); i++)
                {
                    if (allInfo.ModifiedTime[i] != null)
                    {
                        Array content = allInfo.ModifiedTime[i].Data.getContent();
                        if (content == null || content.Length <= 0)
                        {
                            continue;
                        }
                        uint[] temp = (uint[])(content);
                        uic2[6 * i + 4] = temp[0];
                        uic2[6 * i + 5] = temp[1];
                    }
                    else
                    {
                        uic2[6 * i + 4] = 0;
                        uic2[6 * i + 5] = 0;
                    }
                }
            }

            UIC2data = new TiffData(TiffData.TIFFdataType.Rational);
            UIC2data.setContent(uic2);
            TiffDirData ddTemp = new TiffDirData();

            ddTemp.Tag  = StkInfoCollection.UIC2Tag;
            ddTemp.Data = new TiffData(TiffData.TIFFdataType.Rational, numPlane);
            dirTemp.Add(ddTemp);


            if (allInfo.validUIC3tag())
            {
                uint[] uic3 = new uint[2 * numPlane];

                for (int i = 0; i < numPlane; i++)
                {
                    if (allInfo.Wavelength[i] != null)
                    {
                        uint[] temp = (uint[])(allInfo.Wavelength[i].Data.getContent());
                        uic3[2 * i]     = temp[0];
                        uic3[2 * i + 1] = temp[1];
                    }
                    else
                    {
                        uic3[2 * i]     = 0;
                        uic3[2 * i + 1] = 0;
                    }
                }
                UIC3data = new TiffData(TiffData.TIFFdataType.Rational);
                UIC3data.setContent(uic3);
                ddTemp      = new TiffDirData();
                ddTemp.Tag  = StkInfoCollection.UIC3Tag;
                ddTemp.Data = new TiffData(TiffData.TIFFdataType.Rational, numPlane);
                dirTemp.Add(ddTemp);
            }

            UIC4data = new SortedList <ushort, TiffData[]>();
            if (allInfo.validUIC4tag())
            {
                ddTemp      = new TiffDirData();
                ddTemp.Tag  = StkInfoCollection.UIC4Tag;
                ddTemp.Data = new TiffData(TiffData.TIFFdataType.Byte, numPlane);
                dirTemp.Add(ddTemp);

                foreach (KeyValuePair <ushort, List <TiffInfo> > pair in allInfo.UIC4DataDeepCopy)
                {
                    if (pair.Value.Count != numPlane)
                    {
                        continue;
                    }
                    TiffData[] temp = new TiffData[numPlane];
                    for (int j = 0; j < numPlane; j++)
                    {
                        temp[j] = (pair.Value)[j].Data;
                    }
                    UIC4data.Add(pair.Key, temp);
                }
            }

            UIC1data = new SortedList <uint, TiffData[]>();
            if (allInfo.validUIC1tag())
            {
                ddTemp     = new TiffDirData();
                ddTemp.Tag = StkInfoCollection.UIC1Tag;
                SortedList <uint, List <TiffInfo> > uic1Copy = allInfo.UIC1DataDeepCopy;
                ddTemp.Data = new TiffData(TiffData.TIFFdataType.Byte, uic1Copy.Count);
                dirTemp.Add(ddTemp);

                foreach (KeyValuePair <uint, List <TiffInfo> > pair in uic1Copy)
                {
                    TiffData[] temp = new TiffData[pair.Value.Count];
                    for (int i = 0; i < pair.Value.Count; i++)
                    {
                        temp[i] = pair.Value[i].Data;
                    }
                    UIC1data.Add(pair.Key, temp);
                }
            }

            TiffDirData[] newDir = new TiffDirData[dirArray.Length + dirTemp.Count];
            for (int i = 0; i < dirArray.Length; i++)
            {
                newDir[i] = dirArray[i];
            }
            for (int i = dirArray.Length; i < newDir.Length; i++)
            {
                newDir[i] = dirTemp[i - dirArray.Length];
            }
            dirArray = newDir;
            Array.Sort(dirArray);
        }