Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 265855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:48:20+00:00 2026-05-11T22:48:20+00:00

I have a window with an subclass of NSView in it. Inside the view,

  • 0

I have a window with an subclass of NSView in it. Inside the view, I put an NSImage.

I want to be able to rotate the image by 90 degrees, keeping the (new) upper left corner of the image in the upper left corner of the view. Of course, I will have to rotate the image, and then translate it to put the origin back into place.

In Carbon, I found CGContextRotateCTM which does what I want . However, I can’t find the right call in ObjC. setFrameCenterRotation doesn’t seem to do anything, and in setFrameRotation, I can’t seem to figure out where the origin is, so I can approprately translate.

It seems to move. When I resize the window it puts the image (or part of it, I seem to have a strange clipping issue as wel) and when I scroll, it jumps to a different (and not always the saem) location.

Does this make sense to anyone?

thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T22:48:20+00:00Added an answer on May 11, 2026 at 10:48 pm

    I rotate text on the screen for an app I work on and the Cocoa (I assume you mean Cocoa and not ObjC in your question) way of doing this is to use NSAffineTransform.

    Here’s a snippet that should get you started

    double rotateDeg = 90;
    NSAffineTransform *rotate = [[NSAffineTransform alloc] init];
    NSGraphicsContext *context = [NSGraphicsContext currentContext];
    
    [context saveGraphicsState];
    [rotate rotateByDegrees:rotateDeg];
    [rotate concat];
    
        /* Your drawing code [NSImage drawAtPoint....]for the image goes here 
           Also, if you need to lock focus when drawing, do it here.       */
    
    [rotate release];
    [context restoreGraphicsState];
    

    The mathematics on the rotation can get a little tricky here because what the above does is to rotate the coordinate system that you are drawing into. My rotation of 90 degrees is a counter-clockwise rotation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my Cocoa Application I have created a Custom View Class (subclass of NSView),
I have window form in my WPF Application when I open new window from
I have a Window where I have put a Frame. I would like to
I have a window (derived from JFrame) and I want to disable the close
I have a subclass of JPanel , and I want it to, as soon
I've got an NSImage being drawn on a subclass of NSView. In a previous
I have my main window's content view set like this: newContentView = [[CutoutView alloc]initWithFrame:window.frame];
I have a window which contains a QTreeView ( databaseTreeView ) on a subclass
I have a NSViewController subclass with a convenience method to return the window controller
I have an NSView subclass that gets initialized with an OpenGL context and has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.