Beispiel #1
0
            public Reader(Stream input, CpbMetaData info)
            {
                m_width   = (int)info.Width;
                m_height  = (int)info.Height;
                m_info    = info;
                m_bpp     = info.BPP;
                m_channel = info.Channel;
                m_output  = new byte[m_width * m_height * 4];
                if (8 == m_bpp)
                {
                    Format = PixelFormats.Indexed8;
                }
                else if (24 == m_bpp)
                {
                    Format = PixelFormats.Bgr32;
                }
                else
                {
                    Format = PixelFormats.Bgra32;
                }
                m_input          = input;
                m_input.Position = info.DataOffset;

                if (1 == m_info.Version)
                {
                    StreamMap  = new byte[] { 0, 3, 1, 2 };
                    ChannelMap = new byte[] { 3, 0, 1, 2 };
                }
                else
                {
                    StreamMap  = new byte[] { 0, 1, 2, 3 };
                    ChannelMap = new byte[] { 2, 1, 0, 3 };
                }
            }
Beispiel #2
0
        public override ImageMetaData ReadMetaData(Stream stream)
        {
            stream.Seek(5, SeekOrigin.Current);
            int bpp = stream.ReadByte();

            if (24 != bpp && 32 != bpp)
            {
                throw new NotSupportedException("Not supported CPB image format");
            }
            using (var input = new ArcView.Reader(stream))
            {
                int version = input.ReadInt16();
                if (1 != version)
                {
                    throw new NotSupportedException("Not supported CPB image version");
                }
                var info = new CpbMetaData();
                info.BPP = bpp;
                input.ReadUInt32();
                info.Width      = input.ReadUInt16();
                info.Height     = input.ReadUInt16();
                info.Channel[0] = input.ReadUInt32(); // Alpha
                info.Channel[1] = input.ReadUInt32();
                info.Channel[2] = input.ReadUInt32();
                info.Channel[3] = input.ReadUInt32();
                return(info);
            }
        }
Beispiel #3
0
        public override ImageMetaData ReadMetaData(IBinaryStream file)
        {
            file.Position = 4;
            int type = file.ReadByte();
            int bpp  = file.ReadByte();

            if (24 != bpp && 32 != bpp)
            {
                throw new NotSupportedException("Not supported CPB image format");
            }
            int version = file.ReadInt16();

            if (1 != version && 0 != version)
            {
                throw new NotSupportedException("Not supported CPB image version");
            }
            var info = new CpbMetaData {
                Type    = type,
                Version = version,
                BPP     = bpp,
            };

            if (1 == version)
            {
                file.ReadUInt32();
                info.Width      = file.ReadUInt16();
                info.Height     = file.ReadUInt16();
                info.Channel[0] = file.ReadUInt32();
                info.Channel[1] = file.ReadUInt32();
                info.Channel[2] = file.ReadUInt32();
                info.Channel[3] = file.ReadUInt32();
            }
            else
            {
                info.Width  = file.ReadUInt16();
                info.Height = file.ReadUInt16();
                file.ReadUInt32();
                info.Channel[0] = file.ReadUInt32();
                info.Channel[1] = file.ReadUInt32();
                info.Channel[2] = file.ReadUInt32();
                info.Channel[3] = file.ReadUInt32();
            }
            info.DataOffset = (uint)file.Position;
            return(info);
        }
Beispiel #4
0
 public Reader(Stream input, CpbMetaData info)
 {
     m_width   = (int)info.Width;
     m_height  = (int)info.Height;
     m_bpp     = info.BPP;
     m_channel = info.Channel;
     m_output  = new byte[m_width * m_height * 4];
     if (8 == m_bpp)
     {
         Format = PixelFormats.Indexed8;
     }
     else if (24 == m_bpp)
     {
         Format = PixelFormats.Bgr32;
     }
     else
     {
         Format = PixelFormats.Bgra32;
     }
     m_input = input;
 }
Beispiel #5
0
 public override ImageMetaData ReadMetaData(Stream stream)
 {
     stream.Seek (4, SeekOrigin.Current);
     int type = stream.ReadByte();
     int bpp = stream.ReadByte();
     if (24 != bpp && 32 != bpp)
         throw new NotSupportedException ("Not supported CPB image format");
     using (var input = new ArcView.Reader (stream))
     {
         int version = input.ReadInt16 ();
         if (1 != version && 0 != version)
             throw new NotSupportedException ("Not supported CPB image version");
         var info = new CpbMetaData {
             Type = type,
             Version = version,
             BPP = bpp,
         };
         if (1 == version)
         {
             input.ReadUInt32();
             info.Width  = input.ReadUInt16();
             info.Height = input.ReadUInt16();
             info.Channel[0] = input.ReadUInt32();
             info.Channel[1] = input.ReadUInt32();
             info.Channel[2] = input.ReadUInt32();
             info.Channel[3] = input.ReadUInt32();
         }
         else
         {
             info.Width  = input.ReadUInt16();
             info.Height = input.ReadUInt16();
             input.ReadUInt32();
             info.Channel[0] = input.ReadUInt32();
             info.Channel[1] = input.ReadUInt32();
             info.Channel[2] = input.ReadUInt32();
             info.Channel[3] = input.ReadUInt32();
         }
         info.DataOffset = (uint)stream.Position;
         return info;
     }
 }
Beispiel #6
0
            public Reader(Stream input, CpbMetaData info)
            {
                m_width = (int)info.Width;
                m_height = (int)info.Height;
                m_info = info;
                m_bpp = info.BPP;
                m_channel = info.Channel;
                m_output = new byte[m_width * m_height * 4];
                if (8 == m_bpp)
                    Format = PixelFormats.Indexed8;
                else if (24 == m_bpp)
                    Format = PixelFormats.Bgr32;
                else
                    Format = PixelFormats.Bgra32;
                m_input = input;
                m_input.Position = info.DataOffset;

                if (1 == m_info.Version)
                {
                    StreamMap  = new byte[] { 0, 3, 1, 2 };
                    ChannelMap = new byte[] { 3, 0, 1, 2 };
                }
                else
                {
                    StreamMap  = new byte[] { 0, 1, 2, 3 };
                    ChannelMap = new byte[] { 2, 1, 0, 3 };
                }
            }