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


C# Surface.GetObjectByValue方法代码示例

本文整理汇总了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);
        }
开发者ID:adambyram,项目名称:pimaker,代码行数:24,代码来源:MainForm.cs

示例2: GetUnmanagedSurface

 public static IntPtr GetUnmanagedSurface(Surface surface)
 {
   return surface.GetObjectByValue(magicConstant);
 }
开发者ID:npcomplete111,项目名称:MediaPortal-1,代码行数:4,代码来源:DirectShowUtil.cs

示例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);
 }
开发者ID:jiashida,项目名称:Camera_Net,代码行数:11,代码来源:Direct3DMixing.cs

示例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
            );
//.........这里部分代码省略.........
开发者ID:OmerMor,项目名称:DirectShowLib-FORK,代码行数:101,代码来源:Allocator.cs


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