IconMBS not working

I’m using

[code]Private Function getFileIcon(size as integer, extension as string) As Picture

'get file icon for extension

if extension = “” then Return nil

dim ScaleFactor as Integer = Window.BackingScaleFactorMBS

dim theIcon as IconMBS = new IconMBS("", “”, extension, “”)
dim thePictureContext as new CGPictureContextMBS(size * ScaleFactor, size * ScaleFactor)
const DrawNormal = 0
const DrawNoImage = 2
const DrawNoMask =4
const DrawSelected = &h8000
if theIcon = nil or thePictureContext = nil then 'both are not nil
Return nil
end if
thePictureContext.ClearRect CGRectMBS.Make(0, 0, size * ScaleFactor, size * ScaleFactor)
theIcon.DrawIconCGContext(thePictureContext.Handle, 0, 0, size * ScaleFactor, size * ScaleFactor, 0, 0, DrawNormal, &c000000)
thePictureContext.Flush
dim thePicture as Picture = thePictureContext.CopyPictureWithMask

Return thePicture

End Function[/code]

to pain the icon of an extension. Once upon a time it worked. Now nothing at all is painted. The same goes for the examples for the IconMBS constructor at https://www.monkeybreadsoftware.net/iconservice-iconmbs-method.shtml . Xojo 2015r4, MBS from 23.11.2015.

das hier geht:

[code] 'get file icon for extension

dim extension as string = “pdf”
dim size as integer = 128

dim ScaleFactor as Integer = self.BackingScaleFactorMBS

dim theIcon as IconMBS = new IconMBS("", “”, extension, “”)
dim pic as new Picture(size * ScaleFactor, size * ScaleFactor)
dim thePictureContext as CGBitmapContextMBS = CGBitmapContextMBS.CreateWithPicture(pic)
const DrawNormal = 0
const DrawNoImage = 2
const DrawNoMask =4
const DrawSelected = &h8000
if theIcon = nil or thePictureContext = nil then 'both are not nil
Return
end if
thePictureContext.ClearRect CGRectMBS.Make(0, 0, size * ScaleFactor, size * ScaleFactor)
theIcon.DrawIconCGContext(thePictureContext.Handle, 0, 0, size * ScaleFactor, size * ScaleFactor, 0, 0, DrawNormal, &c000000)
thePictureContext.Flush

Backdrop = pic
[/code]

etwas modernisiert für Cocoa.

CopyPictureWithMask liefert nil, weil das weder ein Carbon Programm ist und auch keins mit Picture dahinter.

Thanks, that works, but without mask. My app has been Cocoa for longer than I have this feature. So I’m pretty sure that CopyPicture WithMask worked for Cocoa. I seem to have a dja vue that we talked about the mask for this before.

Your documentation at https://www.monkeybreadsoftware.net/coregraphics-cgpicturecontextmbs-method.shtml#4

says: // Cocoa or Carbon: Make Picture with mask

ich hab’s plugin gendert, so dass es mit 15.5pr4 wieder gehen sollte fr Cocoa 32bit.

Super!