如何获得数位板笔压力值

如何获得数位板笔压力值

本文介绍了如何获得数位板笔压力值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Wacom Bamboo Pen 数位板,我希望能够在我用 C# 编写的应用程序中获得它的笔压力值.我怎么做?是否有允许在 Windows 7 上获取笔值的 API?

I'm using a Wacom Bamboo Pen tablet and I'd like to be able to get its pen pressure value in my application written in C#. How do I do that? Is there maybe an API that allows one to get pen values on Windows 7?

推荐答案

Wacom 提供了扩展 API直接从平板电脑获取数据.API 包括用于检测压力、倾斜和其他交互的示例代码:

Wacom provides an extensive API to get data directly from the tablet.The API includes example code for detecting pressure, tilt and other interactions:

这些代码示例是用 C 语言编写的,但在 c#.net 中也有包含处理压力的代码的示例:

These code samples are in C, but there are also examples that in c#.net that include code to handle pressure:

  • WintabDN:界面、涂鸦和平板电脑使用 Wintab .NET 的控制样本

以这个项目为例,你可以得到这样的压力:

Using this project as an example, you can get the pressure like this:

// Create a data object and hook a packetlistener to receive
// updatse by the tablet
m_wtData = new CWintabData();
m_wtData.SetWTPacketEventHandler(handler);

//Handles packet receive event
void handler(object sender,MessageReceivedEventArgs e)
{
     //Get the packet id
     uint pktID = (uint)eventArgs_I.Message.WParam;

     //Get the data for that packet
     WintabPacket pkt = m_wtData.GetDataPacket((uint)eventArgs_I.Message.LParam, pktID);

     //Grab the pressure
     var pressure = pk.pkNormalPressure.pkAbsoluteNormalPressure;
}

接下来,这是一个 CodeProject解释了如何将 Wacom 数位板与 WPF InkCanvas

Next, here is a CodeProject that explains how to use the Wacom Tablet with the WPF InkCanvas

Windows 上与平板电脑相关的任何开发的良好起点也是 Ink API.

A good starting point for any tablet related development on windows is also the Ink API.

这篇关于如何获得数位板笔压力值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-26 13:00