Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Core Image and CICrop



Unlike CIImage, the NSImage class doesn't support non-zero origins. You'll notice are no methods to get the origin (like -origin or -extent), but only to get the size. So you'll need to keep track of the offset due to cropping, and offset the source rect accordingly when drawing the image.

Dave

On May 29, 2005, at 11:47 PM, Thomas Schnitzer wrote:

A short follow up to my previous post:

If I use the CIImage instance directly, e.g. in the -drawRect: method of a custom NSView subclass – something like

- (void)drawRect:(NSRect)rect
{
    if( _image )
    {
        CIContext *context = [[NSGraphicsContext currentContext] CIContext];
        CGRect cg = CGRectMake(NSMinX(rect), NSMinY(rect), NSWidth(rect), NSHeight(rect));
        
        if( context )
        {
            [context drawImage:_image atPoint:cg.origin fromRect:cg];
        }
    }
}

the image gets drawn correctly.

(And I forget to mention in my previous mail that the cropped and converted NSImage instances, when logged to console, had the right values in the origin portion of the extent struct, like

NSImage 0x3e2d30 Size={144, 108} Reps=(
    NSCIImageRep 0x3eee10 Size={144, 108} ColorSpace=NSCalibratedRGBColorSpace BPS=0 Pixels=144x108 Alpha=NO CIImage={CIImage [0 19 144 108]}
))

So it seems the "incorrect" behavior i'm experiencing stems from the conversion of the CIImage instance to an instance of class NSImage as done in the code I've posted before!(?)

Comments?

Thanks in advance,
Thomas
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartz-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.
Quartz-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartz-dev/email@hidden

This email sent to email@hidden

References: 
 >Core Image and CICrop (From: Thomas Schnitzer <email@hidden>)
 >Re: Core Image and CICrop (From: Thomas Schnitzer <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.