Grant Wilkinson
Grant Wilkinson

Reputation: 1128

Zoom in and Out through a NSView or Magnify

I am hoping to be able to make something similar to the universal access zoom window shown below. I have already created an NSView and using a fill operation I made a rect with a clear "see through" composite to see through my window and show the desktop. Now I am wondering if it is possible to zoom in and out inside my view just like the picture below. I was thinking this might be an IkImageView or something I could apply but i wasent sure how it was done. Does anyone know how to do this or show me where I could find this in the docs? Some code would be great. Thanks!

enter image description here

Upvotes: 1

Views: 1817

Answers (2)

Justin Boo
Justin Boo

Reputation: 10198

Take a look at Apple's example CIAnnotation. In this example is magnifying image but I think You can achieve what You want. You can download sample code from here.

CIAnnotation app example:

enter image description here

References and guides which can help You with this:

Core Image Programming guide
Quartz 2D Programming Guide
NSGraphicsContext Class Reference

Upvotes: 2

thundersteele
thundersteele

Reputation: 673

NSView supports zoom through - (void)scaleUnitSquareToSize:(NSSize)newUnitSize

This zooms the content of the view, so to use this you would have to set the Desktop behind the mouse as view content (NSImage maybe?) and then zoom the view. It will have to update when the mouse is dragged.

Check the ImageKit part of Quartz, in particular the class IKImageView. It has zoom features, but I have not worked with it myself yet.

Upvotes: 1

Related Questions