[SOLVED] Re: Scaled image in NSButtonCell flipped - drawInRect:
[SOLVED] Re: Scaled image in NSButtonCell flipped - drawInRect:
- Subject: [SOLVED] Re: Scaled image in NSButtonCell flipped - drawInRect:
- From: Richard Salvatierra <email@hidden>
- Date: Thu, 5 Jan 2006 11:38:53 -0500
My problem was each row in the matrix after row 1 was being drawn
with its rect.origin translated. By compensating for the
controlView.origin.y (being flipped) and subtracting the
cellFrame.origin.y, all is well. Thank you Ricky for your help.
[[NSGraphicsContext currentContext] saveGraphicsState];
NSAffineTransform* theAffineTransform = [NSAffineTransform transform];
[theAffineTransform scaleXBy:1.0 yBy:-1.0];
[theAffineTransform translateXBy:0.0 yBy:-cellFrame.size.height];
[theAffineTransform concat];
NSRect drawImageRect = cellFrame;
drawImageRect.origin.y = ([controlView frame].origin.y-
cellFrame.origin.y);
[image drawInRect:drawImageRect fromRect: NSZeroRect operation:
NSCompositeSourceIn fraction: 1];
[[NSGraphicsContext currentContext] restoreGraphicsState];
On Jan 4, 2006, at 6:17 PM, Ricky Sharp wrote:
On Jan 3, 2006, at 8:22 PM, Richard Salvatierra wrote:
Ricky - Thank you for the reply. I have submitted my code in
hopes it will help explain my problem. When I apply the
NSAffineTransform, the image does flip, but so do the rest of my
drawings. I suppose I have to apply the NSAffineTransform just
before I draw the image, then revert back. If so, how? Also, I am
fairly new to cocoa so any other pointers/advice greatly appreciated.
You can always wrap particular blocks of drawing like this:
[NSGraphicsContext saveGraphicsState];
// insert code here
[NSGraphicsContext restoreGraphicsState];
___________________________________________________________
Ricky A. Sharp mailto:email@hidden
Instant Interactive(tm) http://www.instantinteractive.com
_______________________________________________
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