• 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: NSImage lockFocus in DrawRect while printing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSImage lockFocus in DrawRect while printing


  • Subject: Re: NSImage lockFocus in DrawRect while printing
  • From: Sergey Mastykash <email@hidden>
  • Date: Thu, 16 Dec 2004 10:56:25 +0200


Hello John,

I'm using MAC OS 10.3.6

On Dec 15, 2004, at 9:42 PM, John C. Randolph wrote:

Sergey,  

What version of Mac OS X are you using?  I seem to remember a bug like this on Jaguar, but I thought we had it fixed by now.

-jcr


On Dec 15, 2004, at 1:22 AM, Sergey Mastykash wrote:


hello. 

I need to print into NSImage inside drawRect method of view that is used for printing. 
But when I simply try to call [image lockFocus]  and [image unlockFocus] happens something strange. 

It seems that transformation matrix of current graphic context is broken. 
Methods [NSGraphicsContext <x-tad-bigger>saveGraphicsState</x-tad-bigger>] [NSGraphicsContext <x-tad-bigger>restoreGraphicsState</x-tad-bigger>] has no effect. 
The matrix is broken, and I print images in wrong place. 

The interesting fact is that when I'm testing this code in NSView which draws on screen everything works fine!
But if I try to print the same to printer, problem occurs. 

This is simple code that demonstrates problem: 
- (void)drawRect:(NSRect)rect
{
    NSImage* textImage = [[NSImage alloc] initWithSize: NSMakeSize(100, 10)];
    [textImage lockFocus];
    [textImage unlockFocus];
    [textImage release];

    /* Performing some drawings, everything is printed in wrong place */
}


 _______________________________________________
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


John C. Randolph <email@hidden> (408) 974-8819
Sr. Cocoa Software Engineer,
Apple Worldwide Developer Relations
http://developer.apple.com/cocoa/index.html


 _______________________________________________
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: 
 >NSImage lockFocus in DrawRect while printing (From: Sergey Mastykash <email@hidden>)
 >Re: NSImage lockFocus in DrawRect while printing (From: "John C. Randolph" <email@hidden>)

  • Prev by Date: Re: Controlling control sizes when programatically resizing a window
  • Next by Date: Wrapping an Interactive Unix Executable
  • Previous by thread: Re: NSImage lockFocus in DrawRect while printing
  • Next by thread: Sending NSString to NSThread task
  • Index(es):
    • Date
    • Thread