示例#1
0
        /// <summary>
        /// Read image flags from the file
        /// </summary>
        public void ReadFlags(BufferReader reader, int offset)
        {
            CalibRange_min = reader.ReadSingleBE(offset + 92);
            CalibRange_max = reader.ReadSingleBE(offset + 96);


            Device           = reader.ReadNullTerminatedString(offset + 142, 12);
            DeviceSerial     = reader.ReadNullTerminatedString(offset + 186, 16);
            Optics           = reader.ReadNullTerminatedString(offset + 202, 32);
            OpticsResolution = reader.ReadNullTerminatedString(offset + 234, 32);
            OpticsText       = reader.ReadNullTerminatedString(offset + 554, 48);

            ShotRange_start_ERROR = reader.ReadSingleBE(offset + 532);
            ShotRange_size        = reader.ReadSingleBE(offset + 536);


            TimeStamp_Raw         = reader.ReadDoubleBE(8, offset + 540);
            TimeStampMilliseconds = reader.ReadIntBE(offset + 548);

            TimeStamp = Double2DateTime(TimeStamp_Raw, TimeStampMilliseconds);
        }
示例#2
0
        /// <summary>
        /// Read the image data from file
        /// </summary>
        /// <returns></returns>
        private float[] ReadImageData(BufferReader reader, int bindata_offset, int width, int height, int palette_offset, int useCompression)
        {
            int  data_size = width * height; //- count of pixles
            bool useComp   = (useCompression == 1);

            int pixelCount = data_size;

            float[] matrixData = new float[pixelCount];

            int matrixDataPos = 0;

            int v1_pos = bindata_offset;
            int v2_pos = v1_pos + width * height; //- used if data are compressed

            //byte data_v1 = &bindata[v1_pos];
            //unsigned char* data_v2 = &bindata[v2_pos];

            int v1 = 0;
            int v2 = 0;


            float[] Palette = ReadPallet(reader, palette_offset);


            int   v2_count = 0;
            float v        = 0;
            float f;


            if (!useComp)
            {
                for (int i = pixelCount; i > 0; i--)
                {
                    //- read values
                    v1 = reader.ReadByte(v1_pos);
                    v1_pos++;
                    v2 = reader.ReadByte(v1_pos);
                    v1_pos++;

                    f = (float)v1 * (1.0f / 256.0f);

                    //- lineare interpolation
                    v = Palette[v2 + 1] * f + Palette[v2] * (1.0f - f);

                    if (v < 0)
                    {
                        v = 0;        //- oder 255
                    }
                    matrixData[matrixDataPos] = v;
                    matrixDataPos++;
                }
            }
            else
            {
                for (int i = pixelCount; i > 0; i--)
                {
                    //- werte lesen
                    if (v2_count-- < 1) //- ok... neuen wert für V2 lesen
                    {
                        v2_count = reader.ReadByte(v2_pos) - 1;
                        v2_pos++;

                        v2 = reader.ReadByte(v2_pos);
                        v2_pos++;
                    }

                    v1 = reader.ReadByte(v1_pos);
                    v1_pos++;

                    f = (float)v1 * (1.0f / 256.0f);

                    //- lineare interpolation
                    v = Palette[v2 + 1] * f + Palette[v2] * (1.0f - f);

                    if (v < 0)
                    {
                        v = 0;        //- oder 255
                    }
                    matrixData[matrixDataPos] = v;
                    matrixDataPos++;
                }
            }

            return(matrixData);
        }
示例#3
0
        /// <summary>
        /// Read a image from the file
        /// </summary>
        public bool ReadImage(int imageIndex)
        {
            System.DateTime FrameTime = System.DateTime.Now;


            var reader = new BufferReader(this.reader.GetImageData(imageIndex));

            if (reader.Eof)
            {
                return(false);
            }

            Width  = 0;
            Height = 0;


            //- Image header
            BytePerPixel = reader.ReadWordBE();
            Compressed   = reader.ReadWordBE();
            Width        = reader.ReadWordBE();
            Height       = reader.ReadWordBE();


            reader.ReadIntBE();  //-- don't know - alway 0
            reader.ReadWordBE(); //-- don't know - alway 0

            //- dont know why but it is alwasy the width -1
            if (reader.ReadWordBE() != (Width - 1))
            {
                logging.addError("??? value != (Height - 1)");
            }


            reader.ReadWordBE(); //-- don't know - alway 0

            //- dont know why but it is alwasy the height -1
            if (reader.ReadWordBE() != (Height - 1))
            {
                logging.addError("??? value != (Height - 1)");
            }


            reader.ReadWordBE(); //-- don't know - alway 0
            reader.ReadWordBE(); //-- don't know - alway 0

            Emissivity = reader.ReadSingleBE();

            Distanz = reader.ReadSingleBE();

            EnvironmentalTemp = reader.ReadSingleBE();


            reader.ReadWordBE(); //-- don't know - always 0
            reader.ReadWordBE(); //-- don't know - always 0

            PathTemperature = reader.ReadSingleBE();

            reader.ReadWordBE(); //-- don't know - always 0x65
            reader.ReadWordBE(); //-- don't know - always 0


            CenterWavelength = reader.ReadSingleBE();


            reader.ReadWordBE(); //-- don't know - always 0
            reader.ReadWordBE(); //-- don't know - always 0xH4080
            reader.ReadWordBE(); //-- don't know - always 0x9
            reader.ReadWordBE(); //-- don't know - always 0x101


            if ((Width > 10000) || (Height > 10000))
            {
                logging.addError("Defect Irbis Image File: Image Width(" + Width + ") or Height(" + Height + ") is out of range!");
                Width  = 1;
                Height = 1;
                return(false);
            }

            //- liest weitere Bildinforationen aus
            this.ReadFlags(reader, 1084);

            Data = ReadImageData(reader, 0x6C0, Width, Height, 60, Compressed);



            if (reader.Eof)
            {
                logging.addError("end of file!");
            }

            return(true);
        }