• 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
NSImage origin
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSImage origin


  • Subject: NSImage origin
  • From: Don Willems <email@hidden>
  • Date: Wed, 22 Sep 2004 23:21:21 +0200

Hi,

Is it possible to change the origin of an NSImage?

My problem is this:
I have a custom NSView in which I can draw. I want to create an image (on file) of the part of the custom view in which I have drawn. For instance I have a view of 800x600 pixels. I have drawn a figure in the rectangle with origin (100,150) and with size 100x100. The result should be an image of size 100x100 with the same content as the rectangle in the NSView. The coordinates (0,0) in the image should correspond with (100,150) in the NSView.
I know how I can translate the origin in an NSView, but I don't know how to do it in an image.


This is my code, where cropped is the rectangle in which I have drawn and which may have an origin other than (0,0).

image = [[[NSImage alloc] initWithSize:cropped.size] autorelease];
[image lockFocus];
[self drawViewRect:cropped];
[image unlockFocus];


At this moment the result is an image with the same content as the NSView in the rectangle (0,0) and size 100x100. (Which I would expect, but don't want.)

Thanks,
Don

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSImage origin
      • From: "R. Scott Thompson" <email@hidden>
    • Re: NSImage origin
      • From: "John C. Randolph" <email@hidden>
  • Prev by Date: Re: setEditable for NSTextField
  • Next by Date: Re: NSTimer questions
  • Previous by thread: Re: Getting system information (was Re: Newbie: My first app, how to?)
  • Next by thread: Re: NSImage origin
  • Index(es):
    • Date
    • Thread