相关疑难解决方法(0)

用Java提取光标图像

我想知道是否有办法从Java中的Cursor对象中提取Image对象.

例如:用于此目的:

Image img = extractCursorImage(Cursor.getDefaultCursor());
Run Code Online (Sandbox Code Playgroud)

然后,您可以在工具栏按钮上绘制(这是我想要的目的).

c++ java winapi

7
推荐指数
1
解决办法
4023
查看次数

如何获得鼠标光标图标VS C++

我使用此代码在屏幕上获取鼠标位置并且它正在工作。我也得到光标的宽度和高度。我需要的是在调用函数 GetIconInfo 时的光标图标。在 ii iI 中有 ii.hbmColor 和 ii.hbmMask。hbmColor 的值为 0x0,hbmMask 的值为 0x2f0517f1。我可以从那两个指针中提取鼠标光标吗?如何提取?

  CURSORINFO cursorInfo = { 0 };
  cursorInfo.cbSize = sizeof(cursorInfo);

  HDC memoryDC = (HDC)malloc(100);
  memset(memoryDC, 0x00, 100);

  if (::GetCursorInfo(&cursorInfo))  {
    ICONINFO ii = {0};
    GetIconInfo(cursorInfo.hCursor, &ii);

    BITMAP bm;
    GetObject(ii.hbmMask,sizeof(BITMAP),&bm);

    DeleteObject(ii.hbmColor);
    DeleteObject(ii.hbmMask);
    ::DrawIcon(memoryDC, cursorInfo.ptScreenPos.x - ii.xHotspot, cursorInfo.ptScreenPos.y - ii.yHotspot, cursorInfo.hCursor);


    for(int i = 0; i < bm.bmWidth; i++){
        for(int j = 0; j < bm.bmHeight; j++){
            COLORREF c = GetPixel(memoryDC, i, j);
            printf("%x", c);

        }
    }
  }
Run Code Online (Sandbox Code Playgroud)

c++ windows mouse cursor

5
推荐指数
1
解决办法
8050
查看次数

WinAPI 获取鼠标光标图标

我想在 Windows 中获取光标图标。我认为我在这里使用的语言不是很重要,所以我将只使用我尝试使用的 WinAPI 函数编写伪代码:

c = CURSORINFO.new(20, 1, 1, POINT.new(1,1));
GetCursorInfo(c); #provides correctly filled structure with hCursor

DrawIcon(GetWindowDC(GetForegroundWindow()), 1, 1, c.hCursor);
Run Code Online (Sandbox Code Playgroud)

所以这部分工作正常,它在活动窗口上绘制当前光标。但这不是我想要的。我想得到一个像素数组,所以我应该在内存中绘制它。

我正在尝试这样做:

hdc = CreateCompatibleDC(GetDC(0)); #returns non-zero int
canvas = CreateCompatibleBitmap(hdc, 256, 256); #returns non-zero int too

c = CURSORINFO.new(20, 1, 1, POINT.new(1,1));
GetCursorInfo(c);

DrawIcon(hdc, 1, 1, c.hCursor); #returns 1
GetPixel(hdc, 1, 1); #returns -1
Run Code Online (Sandbox Code Playgroud)

为什么 GetPixel() 不返回 COLORREF?我错过了什么?

我对 WinAPI 不是很有经验,所以我可能犯了一些愚蠢的错误。

c windows mouse winapi mouse-cursor

4
推荐指数
1
解决办法
4508
查看次数

我如何知道HCURSOR对象的大小

我想获得.cur文件的高度和宽度,而不考虑其格式.

我尝试使用LoadCursorFromFile()获取HCURSOR,我想有一个API函数来获取HCURSOR信息,但我发现GetCursorInfo()根本不是我想要的.

有没有办法获得HCURSOR对象的高度和宽度?

winapi mouse-cursor

1
推荐指数
2
解决办法
2233
查看次数

标签 统计

winapi ×3

c++ ×2

mouse ×2

mouse-cursor ×2

windows ×2

c ×1

cursor ×1

java ×1