Quantcast
Channel: Questions in topic: "icon"
Viewing all articles
Browse latest Browse all 271

Copy cursor icon as bitmap using System.Drawing.Icon

$
0
0
I'm trying to get a bitmap copy of the cursor icon by using the Windows API methods GetCursorInfo() and CopyIcon(), and then using System.Drawing.Icon.FromHandle() to capture the bitmap. When I run this in a console application it works fine; however, when running in Unity the Icon.FromHandle() method fails. I've copied different versions of System.Drawing.dll into my assets folder, but haven't found a version that works. Any thoughts on how to make this work, or another way to capture the cursor icon? CURSORINFO cursorInfo = new CURSORINFO(); cursorInfo.cbSize = Marshal.SizeOf(cursorInfo); if (GetCursorInfo(ref cursorInfo)) { if (cursorInfo.flags == CURSOR_SHOWING) { IntPtr cursorHandle = CopyIcon(cursorInfo.hCursor); Icon ic = Icon.FromHandle(cursorHandle); Bitmap cursorBitmap = ic.ToBitmap(); } }

Viewing all articles
Browse latest Browse all 271

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>