MCPcopy Create free account
hub / github.com/lxn/walk / createAlphaCursorOrIconFromBitmap

Function createAlphaCursorOrIconFromBitmap

icon.go:364–385  ·  view source on GitHub ↗

createAlphaCursorOrIconFromBitmap creates a cursor/icon from a bitmap. hotspot coordinates are in native pixels.

(bmp *Bitmap, hotspot Point, fIcon bool)

Source from the content-addressed store, hash-verified

362
363// createAlphaCursorOrIconFromBitmap creates a cursor/icon from a bitmap. hotspot coordinates are in native pixels.
364func 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.
388func sizeFromHICON(hIcon win.HICON) (Size, error) {

Callers 3

newIconFromImageForDPIFunction · 0.85
NewIconFromBitmapFunction · 0.85

Calls 1

newErrorFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…