Re: Reflecting image using NSAffineTransform
Re: Reflecting image using NSAffineTransform
- Subject: Re: Reflecting image using NSAffineTransform
- From: Chris Lewis <email@hidden>
- Date: Thu, 28 Jul 2005 02:46:15 +0100
Hi John,
I've been playing around, and you won't have guessed what I found.
Remember, my drawing call was this:
[flipper scaleXBy:-1.0 yBy:1.0];
// SNIP//
[aFrame drawAtPoint:NSMakePoint(-dimensions.width,0)
fromRect:NSMakeRect(0,0, dimensions.width, dimensions.height)
operation:NSCompositeCopy fraction:1.0];
If I set scaleXBy:-0.9999 ... it works! Why? I have no idea. Same goes
for a lot of the overlay operations. But check *this* out. If I change
the operation to NSCompositeIn, it works with scaleXBy:-1.0! It's
crazy. Not wanting to jump to conclusions, because usually it's *my
fault*, but could this be a bug in Cocoa?
The operations, according to the documentation, should result in the same thing:
NSCompositeCopy: Source image.
NSCompositeSourceIn: Source image wherever both images are opaque, and
transparent elsewhere.
As I'm overlaying entirely, this should be an equal operation.
As for the co-ords, I worked it out, thanks John. For others: When you
do the transformation on the pixels, it moves them in space. Thinking
of it like an X/Y axis, you've just moved the image into the negative
X and positive Y space, so your origin is now in the bottom-right
corner. The function call reflects this new origin, and it works
perfectly.
So the code which draws correctly is:
[aFrame drawAtPoint:NSMakePoint(-dimensions.width,0)
fromRect:NSMakeRect(0,0, dimensions.width, dimensions.height)
operation:NSCompositeSourceIn fraction:1.0];
Hope this helps other people! Thanks a lot John!
Chris
On 28/07/05, John C. Randolph <email@hidden> wrote:
> Well then, do the math: You need to center one rectangle in another.
>
> -jcr
>
> On Jul 27, 2005, at 5:24 PM, Chris Lewis wrote:
>
> > Right in the middle of the NSImageView, I want it to take up the whole
> > of the view, overwriting the image that came before it...
> >
> > Thanks ever so much John, I hate to be a pain.
> >
> > Chris
> >
> > On 28/07/05, John C. Randolph <email@hidden> wrote:
> >
> >>
> >> On Jul 27, 2005, at 4:06 PM, Chris Lewis wrote:
> >>
> >>
> >>> John,
> >>> Thank you for the help, the origin did need to be moved! However,
> >>> where should this new origin be set to be at?
> >>>
> >>
> >> Well, that depends on where you want the image to appear. It's
> >> really not for me to say where that is in your case.
> >>
> >> -jcr
>
>
> John C. Randolph <email@hidden> (408) 914-0013
> Roaming Cocoa Engineer,
> Available for your projects at great Expense and Inconvenience.
>
>
>
>
_______________________________________________
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