Exemple #1
0
            public Reader(Stream input, GrxMetaData info)
            {
                m_input      = input;
                m_info       = info;
                m_pixel_size = (m_info.BPP + 7) / 8;
                switch (m_info.BPP)
                {
                case 32:
                    Format = PixelFormats.Bgr32;
                    break;

                case 24:
                    Format       = PixelFormats.Bgr32;
                    m_pixel_size = 4;
                    break;

                case 16:
                    Format = PixelFormats.Bgr565;
                    break;

                case 15:
                    Format = PixelFormats.Bgr555;
                    break;

                case 8:
                    Format = PixelFormats.Gray8;
                    break;

                default:
                    throw new InvalidFormatException();
                }
                m_aligned_width = ((int)m_info.Width + 3) & ~3;
                Stride          = m_aligned_width * m_pixel_size;
                m_output        = new byte[Stride * (int)info.Height];
            }
Exemple #2
0
            public Reader(Stream input, GrxMetaData info)
            {
                m_input = input;
                m_info  = info;
                m_input.Seek(0x10, SeekOrigin.Current);
                m_pixel_size = m_info.BPP / 8;
                switch (m_info.BPP)
                {
                case 32:
                    Format = PixelFormats.Bgr32;
                    break;

                case 24:
                    Format       = PixelFormats.Bgr32;
                    m_pixel_size = 4;
                    break;

                case 16:
                    Format = PixelFormats.Bgr565;
                    break;

                case 8:
                    Format = PixelFormats.Gray8;
                    break;

                default:
                    throw new InvalidFormatException();
                }
                m_aligned_width = (m_info.Width + 3u) & ~3u;
                Stride          = (int)(m_aligned_width * m_pixel_size);
                m_output        = new byte[Stride * (int)info.Height];
            }
Exemple #3
0
        internal GrxMetaData ReadInfo(IBinaryStream file)
        {
            var info = new GrxMetaData();

            info.IsPacked    = file.ReadByte() != 0;
            info.HasAlpha    = file.ReadByte() != 0;
            info.BPP         = file.ReadUInt16();
            info.Width       = file.ReadUInt16();
            info.Height      = file.ReadUInt16();
            info.AlphaOffset = file.ReadInt32();
            return(info);
        }