public override void read(laszip_point item)
		{
			for(uint i=0; i<number; i++)
			{
				last_item[i]=item.extra_bytes[i]=(byte)(ic_byte.decompress(last_item[i], i));
			}
		}
Ejemplo n.º 2
0
 public override void read(laszip_point item)
 {
     if (instream.Read(item.extra_bytes, 0, (int)number) != (int)number)
     {
         throw new EndOfStreamException();
     }
 }
		public unsafe override bool init(laszip_point item)
		{
			// init state
			last_diff_32=0;
			sym_last_offset_diff=0;

			// init models and integer compressors
			dec.initSymbolModel(m_packet_index);
			dec.initSymbolModel(m_offset_diff[0]);
			dec.initSymbolModel(m_offset_diff[1]);
			dec.initSymbolModel(m_offset_diff[2]);
			dec.initSymbolModel(m_offset_diff[3]);
			ic_offset_diff.initDecompressor();
			ic_packet_size.initDecompressor();
			ic_return_point.initDecompressor();
			ic_xyz.initDecompressor();

			// init last item
			fixed(byte* pItem=item.wave_packet)
			{
				last_item=*(LASwavepacket13*)(pItem+1);
			}

			return true;
		}
        public unsafe override bool init(laszip_point item)
        {
            // init state
            last_diff_32         = 0;
            sym_last_offset_diff = 0;

            // init models and integer compressors
            enc.initSymbolModel(m_packet_index);
            enc.initSymbolModel(m_offset_diff[0]);
            enc.initSymbolModel(m_offset_diff[1]);
            enc.initSymbolModel(m_offset_diff[2]);
            enc.initSymbolModel(m_offset_diff[3]);
            ic_offset_diff.initCompressor();
            ic_packet_size.initCompressor();
            ic_return_point.initCompressor();
            ic_xyz.initCompressor();

            // init last item
            fixed(byte *pItem = item.wave_packet)
            {
                last_item = *(LASwavepacket13 *)(pItem + 1);
            }

            return(true);
        }
		public override bool init(laszip_point item)
		{
			// init state
			last_x_diff[0]=last_x_diff[1]=last_x_diff[2]=0;
			last_y_diff[0]=last_y_diff[1]=last_y_diff[2]=0;
			last_incr=0;

			// init models and integer compressors
			ic_dx.initDecompressor();
			ic_dy.initDecompressor();
			ic_z.initDecompressor();
			ic_intensity.initDecompressor();
			ic_scan_angle_rank.initDecompressor();
			ic_point_source_ID.initDecompressor();
			dec.initSymbolModel(m_changed_values);
			for(int i=0; i<256; i++)
			{
				if(m_bit_byte[i]!=null) dec.initSymbolModel(m_bit_byte[i]);
				if(m_classification[i]!=null) dec.initSymbolModel(m_classification[i]);
				if(m_user_data[i]!=null) dec.initSymbolModel(m_user_data[i]);
			}

			// init last item
			last.x=item.X;
			last.y=item.Y;
			last.z=item.Z;
			last.intensity=item.intensity;
			last.flags=item.flags;
			last.classification=item.classification;
			last.scan_angle_rank=item.scan_angle_rank;
			last.user_data=item.user_data;
			last.point_source_ID=item.point_source_ID;

			return true;
		}
