Re: How to create NSCursor from CGBitmap?

2011-10-28 Thread Howard Moon
Never mind I found it!  I can create an NSBitmapImageRep using 
initWithCGImage:, create my NSImage using initWithSize:, and then add the 
representation to the image using addRepresentation:.

Thanks anyway!
Howard



On Oct 26, 2011, at 10:17 AM, Howard Moon wrote:

> Hi all,
> 
>   I've got several .png files that I want to use as custom cursors in my 
> app. I'm loading them into CGBitmap objects, and have written code that 
> creates NSImage objects using them, via initWithCGImage:size:.  I then use 
> those NSImage objects to create my NSCursor objects via 
> initWithImage:hotSpot:.
> 
>   Unfortunately, I just noticed that the NSImage function 
> initWithCGImage:size: is not supported until OS X 10.6, and I need to support 
> 10.5 as well.  How can I create my NSCursor objects from my CGBitmap objects, 
> in a manner that IS supported in 10.5?
> 
>   (By the way, I can't create the NSCursor objects directly from the 
> files - assuming that's possible anyway - because I'm using cross-platform 
> code to get my bitmaps, which provides an object that I can cast to a 
> CGBitmap on the Mac. So, I need to start with CGBitmap objects and create 
> NSCursor objects from those.)
> 
> Thanks,
>   Howard
> 

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: How to create NSCursor from CGBitmap?

2011-10-28 Thread Graham Cox

On 27/10/2011, at 4:17 AM, Howard Moon wrote:

> Unfortunately, I just noticed that the NSImage function initWithCGImage:size: 
> is not supported until OS X 10.6, and I need to support 10.5 as well.  How 
> can I create my NSCursor objects from my CGBitmap objects, in a manner that 
> IS supported in 10.5?


Create an NSBitmapImageRep from the bitmap (you may not even need to use a 
CGBitmap, if the bits are in a supported layout, you can simply wrap a 
NSBitmapImageRep around it directly) then add that rep to an NSImage, which you 
pass to NSCursor.

--Graham

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


How to create NSCursor from CGBitmap?

2011-10-28 Thread Howard Moon
Hi all,

I've got several .png files that I want to use as custom cursors in my 
app. I'm loading them into CGBitmap objects, and have written code that creates 
NSImage objects using them, via initWithCGImage:size:.  I then use those 
NSImage objects to create my NSCursor objects via initWithImage:hotSpot:.

Unfortunately, I just noticed that the NSImage function 
initWithCGImage:size: is not supported until OS X 10.6, and I need to support 
10.5 as well.  How can I create my NSCursor objects from my CGBitmap objects, 
in a manner that IS supported in 10.5?

(By the way, I can't create the NSCursor objects directly from the 
files - assuming that's possible anyway - because I'm using cross-platform code 
to get my bitmaps, which provides an object that I can cast to a CGBitmap on 
the Mac. So, I need to start with CGBitmap objects and create NSCursor objects 
from those.)

Thanks,
Howard

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com