这是我在uni的第一个图形主题,并且实现的某些部分对我不起作用.我可以正确地绘制关节,但我正在尝试编写一个在关节之间放入"骨骼"的函数.在这一点上,骨头只是立方体,被转换为矩形棱柱,稍后我将尝试从搅拌机或其他东西引入适当的模型.
我的麻烦在于轮换.大约5个小时左右后,我的伴侣和我有一些工作,但是一旦你移动你的手臂或腿,立方体就会扭曲并看起来很奇怪.任何帮助,将不胜感激.以下是尝试绘制骨骼的功能.
private void DrawBone(Skeleton skeleton, JointType jointType0, JointType jointType1)
{
Joint joint0 = skeleton.Joints[jointType0];
Joint joint1 = skeleton.Joints[jointType1];
// If we can't find either of these joints, exit
if (joint0.TrackingState == JointTrackingState.NotTracked ||
joint1.TrackingState == JointTrackingState.NotTracked)
{
return;
}
// Don't draw if both points are inferred
if (joint0.TrackingState == JointTrackingState.Inferred &&
joint1.TrackingState == JointTrackingState.Inferred)
{
return;
}
// We assume all drawn bones are inferred unless BOTH joints are tracked
if (joint0.TrackingState == JointTrackingState.Tracked && joint1.TrackingState == JointTrackingState.Tracked) …Run Code Online (Sandbox Code Playgroud) 是否可以使用C#编写Windows 8 RT和/或Windows 8 Phone游戏?
我想调整使用SharpDX中的桌面复制API捕获的屏幕.我正在使用SharpDX Samples存储库中的Screen Capture示例代码,相关部分如下:
SharpDX.DXGI.Resource screenResource;
OutputDuplicateFrameInformation duplicateFrameInformation;
// Try to get duplicated frame within given time
duplicatedOutput.AcquireNextFrame(10000, out duplicateFrameInformation, out screenResource);
if (i > 0)
{
// copy resource into memory that can be accessed by the CPU
using (var screenTexture2D = screenResource.QueryInterface<Texture2D>())
device.ImmediateContext.CopyResource(screenTexture2D, screenTexture);
// Get the desktop capture texture
var mapSource = device.ImmediateContext.MapSubresource(screenTexture, 0, MapMode.Read, MapFlags.None);
System.Diagnostics.Debug.WriteLine(watch.Elapsed);
// Create Drawing.Bitmap
var bitmap = new System.Drawing.Bitmap(width, height, PixelFormat.Format32bppArgb);
var boundsRect = new System.Drawing.Rectangle(0, 0, width, …Run Code Online (Sandbox Code Playgroud) 使用C#或VB.NET.我正在尝试使表单的背景透明; 这个表单将叠加到其他窗口,它将是最顶层的窗口,因此透明表单(及其控件)必须具有不能获得焦点的能力,并且必须可以单击它们,这意味着如果例如我在透明背景上执行左键单击,然后在该背景上的窗口(在Z顺序窗口中)是必须接收单击的窗口.
笔记:
为了避免焦点,我正在覆盖这里CreateParams所解释的财产.
为了使我的形式透明,我打电话的Win32 DwmExtendFrameIntoClientArea函数,并且还使用SharpDX库作为解释在这里.但我认为这与问题本身无关.
我将展示我使用图像的意思.下面是与文本编辑器程序窗口重叠的表单图像(没有透明度,只是为了简化理解); 请注意,我的表单没有获得焦点.好吧,问题是当我点击表单的背景(或其中一个控件)时,背景上的窗口(文本编辑器窗口)仍然具有焦点但它无法接收到点击.
这是上面相同的图像,但是透明的形式:
我不确定要调查什么,所以我试图通过覆盖透明窗体的Window过程(WndProc)来测试相关的窗口消息,例如WM_NCHITEST或者试图在试错阶段找到有用的东西.WM_MOUSEACTIVATE消息如下所述:
我在C#中创建了一个图像服务,它采用了基础层图像(JPG),将一个更透明的PNG层(32位)分层,然后输出最终的JPG图像.我试图从这个函数中挤出最后一毫秒,我的代码是GDI +中DrawImage调用的瓶颈.托管代码在这里:
// Load base image and create graphics
Image image = LoadImage(renderSettings.RenderedImageDirectory + baseLayer);
Graphics graphics = Graphics.FromImage(image);
graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighSpeed;
// Draw additional layers to final image
for (int i = 1; i < renderLayers.Count; i++) {
// SLOW -- LoadImage just a utility method that returns an Image from disk or cache
graphics.DrawImage(LoadImage(renderSettings.RenderedImageDirectory + renderLayers[i]), 0, 0, image.Width, image.Height);
}
if (graphics != null) graphics.Dispose();
Run Code Online (Sandbox Code Playgroud)
现在,我读到了通过P/Invoke直接调用GDI获得的性能提升,并试图替换DrawImage调用.我创建了一个单元测试,试图复制加载JPG的相同功能,然后在其上层叠一个透明PNG.
参考:http …
考虑给定的临时程序使用SharpDX(Direct*库的托管包装器)来渲染位图并将其保存为PNG:
namespace ConsoleApplication5
{
using System;
using System.Diagnostics;
using System.IO;
using SharpDX;
using SharpDX.Direct2D1;
using SharpDX.DirectWrite;
using SharpDX.DXGI;
using SharpDX.IO;
using SharpDX.WIC;
using AlphaMode = SharpDX.Direct2D1.AlphaMode;
using Bitmap = SharpDX.WIC.Bitmap;
using D2DPixelFormat = SharpDX.Direct2D1.PixelFormat;
using WicPixelFormat = SharpDX.WIC.PixelFormat;
class Program
{
static void Main(string[] args)
{
var width = 400;
var height = 100;
var pixelFormat = WicPixelFormat.Format32bppBGR;
var wicFactory = new ImagingFactory();
var dddFactory = new SharpDX.Direct2D1.Factory();
var dwFactory = new SharpDX.DirectWrite.Factory();
var wicBitmap = new …Run Code Online (Sandbox Code Playgroud) 我正在寻找一种在鼠标点读取像素颜色的方法.在OpenGL中,它是在绘制场景(或部分场景)后调用函数"glReadPixels"完成的.我想在后台制作一个简单的颜色拾取程序,用于识别3D空间中的形状/线条.
那么,在SharpDX(DirectX10/DirectX11)中是否有相同的方法/功能/建议?
我是DirectX的新手,并尝试使用SharpDX使用Desktop Duplication API捕获屏幕截图.
我想知道是否有任何简单的方法来创建我可以在CPU中使用的位图(即保存在文件等)
我使用以下代码获取桌面屏幕截图:
var factory = new SharpDX.DXGI.Factory1();
var adapter = factory.Adapters1[0];
var output = adapter.Outputs[0];
var device = new SharpDX.Direct3D11.Device(SharpDX.Direct3D.DriverType.Hardware,
DeviceCreationFlags.BgraSupport |
DeviceCreationFlags.Debug);
var dev1 = device.QueryInterface<SharpDX.DXGI.Device1>();
var output1 = output.QueryInterface<Output1>();
var duplication = output1.DuplicateOutput(dev1);
OutputDuplicateFrameInformation frameInfo;
SharpDX.DXGI.Resource desktopResource;
duplication.AcquireNextFrame(50, out frameInfo, out desktopResource);
var desktopSurface = desktopResource.QueryInterface<Surface>();
Run Code Online (Sandbox Code Playgroud)
任何人都可以给我一些关于如何从desktopSurface(DXGI.Surface实例)创建位图对象的想法?
我正在使用SharpDx将DX内容呈现给WPF应用程序.当我在VS2010中将窗口模式设置为最大化时,直到我手动调整窗口大小才会显示内容.如果我在VS2010中将窗口模式设置为Normal,它可以正常工作.这也发生在SharpDX WPF样本中.
使用最大化窗口模式时,我可以手动调整窗口大小,然后显示SharpDX内容.
使用普通窗口时,我可以使用最大化按钮,一切正常.这只发生在我将窗口模式设置为VS2010内的最大化并尝试运行时.
我的应用程序的用户在使用DesktopDuplication API.
开始捕获时,应用程序崩溃,因为应用程序无法释放OutputDuplication.
用户的PC详细信息:
Windows 10.0.18362.0, 64 bits
Nvidia GeForce GTX 960, driver version 441.66
Run Code Online (Sandbox Code Playgroud)
错误日志:
? Message -
HRESULT: [0x887A0001], Module: [SharpDX.DXGI], ApiCode: [DXGI_ERROR_INVALID_CALL/InvalidCall],
Message: The application made a call that is invalid. Either the parameters of the call or the state of some object was incorrect.
Enable the D3D debug layer in order to see details via debug messages.
? Type -
SharpDX.SharpDXException
? Source -
SharpDX
? TargetSite -
Void CheckError()
? StackTrace …Run Code Online (Sandbox Code Playgroud)