当前位置: 首页>>代码示例>>C#>>正文


C# Surface.GetContainer方法代码示例

本文整理汇总了C#中Surface.GetContainer方法的典型用法代码示例。如果您正苦于以下问题:C# Surface.GetContainer方法的具体用法?C# Surface.GetContainer怎么用?C# Surface.GetContainer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Surface的用法示例。


在下文中一共展示了Surface.GetContainer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InitializeDevice

        public int InitializeDevice(IntPtr dwUserID, ref VMR9AllocationInfo lpAllocInfo, ref int lpNumBuffers)
        {
            int width = 1;
            int height = 1;
            float fTU = 1.0f;
            float fTV = 1.0f;

            if (vmrSurfaceAllocatorNotify == null)
            {
                return E_FAIL;
            }

            int hr = 0;

            try
            {
                IntPtr unmanagedDevice = device.GetObjectByValue(DxMagicNumber);
                IntPtr hMonitor = Manager.GetAdapterMonitor(adapterInfo.Adapter);

                hr = vmrSurfaceAllocatorNotify.SetD3DDevice(unmanagedDevice, hMonitor);
                DsError.ThrowExceptionForHR(hr);

                if (device.DeviceCaps.TextureCaps.SupportsPower2)
                {
                    while (width < lpAllocInfo.dwWidth)
                        width = width << 1;
                    while (height < lpAllocInfo.dwHeight)
                        height = height << 1;

                    fTU = (float)(lpAllocInfo.dwWidth) / (float)(width);
                    fTV = (float)(lpAllocInfo.dwHeight) / (float)(height);
                    scene.SetSrcRect(fTU, fTV);

                    lpAllocInfo.dwWidth = width;
                    lpAllocInfo.dwHeight = height;
                }

                // NOTE:
                // we need to make sure that we create textures because
                // surfaces can not be textured onto a primitive.
                lpAllocInfo.dwFlags |= VMR9SurfaceAllocationFlags.TextureSurface;

                DeleteSurfaces();

                unmanagedSurfaces = new IntPtr[lpNumBuffers];

                hr = vmrSurfaceAllocatorNotify.AllocateSurfaceHelper(ref lpAllocInfo, ref lpNumBuffers, unmanagedSurfaces);

                // If we couldn't create a texture surface and
                // the format is not an alpha format,
                // then we probably cannot create a texture.
                // So what we need to do is create a private texture
                // and copy the decoded images onto it.
                if (hr < 0)
                {
                    DeleteSurfaces();

                    FourCC fcc = new FourCC("0000");

                    // is surface YUV ?
                    if (lpAllocInfo.Format > fcc.ToInt32())
                    {
                        // create the private texture
                        privateTexture = new Texture(
                            device,
                            lpAllocInfo.dwWidth,
                            lpAllocInfo.dwHeight,
                            1,
                            Usage.RenderTarget,
                            adapterInfo.CurrentDisplayMode.Format,
                            Pool.Default
                            );

                        privateSurface = privateTexture.GetSurfaceLevel(0);
                    }

                    lpAllocInfo.dwFlags &= ~VMR9SurfaceAllocationFlags.TextureSurface;
                    lpAllocInfo.dwFlags |= VMR9SurfaceAllocationFlags.OffscreenSurface;

                    unmanagedSurfaces = new IntPtr[lpNumBuffers];

                    hr = vmrSurfaceAllocatorNotify.AllocateSurfaceHelper(ref lpAllocInfo, ref lpNumBuffers, unmanagedSurfaces);
                    if (hr < 0)
                        return hr;
                }
                else
                {
                    surfaces = new Hashtable(unmanagedSurfaces.Length);
                    textures = new Hashtable(unmanagedSurfaces.Length);

                    for (int i = 0; i < lpNumBuffers; i++)
                    {
                        Surface surf = new Surface(unmanagedSurfaces[i]);
                        Texture text = (Texture) surf.GetContainer(new Guid("85C31227-3DE5-4f00-9B3A-F11AC38C18B5"));
                        surfaces.Add(unmanagedSurfaces[i], surf);
                        textures.Add(unmanagedSurfaces[i], text);
                    }
                }

                return scene.Init(device);
//.........这里部分代码省略.........
开发者ID:coolsula,项目名称:vidplaycorder,代码行数:101,代码来源:Allocator.cs


注:本文中的Surface.GetContainer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。