Hi, this code use to work for getting a system icon for a ToolButton on 32-bit, but when I compile for 64-bit, no picture shows up. I tried changing the scaling to .5 but still no luck. What am I missing? Thanks
dim tbGeneral as New ToolButton
tbGeneral.Icon = GetPictureFromRef( BasicNSImage.PreferencesGeneralImageRef, 2 )
[code]Public Function GetPictureFromRef(imageRef as Ptr, scale as Double) as Picture
If imageRef <> Nil Then
// Get the size of the NSImage
declare function size lib CocoaLib selector "size" (obj_id as Ptr) as NSSize
dim s As NSSize = size( imageRef )
s.width = s.width * scale
s.height = s.height * scale
// Get the graphics of the picture as CGContext
dim p as new picture(s.width,s.height)
dim cntx as Ptr=ptr(p.Graphics.Handle(Graphics.HandleTypeCGContextRef))
dim rect As NSRect
rect.rsize = s
declare function CGImageForProposedRect lib CocoaLib selector "CGImageForProposedRect:context:hints:" (obj_id as Ptr, byref proposedDestRect as NSRect, referenceContext as Ptr, hints as Ptr) as Ptr
// Convert the NSImage to CGImage
dim cgPtr As ptr
cgPtr = CGImageForProposedRect( imageRef, rect, nil, nil)
// Draw the CGImage to our Xojo picture
soft declare sub CGContextDrawImage lib CocoaLib (context as Ptr, rect as NSRect, image as Ptr)
CGContextDrawImage cntx, rect, cgPtr
Return p
End If
End Function
[/code]
[code]Public Shared Function PreferencesGeneralImageRef() as ptr
#if TargetCocoa
Return imageNamed( NSImageNamePreferencesGeneral )
#Endif
End Function
[/code]
[code]Public Shared Function imageNamed(name as string) as ptr
#if TargetCocoa
declare function imageNamed lib CocoaLib selector "imageNamed:" (class_id as Ptr, name as CFStringRef) as Ptr
return imageNamed(NSClassFromString("NSImage"), name)
#Endif
End Function
[/code]