Einhugur macOS Bridge plugin.

NSImage.FromFileType Method

Loads icon for given file type.

shared FromFileType(
   fileType as String) as EinhugurMacOSBridge.NSImage

Parameters

fileType
The file type, which may be either a filename extension, an encoded HFS file type, or a universal type identifier (UTI).

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 image as NSImage = NSImage.FromFileType("txt")

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 image as NSImage = NSImage.FromFileType("txt")
Dim myPicture as Picture

if image <> nil then
    myPicture = image.ToPicture(256, 256) // Or any other desired size.
end if

See Also

NSImage Class