createAlphaCursorOrIconFromBitmap creates a cursor/icon from a bitmap. hotspot coordinates are in native pixels.
(bmp *Bitmap, hotspot Point, fIcon bool)
| 362 | |
| 363 | // createAlphaCursorOrIconFromBitmap creates a cursor/icon from a bitmap. hotspot coordinates are in native pixels. |
| 364 | func createAlphaCursorOrIconFromBitmap(bmp *Bitmap, hotspot Point, fIcon bool) (win.HICON, error) { |
| 365 | // Create an empty mask bitmap. |
| 366 | hMonoBitmap := win.CreateBitmap(int32(bmp.size.Width), int32(bmp.size.Height), 1, 1, nil) |
| 367 | if hMonoBitmap == 0 { |
| 368 | return 0, newError("CreateBitmap failed") |
| 369 | } |
| 370 | defer win.DeleteObject(win.HGDIOBJ(hMonoBitmap)) |
| 371 | |
| 372 | var ii win.ICONINFO |
| 373 | if fIcon { |
| 374 | ii.FIcon = win.TRUE |
| 375 | } |
| 376 | ii.XHotspot = uint32(hotspot.X) |
| 377 | ii.YHotspot = uint32(hotspot.Y) |
| 378 | ii.HbmMask = hMonoBitmap |
| 379 | ii.HbmColor = bmp.hBmp |
| 380 | |
| 381 | // Create the alpha cursor with the alpha DIB section. |
| 382 | hIconOrCursor := win.CreateIconIndirect(&ii) |
| 383 | |
| 384 | return hIconOrCursor, nil |
| 385 | } |
| 386 | |
| 387 | // sizeFromHICON returns icon size in native pixels. |
| 388 | func sizeFromHICON(hIcon win.HICON) (Size, error) { |
no test coverage detected
searching dependent graphs…