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

Method BitmapForDPI

resourcemanager.go:61–84  ·  view source on GitHub ↗

BitmapForDPI loads a bitmap from file or resource identified by name, or an error if it could not be found. When bitmap is loaded, given DPI is assumed.

(name string, dpi int)

Source from the content-addressed store, hash-verified

59// BitmapForDPI loads a bitmap from file or resource identified by name, or an error if it could
60// not be found. When bitmap is loaded, given DPI is assumed.
61func (rm *ResourceManager) BitmapForDPI(name string, dpi int) (*Bitmap, error) {
62 if bm := rm.bitmaps[name]; bm != nil {
63 return bm, nil
64 }
65
66 if bm, err := NewBitmapFromFileForDPI(filepath.Join(rm.rootDirPath, name), dpi); err == nil {
67 rm.bitmaps[name] = bm
68 return bm, nil
69 }
70
71 if bm, err := NewBitmapFromResourceForDPI(name, dpi); err == nil {
72 rm.bitmaps[name] = bm
73 return bm, nil
74 }
75
76 if id, err := strconv.Atoi(name); err == nil {
77 if bm, err := NewBitmapFromResourceIdForDPI(id, dpi); err == nil {
78 rm.bitmaps[name] = bm
79 return bm, nil
80 }
81 }
82
83 return nil, rm.notFoundErr("bitmap", name)
84}
85
86// Icon returns the Icon identified by name, or an error if it could not be found.
87func (rm *ResourceManager) Icon(name string) (*Icon, error) {

Callers 1

BitmapMethod · 0.95

Calls 4

notFoundErrMethod · 0.95
NewBitmapFromFileForDPIFunction · 0.85

Tested by

no test coverage detected