Ejemplo n.º 6
0
        public unsafe override bool write(laszip_point item)
        {
            fixed(byte *pBuffer = buffer)
            {
                LAStempWritePoint10 *p10 = (LAStempWritePoint10 *)pBuffer;

                p10->x               = item.X;
                p10->y               = item.Y;
                p10->z               = item.Z;
                p10->intensity       = item.intensity;
                p10->flags           = item.flags;
                p10->classification  = item.classification;
                p10->scan_angle_rank = item.scan_angle_rank;
                p10->user_data       = item.user_data;
                p10->point_source_ID = item.point_source_ID;
            }

            try
            {
                outstream.Write(buffer, 0, 20);
            }
            catch
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 7
0
 public override void read(laszip_point item)
 {
     if (instream.Read(item.wave_packet, 0, 29) != 29)
     {
         throw new EndOfStreamException();
     }
 }
Ejemplo n.º 8
0
        public bool write(laszip_point point)
        {
            if (chunk_count == chunk_size)
            {
                enc.done();
                add_chunk_to_table();
                init(outstream);
                chunk_count = 0;
            }
            chunk_count++;

            if (writers != null)
            {
                for (uint i = 0; i < num_writers; i++)
                {
                    writers[i].write(point);
                }
            }
            else
            {
                for (uint i = 0; i < num_writers; i++)
                {
                    writers_raw[i].write(point);
                    ((LASwriteItemCompressed)(writers_compressed[i])).init(point);
                }
                writers = writers_compressed;
                enc.init(outstream);
            }

            return(true);
        }
Ejemplo n.º 9
0
 public override void read(laszip_point item)
 {
     for (uint i = 0; i < number; i++)
     {
         last_item[i] = item.extra_bytes[i] = (byte)(ic_byte.decompress(last_item[i], i));
     }
 }
		public override bool init(laszip_point item)
		{
			// init state
			last=0; next=0;
			last_gpstime_diff[0]=0;
			last_gpstime_diff[1]=0;
			last_gpstime_diff[2]=0;
			last_gpstime_diff[3]=0;
			multi_extreme_counter[0]=0;
			multi_extreme_counter[1]=0;
			multi_extreme_counter[2]=0;
			multi_extreme_counter[3]=0;

			// init models and integer compressors
			dec.initSymbolModel(m_gpstime_multi);
			dec.initSymbolModel(m_gpstime_0diff);
			ic_gpstime.initDecompressor();

			// init last item
			last_gpstime[0].f64=item.gps_time;
			last_gpstime[1].u64=0;
			last_gpstime[2].u64=0;
			last_gpstime[3].u64=0;
			return true;
		}
Ejemplo n.º 11
0
		public unsafe override bool write(laszip_point item)
		{
			fixed(byte* pBuffer=buffer)
			{
				LAStempWritePoint10* p10=(LAStempWritePoint10*)pBuffer;
				p10->x=item.X;
				p10->y=item.Y;
				p10->z=item.Z;
				p10->intensity=item.intensity;
				p10->flags=item.flags;
				p10->classification=item.classification;
				p10->scan_angle_rank=item.scan_angle_rank;
				p10->user_data=item.user_data;
				p10->point_source_ID=item.point_source_ID;
			}

			try
			{
				outstream.Write(buffer, 0, 20);
			}
			catch
			{
				return false;
			}

			return true;
		}
Ejemplo n.º 12
0
		public override void read(laszip_point item)
		{
			byte[] buf=new byte[6];
			if(instream.Read(buf, 0, 6)!=6) throw new EndOfStreamException();
			item.rgb[0]=BitConverter.ToUInt16(buf, 0);
			item.rgb[1]=BitConverter.ToUInt16(buf, 2);
			item.rgb[2]=BitConverter.ToUInt16(buf, 4);
		}
Ejemplo n.º 13
0
        public override void read(laszip_point item)
        {
            if (instream.Read(buffer, 0, 8) != 8)
            {
                throw new EndOfStreamException();
            }

            item.gps_time = BitConverter.ToDouble(buffer, 0);
        }
		public override void read(laszip_point item)
		{
			for(uint i=0; i<number; i++)
			{
				int value=(int)(last_item[i]+dec.decodeSymbol(m_byte[i]));
				item.extra_bytes[i]=(byte)MyDefs.U8_FOLD(value);
			}

			Buffer.BlockCopy(item.extra_bytes, 0, last_item, 0, (int)number);
		}
        public override void read(laszip_point item)
        {
            for (uint i = 0; i < number; i++)
            {
                int value = (int)(last_item[i] + dec.decodeSymbol(m_byte[i]));
                item.extra_bytes[i] = (byte)MyDefs.U8_FOLD(value);
            }

            Buffer.BlockCopy(item.extra_bytes, 0, last_item, 0, (int)number);
        }
Ejemplo n.º 16
0
 public override void read(laszip_point item)
 {
     byte[] buf = new byte[6];
     if (instream.Read(buf, 0, 6) != 6)
     {
         throw new EndOfStreamException();
     }
     item.rgb[0] = BitConverter.ToUInt16(buf, 0);
     item.rgb[1] = BitConverter.ToUInt16(buf, 2);
     item.rgb[2] = BitConverter.ToUInt16(buf, 4);
 }
		public override bool write(laszip_point item)
		{
			for(uint i=0; i<number; i++)
			{
				int diff=item.extra_bytes[i]-last_item[i];
				enc.encodeSymbol(m_byte[i], (byte)MyDefs.U8_FOLD(diff));
			}

			Buffer.BlockCopy(item.extra_bytes, 0, last_item, 0, (int)number);
			return true;
		}
Ejemplo n.º 18
0
        public override bool write(laszip_point item)
        {
            for (uint i = 0; i < number; i++)
            {
                int diff = item.extra_bytes[i] - last_item[i];
                enc.encodeSymbol(m_byte[i], (byte)MyDefs.U8_FOLD(diff));
            }

            Buffer.BlockCopy(item.extra_bytes, 0, last_item, 0, (int)number);
            return(true);
        }
		public override bool init(laszip_point item)
		{
			// init state

			// init models and integer compressors
			ic_byte.initDecompressor();

			// init last item
			Buffer.BlockCopy(item.extra_bytes, 0, last_item, 0, (int)number);

			return true;
		}
Ejemplo n.º 20
0
        public override bool init(laszip_point item)
        {
            // init state

            // init models and integer compressors
            ic_byte.initDecompressor();

            // init last item
            Buffer.BlockCopy(item.extra_bytes, 0, last_item, 0, (int)number);

            return(true);
        }
Ejemplo n.º 21
0
        public unsafe override void read(laszip_point item)
        {
            if (instream.Read(buffer, 0, 30) != 30)
                throw new EndOfStreamException();

            fixed(byte *pBuffer = buffer)
            {
                LAStempReadPoint14 *p14 = (LAStempReadPoint14 *)pBuffer;

                item.X         = p14->x;
                item.Y         = p14->y;
                item.Z         = p14->z;
                item.intensity = p14->intensity;
                if (p14->number_of_returns_of_given_pulse > 7)
                {
                    if (p14->return_number > 6)
                    {
                        if (p14->return_number >= p14->number_of_returns_of_given_pulse)
                        {
                            item.number_of_returns_of_given_pulse = 7;
                        }
                        else
                        {
                            item.number_of_returns_of_given_pulse = 6;
                        }
                    }
                    else
                    {
                        item.return_number = p14->return_number;
                    }
                    item.number_of_returns_of_given_pulse = 7;
                }
                else
                {
                    item.return_number = p14->return_number;
                    item.number_of_returns_of_given_pulse = p14->number_of_returns_of_given_pulse;
                }
                item.scan_direction_flag                       = p14->scan_direction_flag;
                item.edge_of_flight_line                       = p14->edge_of_flight_line;
                item.classification                            = (byte)((p14->classification_flags << 5) | (p14->classification & 31));
                item.scan_angle_rank                           = MyDefs.I8_CLAMP(MyDefs.I16_QUANTIZE(p14->scan_angle * 0.006));
                item.user_data                                 = p14->user_data;
                item.point_source_ID                           = p14->point_source_ID;
                item.extended_scanner_channel                  = p14->scanner_channel;
                item.extended_classification_flags             = (byte)(p14->classification_flags & 8); // TODO Häää?
                item.extended_classification                   = p14->classification;
                item.extended_return_number                    = p14->return_number;
                item.extended_number_of_returns_of_given_pulse = p14->number_of_returns_of_given_pulse;
                item.extended_scan_angle                       = p14->scan_angle;
                item.gps_time = p14->gps_time;
            }
        }
Ejemplo n.º 22
0
        public override bool write(laszip_point item)
        {
            try
            {
                outstream.Write(BitConverter.GetBytes(item.gps_time), 0, 8);
            }
            catch
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 23
0
		public override bool write(laszip_point item)
		{
			try
			{
				outstream.Write(BitConverter.GetBytes(item.gps_time), 0, 8);
			}
			catch
			{
				return false;
			}

			return true;
		}
Ejemplo n.º 24
0
		public unsafe override void read(laszip_point item)
		{
			if(instream.Read(buffer, 0, 30)!=30) throw new EndOfStreamException();

			fixed(byte* pBuffer=buffer)
			{
				LAStempReadPoint14* p14=(LAStempReadPoint14*)pBuffer;

				item.X=p14->x;
				item.Y=p14->y;
				item.Z=p14->z;
				item.intensity=p14->intensity;
				if(p14->number_of_returns_of_given_pulse>7)
				{
					if(p14->return_number>6)
					{
						if(p14->return_number>=p14->number_of_returns_of_given_pulse)
						{
							item.number_of_returns_of_given_pulse=7;
						}
						else
						{
							item.number_of_returns_of_given_pulse=6;
						}
					}
					else
					{
						item.return_number=p14->return_number;
					}
					item.number_of_returns_of_given_pulse=7;
				}
				else
				{
					item.return_number=p14->return_number;
					item.number_of_returns_of_given_pulse=p14->number_of_returns_of_given_pulse;
				}
				item.scan_direction_flag=p14->scan_direction_flag;
				item.edge_of_flight_line=p14->edge_of_flight_line;
				item.classification=(byte)((p14->classification_flags<<5)|(p14->classification&31));
				item.scan_angle_rank=MyDefs.I8_CLAMP(MyDefs.I16_QUANTIZE(p14->scan_angle*0.006));
				item.user_data=p14->user_data;
				item.point_source_ID=p14->point_source_ID;
				item.extended_scanner_channel=p14->scanner_channel;
				item.extended_classification_flags=(byte)(p14->classification_flags&8); // TODO Häää?
				item.extended_classification=p14->classification;
				item.extended_return_number=p14->return_number;
				item.extended_number_of_returns_of_given_pulse=p14->number_of_returns_of_given_pulse;
				item.extended_scan_angle=p14->scan_angle;
				item.gps_time=p14->gps_time;
			}
		}
        public unsafe override bool write(laszip_point item)
        {
            enc.encodeSymbol(m_packet_index, item.wave_packet[0]);

            fixed(byte *pItem = item.wave_packet)
            {
                LASwavepacket13 *wave = (LASwavepacket13 *)(pItem + 1);

                // calculate the difference between the two offsets
                long curr_diff_64 = (long)(wave->offset - last_item.offset);
                int  curr_diff_32 = (int)curr_diff_64;

                // if the current difference can be represented with 32 bits
                if (curr_diff_64 == (long)(curr_diff_32))
                {
                    if (curr_diff_32 == 0)                  // current difference is zero
                    {
                        enc.encodeSymbol(m_offset_diff[sym_last_offset_diff], 0);
                        sym_last_offset_diff = 0;
                    }
                    else if (curr_diff_32 == (int)last_item.packet_size)                  // current difference is size of last packet
                    {
                        enc.encodeSymbol(m_offset_diff[sym_last_offset_diff], 1);
                        sym_last_offset_diff = 1;
                    }
                    else                     //
                    {
                        enc.encodeSymbol(m_offset_diff[sym_last_offset_diff], 2);
                        sym_last_offset_diff = 2;
                        ic_offset_diff.compress(last_diff_32, curr_diff_32);
                        last_diff_32 = curr_diff_32;
                    }
                }
                else
                {
                    enc.encodeSymbol(m_offset_diff[sym_last_offset_diff], 3);
                    sym_last_offset_diff = 3;
                    enc.writeInt64(wave->offset);
                }

                ic_packet_size.compress((int)last_item.packet_size, (int)wave->packet_size);
                ic_return_point.compress(last_item.return_point.i32, wave->return_point.i32);
                ic_xyz.compress(last_item.x.i32, wave->x.i32, 0);
                ic_xyz.compress(last_item.y.i32, wave->y.i32, 1);
                ic_xyz.compress(last_item.z.i32, wave->z.i32, 2);

                last_item = *wave;
            }

            return(true);
        }
Ejemplo n.º 26
0
        public unsafe override bool write(laszip_point item)
        {
            fixed(byte *pBuffer = buffer)
            {
                LAStempWritePoint14 *p14 = (LAStempWritePoint14 *)pBuffer;

                p14->x                   = item.X;
                p14->y                   = item.Y;
                p14->z                   = item.Z;
                p14->intensity           = item.intensity;
                p14->scan_direction_flag = item.scan_direction_flag;
                p14->edge_of_flight_line = item.edge_of_flight_line;
                p14->classification      = (byte)(item.classification & 31);
                p14->user_data           = item.user_data;
                p14->point_source_ID     = item.point_source_ID;

                if (item.extended_point_type != 0)
                {
                    p14->classification_flags = (byte)(item.extended_classification_flags | (item.classification >> 5));
                    if (item.extended_classification > 31)
                    {
                        p14->classification = item.extended_classification;
                    }
                    p14->scanner_channel = item.extended_scanner_channel;
                    p14->return_number   = item.extended_return_number;
                    p14->number_of_returns_of_given_pulse = item.extended_number_of_returns_of_given_pulse;
                    p14->scan_angle = item.extended_scan_angle;
                }
                else
                {
                    p14->classification_flags             = (byte)(item.classification >> 5);
                    p14->scanner_channel                  = 0;
                    p14->return_number                    = item.return_number;
                    p14->number_of_returns_of_given_pulse = item.number_of_returns_of_given_pulse;
                    p14->scan_angle = MyDefs.I16_QUANTIZE(item.scan_angle_rank / 0.006f);
                }

                p14->gps_time = item.gps_time;
            }

            try
            {
                outstream.Write(buffer, 0, 30);
            }
            catch
            {
                return(false);
            }

            return(true);
        }
        public override bool init(laszip_point item)
        {
            // init state
            for (int i = 0; i < 16; i++)
            {
                last_x_diff_median5[i].init();
                last_y_diff_median5[i].init();
                last_intensity[i]  = 0;
                last_height[i / 2] = 0;
            }

            // init models and integer compressors
            ic_dx.initDecompressor();
            ic_dy.initDecompressor();
            ic_z.initDecompressor();
            ic_intensity.initDecompressor();
            dec.initSymbolModel(m_scan_angle_rank[0]);
            dec.initSymbolModel(m_scan_angle_rank[1]);
            ic_point_source_ID.initDecompressor();
            dec.initSymbolModel(m_changed_values);
            for (int i = 0; i < 256; i++)
            {
                if (m_bit_byte[i] != null)
                {
                    dec.initSymbolModel(m_bit_byte[i]);
                }
                if (m_classification[i] != null)
                {
                    dec.initSymbolModel(m_classification[i]);
                }
                if (m_user_data[i] != null)
                {
                    dec.initSymbolModel(m_user_data[i]);
                }
            }

            // init last item
            last.x               = item.X;
            last.y               = item.Y;
            last.z               = item.Z;
            last.intensity       = 0;     // but set intensity to zero
            last.flags           = item.flags;
            last.classification  = item.classification;
            last.scan_angle_rank = item.scan_angle_rank;
            last.user_data       = item.user_data;
            last.point_source_ID = item.point_source_ID;

            return(true);
        }
        public override bool init(laszip_point item)
        {
            // init state

            // init models and integer compressors
            dec.initSymbolModel(m_byte_used);
            ic_rgb.initDecompressor();

            // init last item
            r = item.rgb[0];
            g = item.rgb[1];
            b = item.rgb[2];

            return(true);
        }
Ejemplo n.º 29
0
        public override bool write(laszip_point item)
        {
            try
            {
                outstream.Write(BitConverter.GetBytes(item.rgb[0]), 0, 2);
                outstream.Write(BitConverter.GetBytes(item.rgb[1]), 0, 2);
                outstream.Write(BitConverter.GetBytes(item.rgb[2]), 0, 2);
            }
            catch
            {
                return(false);
            }

            return(true);
        }
		public override bool init(laszip_point item)
		{
			// init state

			// init models and integer compressors
			for(uint i=0; i<number; i++)
			{
				enc.initSymbolModel(m_byte[i]);
			}

			// init last item
			Buffer.BlockCopy(item.extra_bytes, 0, last_item, 0, (int)number);

			return true;
		}
Ejemplo n.º 31
0
        public override bool init(laszip_point item)
        {
            // init state

            // init models and integer compressors
            for (uint i = 0; i < number; i++)
            {
                enc.initSymbolModel(m_byte[i]);
            }

            // init last item
            Buffer.BlockCopy(item.extra_bytes, 0, last_item, 0, (int)number);

            return(true);
        }
Ejemplo n.º 32
0
		public unsafe override bool write(laszip_point item)
		{
			fixed(byte* pBuffer=buffer)
			{
				LAStempWritePoint14* p14=(LAStempWritePoint14*)pBuffer;

				p14->x=item.X;
				p14->y=item.Y;
				p14->z=item.Z;
				p14->intensity=item.intensity;
				p14->scan_direction_flag=item.scan_direction_flag;
				p14->edge_of_flight_line=item.edge_of_flight_line;
				p14->classification=(byte)(item.classification&31);
				p14->user_data=item.user_data;
				p14->point_source_ID=item.point_source_ID;

				if(item.extended_point_type!=0)
				{
					p14->classification_flags=(byte)(item.extended_classification_flags|(item.classification>>5));
					if(item.extended_classification>31) p14->classification=item.extended_classification;
					p14->scanner_channel=item.extended_scanner_channel;
					p14->return_number=item.extended_return_number;
					p14->number_of_returns_of_given_pulse=item.extended_number_of_returns_of_given_pulse;
					p14->scan_angle=item.extended_scan_angle;
				}
				else
				{
					p14->classification_flags=(byte)(item.classification>>5);
					p14->scanner_channel=0;
					p14->return_number=item.return_number;
					p14->number_of_returns_of_given_pulse=item.number_of_returns_of_given_pulse;
					p14->scan_angle=MyDefs.I16_QUANTIZE(item.scan_angle_rank/0.006f);
				}

				p14->gps_time=item.gps_time;
			}

			try
			{
				outstream.Write(buffer, 0, 30);
			}
			catch
			{
				return false;
			}

			return true;
		}
Ejemplo n.º 33
0
		public override bool write(laszip_point item)
		{
			try
			{
				outstream.Write(BitConverter.GetBytes(item.rgb[0]), 0, 2);
				outstream.Write(BitConverter.GetBytes(item.rgb[1]), 0, 2);
				outstream.Write(BitConverter.GetBytes(item.rgb[2]), 0, 2);
				outstream.Write(BitConverter.GetBytes(item.rgb[3]), 0, 2);
			}
			catch
			{
				return false;
			}

			return true;
		}
        public override bool init(laszip_point item)
        {
            // init state
            last_gpstime_diff     = 0;
            multi_extreme_counter = 0;

            // init models and integer compressors
            dec.initSymbolModel(m_gpstime_multi);
            dec.initSymbolModel(m_gpstime_0diff);
            ic_gpstime.initDecompressor();

            // init last item
            last_gpstime.f64 = item.gps_time;

            return(true);
        }
		public override bool init(laszip_point item)
		{
			// init state
			last_gpstime_diff=0;
			multi_extreme_counter=0;

			// init models and integer compressors
			dec.initSymbolModel(m_gpstime_multi);
			dec.initSymbolModel(m_gpstime_0diff);
			ic_gpstime.initDecompressor();

			// init last item
			last_gpstime.f64=item.gps_time;

			return true;
		}
		public override bool init(laszip_point item)
		{
			// init state

			// init models and integer compressors
			enc.initSymbolModel(m_byte_used);
			enc.initSymbolModel(m_rgb_diff_0);
			enc.initSymbolModel(m_rgb_diff_1);
			enc.initSymbolModel(m_rgb_diff_2);
			enc.initSymbolModel(m_rgb_diff_3);
			enc.initSymbolModel(m_rgb_diff_4);
			enc.initSymbolModel(m_rgb_diff_5);

			// init last item
			Buffer.BlockCopy(item.rgb, 0, last_item, 0, 6);
			return true;
		}
Ejemplo n.º 37
0
        public override bool init(laszip_point item)
        {
            // init state

            // init models and integer compressors
            enc.initSymbolModel(m_byte_used);
            enc.initSymbolModel(m_rgb_diff_0);
            enc.initSymbolModel(m_rgb_diff_1);
            enc.initSymbolModel(m_rgb_diff_2);
            enc.initSymbolModel(m_rgb_diff_3);
            enc.initSymbolModel(m_rgb_diff_4);
            enc.initSymbolModel(m_rgb_diff_5);

            // init last item
            Buffer.BlockCopy(item.rgb, 0, last_item, 0, 6);
            return(true);
        }
Ejemplo n.º 38
0
		public unsafe override void read(laszip_point item)
		{
			if(instream.Read(buffer, 0, 20)!=20) throw new EndOfStreamException();

			fixed(byte* pBuffer=buffer)
			{
				LAStempReadPoint10* p10=(LAStempReadPoint10*)pBuffer;
				item.X=p10->x;
				item.Y=p10->y;
				item.Z=p10->z;
				item.intensity=p10->intensity;
				item.flags=p10->flags;
				item.classification=p10->classification;
				item.scan_angle_rank=p10->scan_angle_rank;
				item.user_data=p10->user_data;
				item.point_source_ID=p10->point_source_ID;
			}
		}
Ejemplo n.º 39
0
        public unsafe override void read(laszip_point item)
        {
            if (instream.Read(buffer, 0, 20) != 20)
                throw new EndOfStreamException();

            fixed(byte *pBuffer = buffer)
            {
                LAStempReadPoint10 *p10 = (LAStempReadPoint10 *)pBuffer;

                item.X               = p10->x;
                item.Y               = p10->y;
                item.Z               = p10->z;
                item.intensity       = p10->intensity;
                item.flags           = p10->flags;
                item.classification  = p10->classification;
                item.scan_angle_rank = p10->scan_angle_rank;
                item.user_data       = p10->user_data;
                item.point_source_ID = p10->point_source_ID;
            }
        }
		public override bool init(laszip_point item)
		{
			// init state
			for(int i=0; i<16; i++)
			{
				last_x_diff_median5[i].init();
				last_y_diff_median5[i].init();
				last_intensity[i]=0;
				last_height[i/2]=0;
			}

			// init models and integer compressors
			ic_dx.initCompressor();
			ic_dy.initCompressor();
			ic_z.initCompressor();
			ic_intensity.initCompressor();
			enc.initSymbolModel(m_scan_angle_rank[0]);
			enc.initSymbolModel(m_scan_angle_rank[1]);
			ic_point_source_ID.initCompressor();
			enc.initSymbolModel(m_changed_values);
			for(int i=0; i<256; i++)
			{
				if(m_bit_byte[i]!=null) enc.initSymbolModel(m_bit_byte[i]);
				if(m_classification[i]!=null) enc.initSymbolModel(m_classification[i]);
				if(m_user_data[i]!=null) enc.initSymbolModel(m_user_data[i]);
			}

			// init last item
			last.x=item.X;
			last.y=item.Y;
			last.z=item.Z;
			last.intensity=0; // but set intensity to zero
			last.flags=item.flags;
			last.classification=item.classification;
			last.scan_angle_rank=item.scan_angle_rank;
			last.user_data=item.user_data;
			last.point_source_ID=item.point_source_ID;

			return true;
		}
		public unsafe override void read(laszip_point item)
		{
			item.wave_packet[0]=(byte)(dec.decodeSymbol(m_packet_index));

			fixed(byte* pItem=item.wave_packet)
			{
				LASwavepacket13* wave=(LASwavepacket13*)(pItem+1);

				sym_last_offset_diff=dec.decodeSymbol(m_offset_diff[sym_last_offset_diff]);

				if(sym_last_offset_diff==0)
				{
					wave->offset=last_item.offset;
				}
				else if(sym_last_offset_diff==1)
				{
					wave->offset=last_item.offset+last_item.packet_size;
				}
				else if(sym_last_offset_diff==2)
				{
					last_diff_32=ic_offset_diff.decompress(last_diff_32);
					wave->offset=(ulong)((long)last_item.offset+last_diff_32);
				}
				else
				{
					wave->offset=dec.readInt64();
				}

				wave->packet_size=(uint)ic_packet_size.decompress((int)last_item.packet_size);
				wave->return_point.i32=ic_return_point.decompress(last_item.return_point.i32);
				wave->x.i32=ic_xyz.decompress(last_item.x.i32, 0);
				wave->y.i32=ic_xyz.decompress(last_item.y.i32, 1);
				wave->z.i32=ic_xyz.decompress(last_item.z.i32, 2);

				last_item=*wave;
			}
		}
Ejemplo n.º 42
0
        public unsafe override void read(laszip_point item)
        {
            item.wave_packet[0] = (byte)(dec.decodeSymbol(m_packet_index));

            fixed(byte *pItem = item.wave_packet)
            {
                LASwavepacket13 *wave = (LASwavepacket13 *)(pItem + 1);

                sym_last_offset_diff = dec.decodeSymbol(m_offset_diff[sym_last_offset_diff]);

                if (sym_last_offset_diff == 0)
                {
                    wave->offset = last_item.offset;
                }
                else if (sym_last_offset_diff == 1)
                {
                    wave->offset = last_item.offset + last_item.packet_size;
                }
                else if (sym_last_offset_diff == 2)
                {
                    last_diff_32 = ic_offset_diff.decompress(last_diff_32);
                    wave->offset = (ulong)((long)last_item.offset + last_diff_32);
                }
                else
                {
                    wave->offset = dec.readInt64();
                }

                wave->packet_size      = (uint)ic_packet_size.decompress((int)last_item.packet_size);
                wave->return_point.i32 = ic_return_point.decompress(last_item.return_point.i32);
                wave->x.i32            = ic_xyz.decompress(last_item.x.i32, 0);
                wave->y.i32            = ic_xyz.decompress(last_item.y.i32, 1);
                wave->z.i32            = ic_xyz.decompress(last_item.z.i32, 2);

                last_item = *wave;
            }
        }
		public override void read(laszip_point item)
		{
			if(last_gpstime_diff[last]==0) // if the last integer difference was zero
			{
				int multi=(int)dec.decodeSymbol(m_gpstime_0diff);
				if(multi==1) // the difference can be represented with 32 bits
				{
					last_gpstime_diff[last]=ic_gpstime.decompress(0, 0);
					last_gpstime[last].i64+=last_gpstime_diff[last];
					multi_extreme_counter[last]=0;
				}
				else if(multi==2) // the difference is huge
				{
					next=(next+1)&3;
					last_gpstime[next].u64=(ulong)ic_gpstime.decompress((int)(last_gpstime[last].u64>>32), 8);
					last_gpstime[next].u64=last_gpstime[next].u64<<32;
					last_gpstime[next].u64|=dec.readInt();
					last=next;
					last_gpstime_diff[last]=0;
					multi_extreme_counter[last]=0;
				}
				else if(multi>2) // we switch to another sequence
				{
					last=(uint)(last+multi-2)&3;
					read(item);
				}
			}
			else
			{
				int multi=(int)dec.decodeSymbol(m_gpstime_multi);
				if(multi==1)
				{
					last_gpstime[last].i64+=ic_gpstime.decompress(last_gpstime_diff[last], 1); ;
					multi_extreme_counter[last]=0;
				}
				else if(multi<LASZIP_GPSTIME_MULTI_UNCHANGED)
				{
					int gpstime_diff;
					if(multi==0)
					{
						gpstime_diff=ic_gpstime.decompress(0, 7);
						multi_extreme_counter[last]++;
						if(multi_extreme_counter[last]>3)
						{
							last_gpstime_diff[last]=gpstime_diff;
							multi_extreme_counter[last]=0;
						}
					}
					else if(multi<LASZIP_GPSTIME_MULTI)
					{
						if(multi<10)
							gpstime_diff=ic_gpstime.decompress(multi*last_gpstime_diff[last], 2);
						else
							gpstime_diff=ic_gpstime.decompress(multi*last_gpstime_diff[last], 3);
					}
					else if(multi==LASZIP_GPSTIME_MULTI)
					{
						gpstime_diff=ic_gpstime.decompress(LASZIP_GPSTIME_MULTI*last_gpstime_diff[last], 4);
						multi_extreme_counter[last]++;
						if(multi_extreme_counter[last]>3)
						{
							last_gpstime_diff[last]=gpstime_diff;
							multi_extreme_counter[last]=0;
						}
					}
					else
					{
						multi=LASZIP_GPSTIME_MULTI-multi;
						if(multi>LASZIP_GPSTIME_MULTI_MINUS)
						{
							gpstime_diff=ic_gpstime.decompress(multi*last_gpstime_diff[last], 5);
						}
						else
						{
							gpstime_diff=ic_gpstime.decompress(LASZIP_GPSTIME_MULTI_MINUS*last_gpstime_diff[last], 6);
							multi_extreme_counter[last]++;
							if(multi_extreme_counter[last]>3)
							{
								last_gpstime_diff[last]=gpstime_diff;
								multi_extreme_counter[last]=0;
							}
						}
					}
					last_gpstime[last].i64+=gpstime_diff;
				}
				else if(multi==LASZIP_GPSTIME_MULTI_CODE_FULL)
				{
					next=(next+1)&3;
					last_gpstime[next].u64=(ulong)ic_gpstime.decompress((int)(last_gpstime[last].u64>>32), 8);
					last_gpstime[next].u64=last_gpstime[next].u64<<32;
					last_gpstime[next].u64|=dec.readInt();
					last=next;
					last_gpstime_diff[last]=0;
					multi_extreme_counter[last]=0;
				}
				else if(multi>=LASZIP_GPSTIME_MULTI_CODE_FULL)
				{
					last=(uint)(last+multi-LASZIP_GPSTIME_MULTI_CODE_FULL)&3;
					read(item);
				}
			}
			item.gps_time=last_gpstime[last].f64;
		}
Ejemplo n.º 44
0
		public int laszip_set_point(laszip_point point)
		{
			if(point==null)
			{
				error="laszip_point_struct pointer is zero";
				return 1;
			}

			if(reader!=null)
			{
				error="cannot set point for reader";
				return 1;
			}

			try
			{
				this.point.classification=point.classification;
				this.point.edge_of_flight_line=point.edge_of_flight_line;
				this.point.extended_classification=point.extended_classification;
				this.point.extended_classification_flags=point.extended_classification_flags;
				this.point.extended_number_of_returns_of_given_pulse=point.extended_number_of_returns_of_given_pulse;
				this.point.extended_point_type=point.extended_point_type;
				this.point.extended_return_number=point.extended_return_number;
				this.point.extended_scan_angle=point.extended_scan_angle;
				this.point.extended_scanner_channel=point.extended_scanner_channel;
				this.point.gps_time=point.gps_time;
				this.point.intensity=point.intensity;
				this.point.num_extra_bytes=point.num_extra_bytes;
				this.point.number_of_returns_of_given_pulse=point.number_of_returns_of_given_pulse;
				this.point.point_source_ID=point.point_source_ID;
				this.point.return_number=point.return_number;
				Array.Copy(point.rgb, this.point.rgb, 4);
				this.point.scan_angle_rank=point.scan_angle_rank;
				this.point.scan_direction_flag=point.scan_direction_flag;
				this.point.user_data=point.user_data;
				this.point.X=point.X;
				this.point.Y=point.Y;
				this.point.Z=point.Z;
				Array.Copy(point.wave_packet, this.point.wave_packet, 29);

				if(this.point.extra_bytes!=null)
				{
					if(point.extra_bytes!=null)
					{
						if(this.point.num_extra_bytes==point.num_extra_bytes)
						{
							Array.Copy(point.extra_bytes, this.point.extra_bytes, point.num_extra_bytes);
						}
						else
						{
							error=string.Format("target point has {0} extra bytes but source point has {1}", this.point.num_extra_bytes, point.num_extra_bytes);
							return 1;
						}
					}
					else
					{
						error="target point has extra bytes but source point does not";
						return 1;
					}
				}
				else
				{
					if(point.extra_bytes!=null)
					{
						error="source point has extra bytes but target point does not";
						return 1;
					}
				}
			}
			catch
			{
				error="internal error in laszip_set_point";
				return 1;
			}

			error=null;
			return 0;
		}
		public override bool write(laszip_point item)
		{
			int diff_l=0;
			int diff_h=0;

			uint sym=0;

			bool rl=(last_item[0]&0x00FF)!=(item.rgb[0]&0x00FF); if(rl) sym|=1;
			bool rh=(last_item[0]&0xFF00)!=(item.rgb[0]&0xFF00); if(rh) sym|=2;
			bool gl=(last_item[1]&0x00FF)!=(item.rgb[1]&0x00FF); if(gl) sym|=4;
			bool gh=(last_item[1]&0xFF00)!=(item.rgb[1]&0xFF00); if(gh) sym|=8;
			bool bl=(last_item[2]&0x00FF)!=(item.rgb[2]&0x00FF); if(bl) sym|=16;
			bool bh=(last_item[2]&0xFF00)!=(item.rgb[2]&0xFF00); if(bh) sym|=32;
			
			bool allColors=((item.rgb[0]&0x00FF)!=(item.rgb[1]&0x00FF))||((item.rgb[0]&0x00FF)!=(item.rgb[2]&0x00FF))||
				((item.rgb[0]&0xFF00)!=(item.rgb[1]&0xFF00))||((item.rgb[0]&0xFF00)!=(item.rgb[2]&0xFF00));
			if(allColors) sym|=64;

			enc.encodeSymbol(m_byte_used, sym);
			if(rl)
			{
				diff_l=((int)(item.rgb[0]&255))-(last_item[0]&255);
				enc.encodeSymbol(m_rgb_diff_0, (byte)MyDefs.U8_FOLD(diff_l));
			}
			if(rh)
			{
				diff_h=((int)(item.rgb[0]>>8))-(last_item[0]>>8);
				enc.encodeSymbol(m_rgb_diff_1, (byte)MyDefs.U8_FOLD(diff_h));
			}

			if(allColors)
			{
				if(gl)
				{
					int corr=((int)(item.rgb[1]&255))-MyDefs.U8_CLAMP(diff_l+(last_item[1]&255));
					enc.encodeSymbol(m_rgb_diff_2, (byte)MyDefs.U8_FOLD(corr));
				}
				if(bl)
				{
					diff_l=(diff_l+(item.rgb[1]&255)-(last_item[1]&255))/2;
					int corr=((int)(item.rgb[2]&255))-MyDefs.U8_CLAMP(diff_l+(last_item[2]&255));
					enc.encodeSymbol(m_rgb_diff_4, (byte)MyDefs.U8_FOLD(corr));
				}
				if(gh)
				{
					int corr=((int)(item.rgb[1]>>8))-MyDefs.U8_CLAMP(diff_h+(last_item[1]>>8));
					enc.encodeSymbol(m_rgb_diff_3, (byte)MyDefs.U8_FOLD(corr));
				}
				if(bh)
				{
					diff_h=(diff_h+(item.rgb[1]>>8)-(last_item[1]>>8))/2;
					int corr=((int)(item.rgb[2]>>8))-MyDefs.U8_CLAMP(diff_h+(last_item[2]>>8));
					enc.encodeSymbol(m_rgb_diff_5, (byte)MyDefs.U8_FOLD(corr));
				}
			}

			last_item[0]=item.rgb[0];
			last_item[1]=item.rgb[1];
			last_item[2]=item.rgb[2];

			return true;
		}
		public override void read(laszip_point item)
		{
			if(last_gpstime_diff==0) // if the last integer difference was zero
			{
				int multi=(int)dec.decodeSymbol(m_gpstime_0diff);
				if(multi==1) // the difference can be represented with 32 bits
				{
					last_gpstime_diff=ic_gpstime.decompress(0, 0);
					last_gpstime.i64+=last_gpstime_diff;
				}
				else if(multi==2) // the difference is huge
				{
					last_gpstime.u64=dec.readInt64();
				}
			}
			else
			{
				int multi=(int)dec.decodeSymbol(m_gpstime_multi);

				if(multi<LASZIP_GPSTIME_MULTIMAX-2)
				{
					int gpstime_diff;
					if(multi==1)
					{
						gpstime_diff=ic_gpstime.decompress(last_gpstime_diff, 1);
						last_gpstime_diff=gpstime_diff;
						multi_extreme_counter=0;
					}
					else if(multi==0)
					{
						gpstime_diff=ic_gpstime.decompress(last_gpstime_diff/4, 2);
						multi_extreme_counter++;
						if(multi_extreme_counter>3)
						{
							last_gpstime_diff=gpstime_diff;
							multi_extreme_counter=0;
						}
					}
					else if(multi<10)
					{
						gpstime_diff=ic_gpstime.decompress(multi*last_gpstime_diff, 3);
					}
					else if(multi<50)
					{
						gpstime_diff=ic_gpstime.decompress(multi*last_gpstime_diff, 4);
					}
					else
					{
						gpstime_diff=ic_gpstime.decompress(multi*last_gpstime_diff, 5);
						if(multi==LASZIP_GPSTIME_MULTIMAX-3)
						{
							multi_extreme_counter++;
							if(multi_extreme_counter>3)
							{
								last_gpstime_diff=gpstime_diff;
								multi_extreme_counter=0;
							}
						}
					}
					last_gpstime.i64+=gpstime_diff;
				}
				else if(multi<LASZIP_GPSTIME_MULTIMAX-1)
				{
					last_gpstime.u64=dec.readInt64();
				}
			}

			item.gps_time=last_gpstime.f64;
		}
        public override void read(laszip_point item)
        {
            // decompress which other values have changed
            uint changed_values = dec.decodeSymbol(m_changed_values);

            byte r, n, m, l;

            if (changed_values != 0)
            {
                // decompress the edge_of_flight_line, scan_direction_flag, ... if it has changed
                if ((changed_values & 32) != 0)
                {
                    if (m_bit_byte[last.flags] == null)
                    {
                        m_bit_byte[last.flags] = dec.createSymbolModel(256);
                        dec.initSymbolModel(m_bit_byte[last.flags]);
                    }
                    last.flags = (byte)dec.decodeSymbol(m_bit_byte[last.flags]);
                }

                r = (byte)(last.flags & 0x7);             // return_number
                n = (byte)((last.flags >> 3) & 0x7);      // number_of_returns_of_given_pulse
                m = Laszip_Common_v2.number_return_map[n, r];
                l = Laszip_Common_v2.number_return_level[n, r];

                // decompress the intensity if it has changed
                if ((changed_values & 16) != 0)
                {
                    last.intensity    = (ushort)ic_intensity.decompress(last_intensity[m], (m < 3?m:3u));
                    last_intensity[m] = last.intensity;
                }
                else
                {
                    last.intensity = last_intensity[m];
                }

                // decompress the classification ... if it has changed
                if ((changed_values & 8) != 0)
                {
                    if (m_classification[last.classification] == null)
                    {
                        m_classification[last.classification] = dec.createSymbolModel(256);
                        dec.initSymbolModel(m_classification[last.classification]);
                    }
                    last.classification = (byte)dec.decodeSymbol(m_classification[last.classification]);
                }

                // decompress the scan_angle_rank ... if it has changed
                if ((changed_values & 4) != 0)
                {
                    int val = (int)dec.decodeSymbol(m_scan_angle_rank[(last.flags & 0x40) != 0?1:0]);               // scan_direction_flag
                    //last->scan_angle_rank=(sbyte)MyDefs.U8_FOLD(val+(byte)last->scan_angle_rank);
                    last.scan_angle_rank = (sbyte)((val + (byte)last.scan_angle_rank) % 256);
                }

                // decompress the user_data ... if it has changed
                if ((changed_values & 2) != 0)
                {
                    if (m_user_data[last.user_data] == null)
                    {
                        m_user_data[last.user_data] = dec.createSymbolModel(256);
                        dec.initSymbolModel(m_user_data[last.user_data]);
                    }
                    last.user_data = (byte)dec.decodeSymbol(m_user_data[last.user_data]);
                }

                // decompress the point_source_ID ... if it has changed
                if ((changed_values & 1) != 0)
                {
                    last.point_source_ID = (ushort)ic_point_source_ID.decompress(last.point_source_ID);
                }
            }
            else
            {
                r = (byte)(last.flags & 0x7);             // return_number
                n = (byte)((last.flags >> 3) & 0x7);      // number_of_returns_of_given_pulse
                m = Laszip_Common_v2.number_return_map[n, r];
                l = Laszip_Common_v2.number_return_level[n, r];
            }

            // decompress x coordinate
            int median = last_x_diff_median5[m].get();
            int diff   = ic_dx.decompress(median, n == 1?1u:0u);

            last.x += diff;
            last_x_diff_median5[m].add(diff);

            // decompress y coordinate
            median = last_y_diff_median5[m].get();
            uint k_bits = ic_dx.getK();

            diff    = ic_dy.decompress(median, (n == 1?1u:0u) + (k_bits < 20?k_bits & 0xFEu:20u)); // &0xFE round k_bits to next even number
            last.y += diff;
            last_y_diff_median5[m].add(diff);

            // decompress z coordinate
            k_bits         = (ic_dx.getK() + ic_dy.getK()) / 2;
            last.z         = ic_z.decompress(last_height[l], (n == 1?1u:0u) + (k_bits < 18?k_bits & 0xFEu:18u)); // &0xFE round k_bits to next even number
            last_height[l] = last.z;

            // copy the last point
            item.X               = last.x;
            item.Y               = last.y;
            item.Z               = last.z;
            item.intensity       = last.intensity;
            item.flags           = last.flags;
            item.classification  = last.classification;
            item.scan_angle_rank = last.scan_angle_rank;
            item.user_data       = last.user_data;
            item.point_source_ID = last.point_source_ID;
        }
		public override bool write(laszip_point item)
		{
			uint r=item.return_number;
			uint n=item.number_of_returns_of_given_pulse;
			uint m=Laszip_Common_v2.number_return_map[n, r];
			uint l=Laszip_Common_v2.number_return_level[n, r];

			// compress which other values have changed
			uint changed_values=0;
			
			bool needFlags=last.flags!=item.flags; if(needFlags) changed_values|=32; // bit_byte
			bool needIntensity=last_intensity[m]!=item.intensity; if(needIntensity) changed_values|=16;
			bool needClassification=last.classification!=item.classification; if(needClassification) changed_values|=8;
			bool needScanAngleRank=last.scan_angle_rank!=item.scan_angle_rank; if(needScanAngleRank) changed_values|=4;
			bool needUserData=last.user_data!=item.user_data; if(needUserData) changed_values|=2;
			bool needPointSourceID=last.point_source_ID!=item.point_source_ID; if(needPointSourceID) changed_values|=1;

			enc.encodeSymbol(m_changed_values, changed_values);

			// compress the bit_byte (edge_of_flight_line, scan_direction_flag, returns, ...) if it has changed
			if(needFlags)
			{
				if(m_bit_byte[last.flags]==null)
				{
					m_bit_byte[last.flags]=enc.createSymbolModel(256);
					enc.initSymbolModel(m_bit_byte[last.flags]);
				}
				enc.encodeSymbol(m_bit_byte[last.flags], item.flags);
			}

			// compress the intensity if it has changed
			if(needIntensity)
			{
				ic_intensity.compress(last_intensity[m], item.intensity, (m<3?m:3u));
				last_intensity[m]=item.intensity;
			}

			// compress the classification ... if it has changed
			if(needClassification)
			{
				if(m_classification[last.classification]==null)
				{
					m_classification[last.classification]=enc.createSymbolModel(256);
					enc.initSymbolModel(m_classification[last.classification]);
				}
				enc.encodeSymbol(m_classification[last.classification], item.classification);
			}

			// compress the scan_angle_rank ... if it has changed
			if(needScanAngleRank)
			{
				enc.encodeSymbol(m_scan_angle_rank[item.scan_direction_flag], (uint)MyDefs.U8_FOLD(item.scan_angle_rank-last.scan_angle_rank));
			}

			// compress the user_data ... if it has changed
			if(needUserData)
			{
				if(m_user_data[last.user_data]==null)
				{
					m_user_data[last.user_data]=enc.createSymbolModel(256);
					enc.initSymbolModel(m_user_data[last.user_data]);
				}
				enc.encodeSymbol(m_user_data[last.user_data], item.user_data);
			}

			// compress the point_source_ID ... if it has changed
			if(needPointSourceID)
			{
				ic_point_source_ID.compress(last.point_source_ID, item.point_source_ID);
			}

			// compress x coordinate
			int median=last_x_diff_median5[m].get();
			int diff=item.X-last.x;
			ic_dx.compress(median, diff, n==1?1u:0u);
			last_x_diff_median5[m].add(diff);

			// compress y coordinate
			uint k_bits=ic_dx.getK();
			median=last_y_diff_median5[m].get();
			diff=item.Y-last.y;
			ic_dy.compress(median, diff, (n==1?1u:0u)+(k_bits<20?k_bits&0xFEu:20u)); // &0xFE round k_bits to next even number
			last_y_diff_median5[m].add(diff);

			// compress z coordinate
			k_bits=(ic_dx.getK()+ic_dy.getK())/2;
			ic_z.compress(last_height[l], item.Z, (n==1?1u:0u)+(k_bits<18?k_bits&0xFEu:18u)); // &0xFE round k_bits to next even number
			last_height[l]=item.Z;

			// copy the last point
			last.x=item.X;
			last.y=item.Y;
			last.z=item.Z;
			last.intensity=item.intensity;
			last.flags=item.flags;
			last.classification=item.classification;
			last.scan_angle_rank=item.scan_angle_rank;
			last.user_data=item.user_data;
			last.point_source_ID=item.point_source_ID;

			return true;
		}
Ejemplo n.º 49
0
		public bool read(laszip_point point)
		{
			try
			{
				if(dec!=null)
				{
					if(chunk_count==chunk_size)
					{
						if(point_start!=0)
						{
							dec.done();
							current_chunk++;
							// check integrity
							if(current_chunk<tabled_chunks)
							{
								long here=instream.Position;
								if(chunk_starts[(int)current_chunk]!=here)
								{
									// previous chunk was corrupt
									current_chunk--;
									throw new Exception("4711");
								}
							}
						}
						init_dec();
						if(tabled_chunks==current_chunk) // no or incomplete chunk table?
						{
							//if(current_chunk==number_chunks)
							//{
							//    number_chunks+=256;
							//    chunk_starts=(I64*)realloc(chunk_starts, sizeof(I64)*(number_chunks+1));
							//}
							//chunk_starts[tabled_chunks]=point_start; // needs fixing

							// If there was no(!) chunk table, we haven't had the chance to create the chunk_starts list.
							if(tabled_chunks==0&&chunk_starts==null) chunk_starts=new List<long>();

							chunk_starts.Add(point_start);
							number_chunks++;
							tabled_chunks++;
						}
						else if(chunk_totals!=null) // variable sized chunks?
						{
							chunk_size=chunk_totals[current_chunk+1]-chunk_totals[current_chunk];
						}
						chunk_count=0;
					}
					chunk_count++;

					if(readers!=null)
					{
						for(int i=0; i<num_readers; i++)
						{
							readers[i].read(point);
						}
					}
					else
					{
						for(int i=0; i<num_readers; i++)
						{
							readers_raw[i].read(point);
							((LASreadItemCompressed)(readers_compressed[i])).init(point);
						}
						readers=readers_compressed;
						dec.init(instream);
					}
				}
				else
				{
					for(int i=0; i<num_readers; i++)
					{
						readers[i].read(point);
					}
				}
			}
			catch(EndOfStreamException)
			{
				// end-of-file
				if(dec!=null) last_error="end-of-file during chunk "+current_chunk;
				else last_error="end-of-file";
				return false;
			}
			catch
			{
				// decompression error
				last_error=string.Format("chunk {0} of {1} is corrupt", current_chunk, tabled_chunks);
				// if we know where the next chunk starts ...
				if((current_chunk+1)<tabled_chunks)
				{
					// ... try to seek to the next chunk
					instream.Seek(chunk_starts[(int)current_chunk+1], SeekOrigin.Begin);
					// ... ready for next LASreadPoint::read()
					chunk_count=chunk_size;
				}

				return false;
			}
			return true;
		}
        public override void read(laszip_point item)
        {
            int corr;
            int diff = 0;

            uint sym = dec.decodeSymbol(m_byte_used);

            if ((sym & (1 << 0)) != 0)
            {
                corr        = (int)dec.decodeSymbol(m_rgb_diff_0);
                item.rgb[0] = (ushort)MyDefs.U8_FOLD(corr + (last_item[0] & 255));
            }
            else
            {
                item.rgb[0] = (ushort)(last_item[0] & 0xFF);
            }

            if ((sym & (1 << 1)) != 0)
            {
                corr         = (int)dec.decodeSymbol(m_rgb_diff_1);
                item.rgb[0] |= (ushort)((MyDefs.U8_FOLD(corr + (last_item[0] >> 8))) << 8);
            }
            else
            {
                item.rgb[0] |= (ushort)(last_item[0] & 0xFF00);
            }

            if ((sym & (1 << 6)) != 0)
            {
                diff = (item.rgb[0] & 0x00FF) - (last_item[0] & 0x00FF);
                if ((sym & (1 << 2)) != 0)
                {
                    corr        = (int)dec.decodeSymbol(m_rgb_diff_2);
                    item.rgb[1] = (ushort)MyDefs.U8_FOLD(corr + MyDefs.U8_CLAMP(diff + (last_item[1] & 255)));
                }
                else
                {
                    item.rgb[1] = (ushort)(last_item[1] & 0xFF);
                }

                if ((sym & (1 << 4)) != 0)
                {
                    corr        = (int)dec.decodeSymbol(m_rgb_diff_4);
                    diff        = (diff + ((item.rgb[1] & 0x00FF) - (last_item[1] & 0x00FF))) / 2;
                    item.rgb[2] = (ushort)MyDefs.U8_FOLD(corr + MyDefs.U8_CLAMP(diff + (last_item[2] & 255)));
                }
                else
                {
                    item.rgb[2] = (ushort)(last_item[2] & 0xFF);
                }

                diff = (item.rgb[0] >> 8) - (last_item[0] >> 8);
                if ((sym & (1 << 3)) != 0)
                {
                    corr         = (int)dec.decodeSymbol(m_rgb_diff_3);
                    item.rgb[1] |= (ushort)((MyDefs.U8_FOLD(corr + MyDefs.U8_CLAMP(diff + (last_item[1] >> 8)))) << 8);
                }
                else
                {
                    item.rgb[1] |= (ushort)(last_item[1] & 0xFF00);
                }

                if ((sym & (1 << 5)) != 0)
                {
                    corr         = (int)dec.decodeSymbol(m_rgb_diff_5);
                    diff         = (diff + ((item.rgb[1] >> 8) - (last_item[1] >> 8))) / 2;
                    item.rgb[2] |= (ushort)((MyDefs.U8_FOLD(corr + MyDefs.U8_CLAMP(diff + (last_item[2] >> 8)))) << 8);
                }
                else
                {
                    item.rgb[2] |= (ushort)(last_item[2] & 0xFF00);
                }
            }
            else
            {
                item.rgb[1] = item.rgb[0];
                item.rgb[2] = item.rgb[0];
            }

            last_item[0] = item.rgb[0];
            last_item[1] = item.rgb[1];
            last_item[2] = item.rgb[2];
        }
Ejemplo n.º 51
0
        public bool read(laszip_point point)
        {
            try
            {
                if (dec != null)
                {
                    if (chunk_count == chunk_size)
                    {
                        if (point_start != 0)
                        {
                            dec.done();
                            current_chunk++;
                            // check integrity
                            if (current_chunk < tabled_chunks)
                            {
                                long here = instream.Position;
                                if (chunk_starts[(int)current_chunk] != here)
                                {
                                    // previous chunk was corrupt
                                    current_chunk--;
                                    throw new Exception("4711");
                                }
                            }
                        }
                        init_dec();
                        if (tabled_chunks == current_chunk)                      // no or incomplete chunk table?
                        {
                            //if(current_chunk==number_chunks)
                            //{
                            //    number_chunks+=256;
                            //    chunk_starts=(I64*)realloc(chunk_starts, sizeof(I64)*(number_chunks+1));
                            //}
                            //chunk_starts[tabled_chunks]=point_start; // needs fixing

                            // If there was no(!) chunk table, we haven't had the chance to create the chunk_starts list.
                            if (tabled_chunks == 0 && chunk_starts == null)
                            {
                                chunk_starts = new List <long>();
                            }

                            chunk_starts.Add(point_start);
                            number_chunks++;
                            tabled_chunks++;
                        }
                        else if (chunk_totals != null)                      // variable sized chunks?
                        {
                            chunk_size = chunk_totals[current_chunk + 1] - chunk_totals[current_chunk];
                        }
                        chunk_count = 0;
                    }
                    chunk_count++;

                    if (readers != null)
                    {
                        for (int i = 0; i < num_readers; i++)
                        {
                            readers[i].read(point);
                        }
                    }
                    else
                    {
                        for (int i = 0; i < num_readers; i++)
                        {
                            readers_raw[i].read(point);
                            ((LASreadItemCompressed)(readers_compressed[i])).init(point);
                        }
                        readers = readers_compressed;
                        dec.init(instream);
                    }
                }
                else
                {
                    for (int i = 0; i < num_readers; i++)
                    {
                        readers[i].read(point);
                    }
                }
            }
            catch (EndOfStreamException)
            {
                // end-of-file
                if (dec != null)
                {
                    last_error = "end-of-file during chunk " + current_chunk;
                }
                else
                {
                    last_error = "end-of-file";
                }
                return(false);
            }
            catch
            {
                // decompression error
                last_error = string.Format("chunk {0} of {1} is corrupt", current_chunk, tabled_chunks);
                // if we know where the next chunk starts ...
                if ((current_chunk + 1) < tabled_chunks)
                {
                    // ... try to seek to the next chunk
                    instream.Seek(chunk_starts[(int)current_chunk + 1], SeekOrigin.Begin);
                    // ... ready for next LASreadPoint::read()
                    chunk_count = chunk_size;
                }

                return(false);
            }
            return(true);
        }
		public override void read(laszip_point item)
		{
			// find median difference for x and y from 3 preceding differences
			int median_x;
			if(last_x_diff[0]<last_x_diff[1])
			{
				if(last_x_diff[1]<last_x_diff[2]) median_x=last_x_diff[1];
				else if(last_x_diff[0]<last_x_diff[2]) median_x=last_x_diff[2];
				else median_x=last_x_diff[0];
			}
			else
			{
				if(last_x_diff[0]<last_x_diff[2]) median_x=last_x_diff[0];
				else if(last_x_diff[1]<last_x_diff[2]) median_x=last_x_diff[2];
				else median_x=last_x_diff[1];
			}

			int median_y;
			if(last_y_diff[0]<last_y_diff[1])
			{
				if(last_y_diff[1]<last_y_diff[2]) median_y=last_y_diff[1];
				else if(last_y_diff[0]<last_y_diff[2]) median_y=last_y_diff[2];
				else median_y=last_y_diff[0];
			}
			else
			{
				if(last_y_diff[0]<last_y_diff[2]) median_y=last_y_diff[0];
				else if(last_y_diff[1]<last_y_diff[2]) median_y=last_y_diff[2];
				else median_y=last_y_diff[1];
			}

			// decompress x y z coordinates
			int x_diff=ic_dx.decompress(median_x);
			last.x+=x_diff;

			// we use the number k of bits corrector bits to switch contexts
			uint k_bits=ic_dx.getK();
			int y_diff=ic_dy.decompress(median_y, (k_bits<19?k_bits:19u));
			last.y+=y_diff;

			k_bits=(k_bits+ic_dy.getK())/2;
			last.z=ic_z.decompress(last.z, (k_bits<19?k_bits:19u));

			// decompress which other values have changed
			uint changed_values=dec.decodeSymbol(m_changed_values);

			if(changed_values!=0)
			{
				// decompress the intensity if it has changed
				if((changed_values&32)!=0)
				{
					last.intensity=(ushort)ic_intensity.decompress(last.intensity);
				}

				// decompress the edge_of_flight_line, scan_direction_flag, ... if it has changed
				if((changed_values&16)!=0)
				{
					if(m_bit_byte[last.flags]==null)
					{
						m_bit_byte[last.flags]=dec.createSymbolModel(256);
						dec.initSymbolModel(m_bit_byte[last.flags]);
					}
					last.flags=(byte)dec.decodeSymbol(m_bit_byte[last.flags]);
				}

				// decompress the classification ... if it has changed
				if((changed_values&8)!=0)
				{
					if(m_classification[last.classification]==null)
					{
						m_classification[last.classification]=dec.createSymbolModel(256);
						dec.initSymbolModel(m_classification[last.classification]);
					}
					last.classification=(byte)dec.decodeSymbol(m_classification[last.classification]);
				}

				// decompress the scan_angle_rank ... if it has changed
				if((changed_values&4)!=0)
				{
					last.scan_angle_rank=(sbyte)(byte)ic_scan_angle_rank.decompress((byte)last.scan_angle_rank, k_bits<3?1u:0u);
				}

				// decompress the user_data ... if it has changed
				if((changed_values&2)!=0)
				{
					if(m_user_data[last.user_data]==null)
					{
						m_user_data[last.user_data]=dec.createSymbolModel(256);
						dec.initSymbolModel(m_user_data[last.user_data]);
					}
					last.user_data=(byte)dec.decodeSymbol(m_user_data[last.user_data]);
				}

				// decompress the point_source_ID ... if it has changed
				if((changed_values&1)!=0)
				{
					last.point_source_ID=(ushort)ic_point_source_ID.decompress(last.point_source_ID);
				}
			}

			// record the difference
			last_x_diff[last_incr]=x_diff;
			last_y_diff[last_incr]=y_diff;
			last_incr++;
			if(last_incr>2) last_incr=0;

			// copy the last point
			item.X=last.x;
			item.Y=last.y;
			item.Z=last.z;
			item.intensity=last.intensity;
			item.flags=last.flags;
			item.classification=last.classification;
			item.scan_angle_rank=last.scan_angle_rank;
			item.user_data=last.user_data;
			item.point_source_ID=last.point_source_ID;
		}
Ejemplo n.º 53
0
		public bool write(laszip_point point)
		{
			if(chunk_count==chunk_size)
			{
				enc.done();
				add_chunk_to_table();
				init(outstream);
				chunk_count=0;
			}
			chunk_count++;

			if(writers!=null)
			{
				for(uint i=0; i<num_writers; i++)
				{
					writers[i].write(point);
				}
			}
			else
			{
				for(uint i=0; i<num_writers; i++)
				{
					writers_raw[i].write(point);
					((LASwriteItemCompressed)(writers_compressed[i])).init(point);
				}
				writers=writers_compressed;
				enc.init(outstream);
			}

			return true;
		}
Ejemplo n.º 54
0
        public override bool write(laszip_point item)
        {
            int diff_l = 0;
            int diff_h = 0;

            uint sym = 0;

            bool rl = (last_item[0] & 0x00FF) != (item.rgb[0] & 0x00FF); if (rl)
            {
                sym |= 1;
            }
            bool rh = (last_item[0] & 0xFF00) != (item.rgb[0] & 0xFF00); if (rh)
            {
                sym |= 2;
            }
            bool gl = (last_item[1] & 0x00FF) != (item.rgb[1] & 0x00FF); if (gl)
            {
                sym |= 4;
            }
            bool gh = (last_item[1] & 0xFF00) != (item.rgb[1] & 0xFF00); if (gh)
            {
                sym |= 8;
            }
            bool bl = (last_item[2] & 0x00FF) != (item.rgb[2] & 0x00FF); if (bl)
            {
                sym |= 16;
            }
            bool bh = (last_item[2] & 0xFF00) != (item.rgb[2] & 0xFF00); if (bh)
            {
                sym |= 32;
            }

            bool allColors = ((item.rgb[0] & 0x00FF) != (item.rgb[1] & 0x00FF)) || ((item.rgb[0] & 0x00FF) != (item.rgb[2] & 0x00FF)) ||
                             ((item.rgb[0] & 0xFF00) != (item.rgb[1] & 0xFF00)) || ((item.rgb[0] & 0xFF00) != (item.rgb[2] & 0xFF00));

            if (allColors)
            {
                sym |= 64;
            }

            enc.encodeSymbol(m_byte_used, sym);
            if (rl)
            {
                diff_l = ((int)(item.rgb[0] & 255)) - (last_item[0] & 255);
                enc.encodeSymbol(m_rgb_diff_0, (byte)MyDefs.U8_FOLD(diff_l));
            }
            if (rh)
            {
                diff_h = ((int)(item.rgb[0] >> 8)) - (last_item[0] >> 8);
                enc.encodeSymbol(m_rgb_diff_1, (byte)MyDefs.U8_FOLD(diff_h));
            }

            if (allColors)
            {
                if (gl)
                {
                    int corr = ((int)(item.rgb[1] & 255)) - MyDefs.U8_CLAMP(diff_l + (last_item[1] & 255));
                    enc.encodeSymbol(m_rgb_diff_2, (byte)MyDefs.U8_FOLD(corr));
                }
                if (bl)
                {
                    diff_l = (diff_l + (item.rgb[1] & 255) - (last_item[1] & 255)) / 2;
                    int corr = ((int)(item.rgb[2] & 255)) - MyDefs.U8_CLAMP(diff_l + (last_item[2] & 255));
                    enc.encodeSymbol(m_rgb_diff_4, (byte)MyDefs.U8_FOLD(corr));
                }
                if (gh)
                {
                    int corr = ((int)(item.rgb[1] >> 8)) - MyDefs.U8_CLAMP(diff_h + (last_item[1] >> 8));
                    enc.encodeSymbol(m_rgb_diff_3, (byte)MyDefs.U8_FOLD(corr));
                }
                if (bh)
                {
                    diff_h = (diff_h + (item.rgb[1] >> 8) - (last_item[1] >> 8)) / 2;
                    int corr = ((int)(item.rgb[2] >> 8)) - MyDefs.U8_CLAMP(diff_h + (last_item[2] >> 8));
                    enc.encodeSymbol(m_rgb_diff_5, (byte)MyDefs.U8_FOLD(corr));
                }
            }

            last_item[0] = item.rgb[0];
            last_item[1] = item.rgb[1];
            last_item[2] = item.rgb[2];

            return(true);
        }
Ejemplo n.º 55
0
		public override void read(laszip_point item)
		{
			if(instream.Read(buffer, 0, 8)!=8) throw new EndOfStreamException();

			item.gps_time=BitConverter.ToDouble(buffer, 0);
		}
		public override void read(laszip_point item)
		{
			if(instream.Read(item.wave_packet, 0, 29)!=29) throw new EndOfStreamException();
		}
		public override bool write(laszip_point item)
		{
			U64I64F64 this_gpstime=new U64I64F64();
			this_gpstime.f64=item.gps_time;

			if(last_gpstime_diff[last]==0) // if the last integer difference was zero
			{
				if(this_gpstime.i64==last_gpstime[last].i64)
				{
					enc.encodeSymbol(m_gpstime_0diff, 0); // the doubles have not changed
				}
				else
				{
					// calculate the difference between the two doubles as an integer
					long curr_gpstime_diff_64=this_gpstime.i64-last_gpstime[last].i64;
					int curr_gpstime_diff=(int)curr_gpstime_diff_64;
					if(curr_gpstime_diff_64==(long)(curr_gpstime_diff))
					{
						enc.encodeSymbol(m_gpstime_0diff, 1); // the difference can be represented with 32 bits
						ic_gpstime.compress(0, curr_gpstime_diff, 0);
						last_gpstime_diff[last]=curr_gpstime_diff;
						multi_extreme_counter[last]=0;
					}
					else // the difference is huge
					{
						// maybe the double belongs to another time sequence
						for(uint i=1; i<4; i++)
						{
							long other_gpstime_diff_64=this_gpstime.i64-last_gpstime[(last+i)&3].i64;
							int other_gpstime_diff=(int)other_gpstime_diff_64;
							if(other_gpstime_diff_64==(long)(other_gpstime_diff))
							{
								enc.encodeSymbol(m_gpstime_0diff, i+2); // it belongs to another sequence 
								last=(last+i)&3;
								return write(item);
							}
						}
						// no other sequence found. start new sequence.
						enc.encodeSymbol(m_gpstime_0diff, 2);
						ic_gpstime.compress((int)(last_gpstime[last].u64>>32), (int)(this_gpstime.u64>>32), 8);
						enc.writeInt((uint)(this_gpstime.u64));
						next=(next+1)&3;
						last=next;
						last_gpstime_diff[last]=0;
						multi_extreme_counter[last]=0;
					}
					last_gpstime[last].i64=this_gpstime.i64;
				}
			}
			else // the last integer difference was *not* zero
			{
				if(this_gpstime.i64==last_gpstime[last].i64)
				{
					// if the doubles have not changed use a special symbol
					enc.encodeSymbol(m_gpstime_multi, LASZIP_GPSTIME_MULTI_UNCHANGED);
				}
				else
				{
					// calculate the difference between the two doubles as an integer
					long curr_gpstime_diff_64=this_gpstime.i64-last_gpstime[last].i64;
					int curr_gpstime_diff=(int)curr_gpstime_diff_64;

					// if the current gpstime difference can be represented with 32 bits
					if(curr_gpstime_diff_64==(long)(curr_gpstime_diff))
					{
						// compute multiplier between current and last integer difference
						double multi_f=(double)curr_gpstime_diff/(double)(last_gpstime_diff[last]);
						int multi=MyDefs.I32_QUANTIZE(multi_f);

						// compress the residual curr_gpstime_diff in dependance on the multiplier
						if(multi==1)
						{
							// this is the case we assume we get most often for regular spaced pulses
							enc.encodeSymbol(m_gpstime_multi, 1);
							ic_gpstime.compress(last_gpstime_diff[last], curr_gpstime_diff, 1);
							multi_extreme_counter[last]=0;
						}
						else if(multi>0)
						{
							if(multi<LASZIP_GPSTIME_MULTI) // positive multipliers up to LASZIP_GPSTIME_MULTI are compressed directly
							{
								enc.encodeSymbol(m_gpstime_multi, (uint)multi);
								if(multi<10)
									ic_gpstime.compress(multi*last_gpstime_diff[last], curr_gpstime_diff, 2);
								else
									ic_gpstime.compress(multi*last_gpstime_diff[last], curr_gpstime_diff, 3);
							}
							else
							{
								enc.encodeSymbol(m_gpstime_multi, LASZIP_GPSTIME_MULTI);
								ic_gpstime.compress(LASZIP_GPSTIME_MULTI*last_gpstime_diff[last], curr_gpstime_diff, 4);
								multi_extreme_counter[last]++;
								if(multi_extreme_counter[last]>3)
								{
									last_gpstime_diff[last]=curr_gpstime_diff;
									multi_extreme_counter[last]=0;
								}
							}
						}
						else if(multi<0)
						{
							if(multi>LASZIP_GPSTIME_MULTI_MINUS) // negative multipliers larger than LASZIP_GPSTIME_MULTI_MINUS are compressed directly
							{
								enc.encodeSymbol(m_gpstime_multi, (uint)(LASZIP_GPSTIME_MULTI-multi));
								ic_gpstime.compress(multi*last_gpstime_diff[last], curr_gpstime_diff, 5);
							}
							else
							{
								enc.encodeSymbol(m_gpstime_multi, LASZIP_GPSTIME_MULTI-LASZIP_GPSTIME_MULTI_MINUS);
								ic_gpstime.compress(LASZIP_GPSTIME_MULTI_MINUS*last_gpstime_diff[last], curr_gpstime_diff, 6);
								multi_extreme_counter[last]++;
								if(multi_extreme_counter[last]>3)
								{
									last_gpstime_diff[last]=curr_gpstime_diff;
									multi_extreme_counter[last]=0;
								}
							}
						}
						else
						{
							enc.encodeSymbol(m_gpstime_multi, 0);
							ic_gpstime.compress(0, curr_gpstime_diff, 7);
							multi_extreme_counter[last]++;
							if(multi_extreme_counter[last]>3)
							{
								last_gpstime_diff[last]=curr_gpstime_diff;
								multi_extreme_counter[last]=0;
							}
						}
					}
					else // the difference is huge
					{
						// maybe the double belongs to another time sequence
						for(uint i=1; i<4; i++)
						{
							long other_gpstime_diff_64=this_gpstime.i64-last_gpstime[(last+i)&3].i64;
							int other_gpstime_diff=(int)other_gpstime_diff_64;
							if(other_gpstime_diff_64==(long)(other_gpstime_diff))
							{
								// it belongs to this sequence 
								enc.encodeSymbol(m_gpstime_multi, LASZIP_GPSTIME_MULTI_CODE_FULL+i);
								last=(last+i)&3;
								return write(item);
							}
						}
						// no other sequence found. start new sequence.
						enc.encodeSymbol(m_gpstime_multi, LASZIP_GPSTIME_MULTI_CODE_FULL);
						ic_gpstime.compress((int)(last_gpstime[last].u64>>32), (int)(this_gpstime.u64>>32), 8);
						enc.writeInt((uint)(this_gpstime.u64));
						next=(next+1)&3;
						last=next;
						last_gpstime_diff[last]=0;
						multi_extreme_counter[last]=0;
					}
					last_gpstime[last].i64=this_gpstime.i64;
				}
			}

			return true;
		}
        public override void read(laszip_point item)
        {
            uint sym = dec.decodeSymbol(m_byte_used);

            ushort[] item16 = item.rgb;

            if ((sym & (1 << 0)) != 0)
            {
                item16[0] = (ushort)ic_rgb.decompress(r & 255, 0);
            }
            else
            {
                item16[0] = (ushort)(r & 0xFF);
            }

            if ((sym & (1 << 1)) != 0)
            {
                item16[0] |= (ushort)(((ushort)ic_rgb.decompress(r >> 8, 1)) << 8);
            }
            else
            {
                item16[0] |= (ushort)(r & 0xFF00);
            }

            if ((sym & (1 << 2)) != 0)
            {
                item16[1] = (ushort)ic_rgb.decompress(g & 255, 2);
            }
            else
            {
                item16[1] = (ushort)(g & 0xFF);
            }

            if ((sym & (1 << 3)) != 0)
            {
                item16[1] |= (ushort)(((ushort)ic_rgb.decompress(g >> 8, 3)) << 8);
            }
            else
            {
                item16[1] |= (ushort)(g & 0xFF00);
            }

            if ((sym & (1 << 4)) != 0)
            {
                item16[2] = (ushort)ic_rgb.decompress(b & 255, 4);
            }
            else
            {
                item16[2] = (ushort)(b & 0xFF);
            }

            if ((sym & (1 << 5)) != 0)
            {
                item16[2] |= (ushort)(((ushort)ic_rgb.decompress(b >> 8, 5)) << 8);
            }
            else
            {
                item16[2] |= (ushort)(b & 0xFF00);
            }

            r = item16[0];
            g = item16[1];
            b = item16[2];
        }