Esempio n. 1
0
        public bool Read(BinaryReader binreader)
        {
            if (dds_id != binreader.ReadUInt32())
            {
                binreader.BaseStream.Position -= 4;
                return(false);
            }

            binreader.BaseStream.Position = 8;                      //  Skip ahead to data
            flags        = binreader.ReadUInt32();
            height       = binreader.ReadUInt32();
            width        = binreader.ReadUInt32();
            pitch        = binreader.ReadUInt32();
            depth        = binreader.ReadUInt32();
            mipmap_count = binreader.ReadUInt32();
            reserved     = new Res();                               //  This isn't used
            binreader.BaseStream.Position += 44;                    //  Skip ahead
            pixel_format = new DDS_PF();
            pixel_format.Read(binreader);                           //  Pixel format
            caps      = binreader.ReadUInt32();
            caps2     = binreader.ReadUInt32();
            caps3     = binreader.ReadUInt32();
            caps4     = binreader.ReadUInt32();
            reserved2 = binreader.ReadUInt32();

            return(true);
        }
Esempio n. 2
0
        public Header(int w, int h, int mipmaps, int depth, bool hasalpha)
        {
            flags += (uint)(format.DDSD_CAPS | format.DDSD_HEIGHT | format.DDSD_WIDTH);
            flags += (uint)format.DDSD_PIXELFORMAT;
            flags += (uint)format.DDSD_LINEARSIZE;
            caps   = (uint)capstype.DDSCAPS_TEXTURE;

            if (mipmaps > 1)
            {
                flags += (uint)(format.DDSD_MIPMAPCOUNT);
                caps  += (uint)(capstype.DDSCAPS_MIPMAP | capstype.DDSCAPS_COMPLEX);
            }

            width  = (uint)w;
            height = (uint)h;

            //  compute the pitch as:
            //  ( width * bits-per-pixel + 7 ) / 8    but this shouldnt be done unless we have a compressed texture, and we dont use those with madden.
            pitch        = 0;
            mipmap_count = (uint)mipmaps;
            reserved     = new Res();
            pixel_format = new DDS_PF();
            pixel_format.pf_RGB_bitcount = (uint)depth;
            if (depth == 24)
            {
                pixel_format.pf_RGB_bitcount = 32;
            }

            pixel_format.pf_flags = (uint)pformat.DDPF_PALETTEINDEXED8;

            if (pixel_format.pf_RGB_bitcount == 4)
            {
                pixel_format.pf_flags = (uint)pformat.DDPF_PALETTEINDEXEDTO8;
            }

            if (pixel_format.pf_RGB_bitcount == 32)
            {
                pixel_format.pf_flags = (uint)(pformat.DDPF_RGB);

                if (hasalpha)
                {
                    pixel_format.pf_flags += (uint)pformat.DDPF_ALPHAPIXELS;
                }

                pixel_format.pf_A_Bitmask = 0xff000000;
                pixel_format.pf_R_Bitmask = 0x00ff0000;
                pixel_format.pf_G_Bitmask = 0x0000ff00;
                pixel_format.pf_B_Bitmask = 0x000000ff;
            }

            pixel_format.pf_fourcc = 0;

            caps2     = 0;
            caps3     = 0;
            caps4     = 0;
            reserved2 = 0;
        }
Esempio n. 3
0
        public Header(bitmapindex bmt, paletteindex pt, fileindex ft, bool containsalpha)
        {
            flags  = (uint)(format.DDSD_CAPS | format.DDSD_HEIGHT | format.DDSD_WIDTH);
            flags += (uint)format.DDSD_PIXELFORMAT;
            caps   = (uint)capstype.DDSCAPS_TEXTURE;

            if (ft.GfxMipmaps > 1)
            {
                flags += (uint)(format.DDSD_MIPMAPCOUNT);
                caps  += (uint)(capstype.DDSCAPS_MIPMAP | capstype.DDSCAPS_COMPLEX);
            }

            height                       = bmt.BitMapHeight;
            width                        = bmt.BitMapWidth;
            pitch                        = 0;
            depth                        = 0;
            mipmap_count                 = ft.GfxMipmaps;
            reserved                     = new Res();
            pixel_format                 = new DDS_PF();
            pixel_format.pf_size         = 32;
            pixel_format.pf_RGB_bitcount = 8;
            pixel_format.pf_flags        = (uint)pformat.DDPF_PALETTEINDEXED8;
            if (bmt.BitMapFormat == 5)
            {
                pixel_format.pf_RGB_bitcount = 4;
                pixel_format.pf_flags        = (uint)pformat.DDPF_PALETTEINDEXEDTO8;
            }
            if (bmt.BitMapFormat == 32)
            {
                pixel_format.pf_RGB_bitcount = 32;
                pixel_format.pf_flags        = (uint)(pformat.DDPF_RGB);

                if (containsalpha)
                {
                    pixel_format.pf_flags += (uint)pformat.DDPF_ALPHAPIXELS;
                }

                pixel_format.pf_A_Bitmask = 0xff000000;
                pixel_format.pf_R_Bitmask = 0x00ff0000;
                pixel_format.pf_G_Bitmask = 0x0000ff00;
                pixel_format.pf_B_Bitmask = 0x000000ff;
            }

            pixel_format.pf_fourcc = 0;
            caps2     = 0;
            caps3     = 0;
            caps4     = 0;
            reserved2 = 0;
        }
Esempio n. 4
0
 public Header()
 {
     flags        = 0;
     height       = 0;
     width        = 0;
     pitch        = 0;
     depth        = 0;
     mipmap_count = 0;
     reserved     = new Res();
     pixel_format = new DDS_PF();
     caps         = 0;
     caps2        = 0;
     caps3        = 0;
     caps4        = 0;
     reserved2    = 0;
 }