Einhugur macOS Bridge plugin. |

# NSImage.FromFileIcon Method

Loads image from a file or folder icon.

shared FromFileIcon(
f as FolderItem) as EinhugurMacOSBridge.NSImage

#### Parameters

f
  The file or folder to load the icon from.

#### Returns

EinhugurMacOSBridge.NSImage

#### Remarks

The NSImage for a file icon can and will contain multiple sizes or representations.
Example:
Sub Paint(g As Graphics, areas() As REALbasic.Rect) Handles Paint
#if TargetMacOS
using EinhugurMacOSBridge
Dim f as FolderItem = SpecialFolder.Movies
Dim image as NSImage = NSImage.FromFileIcon(f)
if image <> nil then
image.Draw(g, 0, 0, 256, 256)
end if
#else
g.DrawText("MacOSBridge plugin is for macOS Only", 10, 10)
#endif
End Sub
Note you could also have the icon as Xojo picture:

using EinhugurMacOSBridge
Dim f as FolderItem = SpecialFolder.Movies
Dim image as NSImage = NSImage.FromFileIcon(f)
Dim myPicture as Picture
if image <> nil then
myPicture = image.ToPicture(256, 256) // Or any other desired size.
end if

#### See Also

NSImage Class