Making a totally black NSImage object

Discussion in 'Mac Programming' started by foidulus, Nov 3, 2008.

  1. foidulus macrumors 6502a

    Jan 15, 2007
    is it possible? I want to insert some black spots in between QTMovie objects and insertEmptySegmentAt just keeps the last frame played showing for the programmed duration. I want to just insert some black, but it looks like I have to make an NSImage object to do it. I guess I could just whip up a quick all black image and load that, but I would rather do it programatically.

    Any suggestions would be appreciated.
  2. robbieduncan Moderator emeritus


    Jul 24, 2002
    Create an NSImage, lock focus on it and draw the rectangle of pure black then unlock focus?

    Look at the lockFocus method of NSImage (and the unlockFocus method too), the set method of NSColor and finally the fillRect: method of NSBezierPath.
  3. foidulus thread starter macrumors 6502a

    Jan 15, 2007
    Thanks, but that looks like you won't be able to do that while running "headless"...

    I think I'll just go with the black jpeg.
  4. kainjow Moderator emeritus


    Jun 15, 2000
    Just make sure you call NSApplicationLoad() if you haven't already, and it'll work fine.

Share This Page