从图像创建半透明光标
是否可以从图像创建光标并使其半透明?
我目前正在拍摄自定义图像并覆盖鼠标光标图像。 如果我可以将其设为半透明,那就太好了,但不是必需的。 销售人员喜欢闪亮的。
目前正在做这样的事情:
Image cursorImage = customImage.GetThumbnailImage(300, 100, null, IntPtr.Zero);
cursorImage.SetResolution(96.0F, 96.0F);
int midPointX = cursorImage.Width / 2;
int midPointY = cursorImage.Height / 2;
Bitmap cursorMouse = GetCursorImage(cursorOverlay);
Graphics cursorGfx = Graphics.FromImage(cursorImageCopy);
cursorGfx.DrawImageUnscaled(cursorMouse, midPointX, midPointY);
Cursor tmp = new Cursor(cursorImage.GetHicon());
Is it possible to create a cursor from an image and have it be semi-transparent?
I'm currently taking a custom image and overylaying the mouse cursor image. It would be great if I could make this semi-transparent, but not necessary. The sales guys love shiny.
Currently doing something like this:
Image cursorImage = customImage.GetThumbnailImage(300, 100, null, IntPtr.Zero);
cursorImage.SetResolution(96.0F, 96.0F);
int midPointX = cursorImage.Width / 2;
int midPointY = cursorImage.Height / 2;
Bitmap cursorMouse = GetCursorImage(cursorOverlay);
Graphics cursorGfx = Graphics.FromImage(cursorImageCopy);
cursorGfx.DrawImageUnscaled(cursorMouse, midPointX, midPointY);
Cursor tmp = new Cursor(cursorImage.GetHicon());
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我尝试过以下示例,效果很好...
我已将其放在按钮单击事件上(您可以从您喜欢的位置调用):
并且 Up.png 图像在 AdobePhotoshop 中以 75% 的不透明度保存。
I've tried following example, and it was working fine...
And i've put this on button click event (you can call from where you like):
And the Up.png image is saved with 75% opacity in AdobePhotoshop.
在我的头顶上(我会先尝试一下):
你应该有很好的那里有半透明位图。
如果性能允许,您可以扫描完全透明的像素并将它们的 A 设置为零!
On the top of my head (I would try that first):
You should have nice semitransparent bitmap there.
If performance allows, you can scan for fully transparent pixels and set A to zero for them!
如果您想“即时”设置自定义鼠标光标位图的透明度,您可能会发现此功能很有帮助。 它使用颜色矩阵来设置任何给定位图的透明度量,并将返回修改后的位图。 要获得一点透明度,TranspFactor 应介于 225 和 245 之间,只需尝试一下即可。 (您需要导入 System.Drawing 和 System.Drawing.Imaging)
{
}
If you want to set transparency of a custom mouse cursor bitmap 'on the fly' you may find this function helpful. It uses a color matrix to set the amount of transparency to any given bitmap and will return the modified one. To have just a touch of transparency the TranspFactor should be between 225 and 245, just try it out. (You need to import System.Drawing and System.Drawing.Imaging)
{
}
这很简单,我不使用 API。
代码是
我希望这是你的解决方案
that is very easy, I don't use API.
the code is
I hope that is your solution