I'm working on a basic OSX screenshot software. Basically, I'd like the user have a semi-transparent rectangle "zone" that they drag over the area they want to screencapture.
They can resize this window/view to their liking. I would then either screenshot only this area, or (more probably) calculate appropriate origin and rectangle size and crop from a fullscreen screenshot.
What type of window or view should I use? Hud Window looks interesting, but isn't obviously resizable and has rounded corners, I'd like to use square corners. My apologies if this is obvious, I'm coming from iOS development. Thanks
For transparent windows, you can either use -[NSWindow setAlphaValue:]
or you can set the window to non-opaque with -setOpaque:
and then make sure parts of the window are drawn with a transparent color (e.g. [NSColor clearColor]
or a color with an alpha less than 1).
See Apple's FunkyOverlayWindow sample code.
For screenshots, you can use CGDisplayCreateImage()
or CGDisplayCreateImageForRect()
. Or you can use CGWindowListCreateImage()
or CGWindowListCreateImageFromArray()
which lets you control which windows are in the image.