Example #1
0
        public static void ToGtexHeader(DdsHeader header, GtexHeader output)
        {
            output.Width = (short)header.Width;
            output.Height = (short)header.Height;
            //output.Depth = (short)header.Depth;
            if (header.MipMapCount > 1)
                throw new NotImplementedException();
            //output.LinerSize = header.PitchOrLinearSize;

            //if (header.MipMapCount > 0)
            //    output.MipMapCount = (byte)header.MipMapCount;

            if ((header.CubemapFlags & DdsHeaderCubemapFlags.Cubemap) == DdsHeaderCubemapFlags.Cubemap)
                output.IsCubeMap = true;

            if (header.PixelFormat.Equals(DdsPixelFormat.DXT1))
                output.Format = GtexPixelFromat.Dxt1;
            else if (header.PixelFormat.Equals(DdsPixelFormat.DXT3))
                output.Format = GtexPixelFromat.Dxt3;
            else if (header.PixelFormat.Equals(DdsPixelFormat.DXT5))
                output.Format = GtexPixelFromat.Dxt5;
            else if (header.PixelFormat.Equals(DdsPixelFormat.X8R8G8B8))
                output.Format = GtexPixelFromat.X8R8G8B8;
            else
                throw new NotImplementedException();
        }
Example #2
0
        public static DdsHeader FromGtexHeader(GtexHeader header)
        {
            DdsHeader result = DdsHeader.Create();

            result.Width = header.Width;
            result.Flags |= DdsHeaderFlags.Width;

            result.Height = header.Height;
            result.Flags |= DdsHeaderFlags.Height;

            result.Depth = header.Depth;
            result.Flags |= DdsHeaderFlags.Depth;

            result.PitchOrLinearSize = header.LinerSize;
            result.Flags |= DdsHeaderFlags.LinearSize;

            if (header.MipMapCount > 0)
            {
                result.MipMapCount = header.MipMapCount;
                result.Flags |= DdsHeaderFlags.MipMapCount;
                result.SurfaceFlags |= DdsHeaderSurfaceFlags.Mipmap | DdsHeaderSurfaceFlags.Complex;
            }

            if (header.IsCubeMap)
            {
                result.SurfaceFlags |= DdsHeaderSurfaceFlags.Complex;
                result.CubemapFlags = DdsHeaderCubemapFlags.AllCubemapFaces;
            }

            switch (header.Format)
            {
                case GtexPixelFromat.Dxt1:
                    result.PixelFormat = DdsPixelFormat.DXT1;
                    result.Flags |= DdsHeaderFlags.PixelFormat;
                    break;
                case GtexPixelFromat.Dxt3:
                    result.PixelFormat = DdsPixelFormat.DXT3;
                    result.Flags |= DdsHeaderFlags.PixelFormat;
                    break;
                case GtexPixelFromat.Dxt5:
                    result.PixelFormat = DdsPixelFormat.DXT5;
                    result.Flags |= DdsHeaderFlags.PixelFormat;
                    break;
                case GtexPixelFromat.X8R8G8B8:
                    result.PixelFormat = DdsPixelFormat.X8R8G8B8;
                    result.Flags |= DdsHeaderFlags.PixelFormat;
                    break;
                case GtexPixelFromat.A8R8G8B8:
                    result.PixelFormat = DdsPixelFormat.A8R8G8B8;
                    result.Flags |= DdsHeaderFlags.PixelFormat;
                    break;
                default:
                    throw new NotSupportedException();
            }

            return result;
        }
Example #3
0
 public void ReadFromStream(Stream input)
 {
     Header     = input.ReadContent <GtexHeader>();
     MipMapData = input.ReadContent <GtexMipMapLocation>(Header.LayerCount);
 }
Example #4
0
 public void ReadFromStream(Stream input)
 {
     Header = input.ReadContent<GtexHeader>();
     MipMapData = input.ReadContent<GtexMipMapLocation>(Header.LayerCount);
 }