本文整理汇总了C#中Surface.GetObjectByValue方法的典型用法代码示例。如果您正苦于以下问题:C# Surface.GetObjectByValue方法的具体用法?C# Surface.GetObjectByValue怎么用?C# Surface.GetObjectByValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Surface
的用法示例。
在下文中一共展示了Surface.GetObjectByValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitializeDirect3D
private void InitializeDirect3D()
{
Device.IsUsingEventHandlers = false;
// Basic Presentation Parameters...
presentParams = new PresentParameters();
presentParams.Windowed = true;
presentParams.SwapEffect = SwapEffect.Discard;
// Assume a hardware Direct3D device is available
// Add MultiThreaded to be safe. Each DirectShow filter runs in a separate thread...
device = new Device(
0,
DeviceType.Hardware,
this,
CreateFlags.SoftwareVertexProcessing | CreateFlags.MultiThreaded,
presentParams
);
// Create a surface from our alpha bitmap
surface = new Surface(device, alphaBitmap, Pool.SystemMemory);
// Get the unmanaged pointer
unmanagedSurface = surface.GetObjectByValue(DxMagicNumber);
}
示例2: GetUnmanagedSurface
public static IntPtr GetUnmanagedSurface(Surface surface)
{
return surface.GetObjectByValue(magicConstant);
}
示例3: StoreBitmapToSurface
/// <summary>
/// Stores an image (bitmap) to Direct3D surface.
/// </summary>
/// <param name="alphaBitmap">Bitmap to store to DX surface.</param>
public void StoreBitmapToSurface(Bitmap alphaBitmap)
{
// Create a surface from our alpha bitmap
surface = new Surface(device, alphaBitmap, Pool.SystemMemory);
// Get the unmanaged pointer
unmanagedSurface = surface.GetObjectByValue(DxMagicNumber);
}
示例4: InitializeDevice
public int InitializeDevice(IntPtr dwUserID, ref VMR9AllocationInfo lpAllocInfo, ref int lpNumBuffers)
{
int hr = 0;
Debug.WriteLine(string.Format("{0}x{1} : {2} / {3} / 0x{4:x}", lpAllocInfo.dwWidth, lpAllocInfo.dwHeight, FourCCToStr(lpAllocInfo.Format), lpAllocInfo.Pool, lpAllocInfo.dwFlags));
// The allocator sometime call this method with invalid pool value (4 for me). Don't ask me why!
// If the pool is invalid, return an error now to avoid an exception later in the code.
if ((lpAllocInfo.Pool < 0) || (lpAllocInfo.Pool > 3))
return D3DERR_INVALIDCALL;
// if format is YUV ? (note : 0x30303030 = " ")
if (lpAllocInfo.Format > 0x30303030)
{
// Check if the hardware support format conversion from this YUV format to the RGB desktop format
if (!Manager.CheckDeviceFormatConversion(creationParameters.AdapterOrdinal, creationParameters.DeviceType, (Format)lpAllocInfo.Format, adapterInfo.CurrentDisplayMode.Format))
{
// If not, refuse this format!
// The VMR9 will propose other formats supported by the downstream filter output pin.
return D3DERR_INVALIDCALL;
}
}
try
{
IntPtr unmanagedDevice = device.GetObjectByValue(DxMagicNumber);
IntPtr hMonitor = Manager.GetAdapterMonitor(adapterInfo.Adapter);
// Give our Direct3D device to the VMR9 filter
hr = vmrSurfaceAllocatorNotify.SetD3DDevice(unmanagedDevice, hMonitor);
DsError.ThrowExceptionForHR(hr);
videoSize = new Size(lpAllocInfo.dwWidth, lpAllocInfo.dwHeight);
int width = 1;
int height = 1;
// If hardware require textures to power of two sized
if (device.DeviceCaps.TextureCaps.SupportsPower2)
{
// Compute the ideal size
while (width < lpAllocInfo.dwWidth)
width = width << 1;
while (height < lpAllocInfo.dwHeight)
height = height << 1;
// notify this change to the VMR9 filter
lpAllocInfo.dwWidth = width;
lpAllocInfo.dwHeight = height;
}
textureSize = new Size(lpAllocInfo.dwWidth, lpAllocInfo.dwHeight);
// Just in case
DeleteSurfaces();
// if format is YUV ?
if (lpAllocInfo.Format > 0x30303030)
{
// An offscreen surface must be created
lpAllocInfo.dwFlags |= VMR9SurfaceAllocationFlags.OffscreenSurface;
// Create it
videoSurface = device.CreateOffscreenPlainSurface(lpAllocInfo.dwWidth, lpAllocInfo.dwHeight, (Format)lpAllocInfo.Format, (Pool)lpAllocInfo.Pool);
// And get it unmanaged pointer
unmanagedSurface = videoSurface.GetObjectByValue(DxMagicNumber);
// Then create a private texture for the client application
privateTexture = new Texture(
device,
lpAllocInfo.dwWidth,
lpAllocInfo.dwHeight,
1,
Usage.RenderTarget,
adapterInfo.CurrentDisplayMode.Format,
Pool.Default
);
// Get the MipMap surface 0 for the copy (see PresentImage)
privateSurface = privateTexture.GetSurfaceLevel(0);
// This code path need a surface copy
needCopy = true;
}
else
{
// in RGB pixel format
lpAllocInfo.dwFlags |= VMR9SurfaceAllocationFlags.TextureSurface;
// Simply create a texture
privateTexture = new Texture(
device,
lpAllocInfo.dwWidth,
lpAllocInfo.dwHeight,
1,
Usage.RenderTarget,
adapterInfo.CurrentDisplayMode.Format,
Pool.Default
);
//.........这里部分代码省略.........