• 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
Re: Draw a portion of NSTextView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Draw a portion of NSTextView


  • Subject: Re: Draw a portion of NSTextView
  • From: "John C. Randolph" <email@hidden>
  • Date: Fri, 15 Jul 2005 06:35:40 -0700

Lorenzo,

When the drawing focus is locked on an image, the changes you've made to the coordinate system of your view aren't applied to the current drawing context.

On Tiger, you can use NSView's -cacheDisplayInRect:toBitmapImageRep:, and you'll get the right part of the view in the image rep. On Panther and earlier, you'll need to find out how the bounds of your view is shifted from its superview's coordinate system (see - convertPoint:fromView:), and use an NSAffineTransform or the equivalent Quartz 2D functions apply the same offset to the drawing context of the image, after you send [image lockFocus].

-jcr


On Jul 15, 2005, at 5:34 AM, Lorenzo wrote:

Hi,
I want to draw a portion of my NSTextView to a NSImage.
textView bounds and frame size are 1024 x 10,000;
image is 1024 x 500.

NSSize imageSize = NSMakeSize(1024, 500);
NSRect imageRect = NSMakeRect(0, 0, imageSize.width, imageSize.height);


    image = [[NSImage alloc] initWithSize:imageSize];
    [image setFlipped:YES];
    [image lockFocus];
        [textView drawRect:imageRect];
    [imageX unlockFocus];

It works and it draws the top-left portion of the textView in my image.
Fine. Now I want to draw the next portion "i" and I move the bounds origin
of the textView.


    [textView setBoundsOrigin:NSMakePoint(0, -500 * i)];

I lock the focus, draw... Good, I get the second image properly.
Now I do the same in a loop for i < 20 and I get a 3rd image just equal to
the second image. The same for the all the next images. They are all equal
to the second image. Why?
Why do I get the first and the second image properly, and I get all the next
images equal to the second image?




Best Regards
--
Lorenzo
email: email@hidden

 _______________________________________________
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



_______________________________________________ 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
References: 
 >Draw a portion of NSTextView (From: Lorenzo <email@hidden>)

  • Prev by Date: CoreData: "Can't reassign an object to a different store once it has been saved."?
  • Next by Date: Re: Cocoa class for queuing operations?
  • Previous by thread: Draw a portion of NSTextView
  • Next by thread: CoreData: "Can't reassign an object to a different store once it has been saved."?
  • Index(es):
    • Date
    • Thread