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

Problems cropping an NSImage


  • Subject: Problems cropping an NSImage
  • From: John Fox <email@hidden>
  • Date: Mon, 20 Sep 2004 14:51:25 -0700

Hi:

I'm trying to add crop functionality similar to Preview in my application. These are the problems I've run into:

1) When an image is loaded in my NSImageView subclass (which is set to scale to fit), I don't know how to determine the NSRect that is actually covered by the image, which is pretty much never the bounds of the image view itself. My selection areas are drawn in the image view, so their origin is the zero point of the image view, not the actual image itself. Ultimately I want create a new NSImage using something like this:

[myImage compositeToPoint:NSZeroPoint
fromRect:myCropRect
operation:NSCompositeCopy];

For myCropRect to be accurately positioned relative to the actual image, I need to subtract the "border" that exists around the actual image area and the bounds of the image view.

2) I can't figure out how to get at the scaled down representation that is displayed on screen. I assume from poring over the docs that I need to get at the NSCachedImageRep and then make a new NSImage from that, but I don't know who to ask for this. For the jpg files that I load into the image view, there is only one representation which of course has the pixel dimensions of the actual full size image, not the scaled down representation I have on-screen. If I could solve the problem in #1 then I could of course scale my selection area and do my work on the full sized image, but that seems like a waste.

Hope I've explained the problem clearly.

Any help greatly appreciated as always.

John
 _______________________________________________
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

  • Prev by Date: Re: Running a shell script out of the current thread
  • Next by Date: CreateEvent and Cocoa
  • Previous by thread: Java, XCode 1.5, and spinning cursor of death
  • Next by thread: CreateEvent and Cocoa
  • Index(es):
    • Date
    • Thread