本文整理汇总了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);
//.........这里部分代码省略.........