• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSCursor from 2 bitmaps
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSCursor from 2 bitmaps


  • Subject: NSCursor from 2 bitmaps
  • From: Mel Walker <email@hidden>
  • Date: Thu, 20 May 2004 15:31:23 -0600

I would like to create an NSCursor from two bitmaps, one front and one mask. Where the mask is white, I'd like the image to be transparent/clear, and where the mask is black, I'd like the front image to draw (pretty standard stuff).

Before you ask, no, I don't control the format of the cursor, so I have to do it this way.

What I'm doing now is, I start like this:

NSRect cursorRect = NSMakeRect(0,0,cursorSize.width,cursorSize.height);
NSImage* cursorImage = [[NSImage alloc] initWithSize:cursorSize];
[cursorImage lockFocus];
[[NSColor clearColor] set];
NSRectFill(cursorRect);

that should give me an image that is transparent. I have 2 NSBitmapImageRep-based NSImages, front & mask. I've tried various combinations of drawing them:

[mask drawInRect:NSMakeRect(0,0,cursorSize.width,cursorSize.height) fromRect:NSMakeRect(0,0,cursorSize.width,cursorSize.height) operation:NSCompositeSourceIn fraction:1.0];
[front drawInRect:NSMakeRect(0,0,cursorSize.width,cursorSize.height) fromRect:NSMakeRect(0,0,cursorSize.width,cursorSize.height) operation:NSCompositeSourceOver fraction:1.0];

etc. & etc. Then I unlock the focus, and set the cursor. However, the method of trying to draw my way to success isn't working, since every combination of NSCompositingOperation I've tried thus far draws incorrectly. Is there another way I'm not seeing?

--
Mel Walker <email@hidden>
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Prev by Date: screen capture, using SoftVDigX
  • Next by Date: Re: Menu-less popup buttons
  • Previous by thread: Re: screen capture, using SoftVDigX
  • Next by thread: Does not execute on launch
  • Index(es):
    • Date
    • Thread