On 22.10.2008, at 02:54, DKJ wrote:

Me again. I've been using this code:

NSURL *url = [NSURL fileURLWithPath:fname];
CGImageSourceRef source = CGImageSourceCreateWithURL((CFURLRef)url, NULL);
        CGImageRef image = CGImageSourceCreateImageAtIndex(source, 0, NULL);
        CFRelease(source);
        
        theView.layer.contents = (id)image;

It compiles without complaint, but I'm still not seeing the image. I can see the effects of changing other properties of the layer (e.g. borderWidth). I've checked that image is not NULL. What am I missing here?

You are probably missing a '[theView.layer setNeedsDisplay];'

BTW, I prefer drawing using the standard NS... classes by a delegate and this code:

- (void) drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx {
NSGraphicsContext *gc = [NSGraphicsContext graphicsContextWithGraphicsPort:ctx flipped:NO];
    [NSGraphicsContext saveGraphicsState];
    [NSGraphicsContext setCurrentContext:gc];

    // Draw stuff
    [[NSColor redColor] setFill];
    [NSBezierPath fillRect:NSMakeRect(8.0, 8.0, 48.0, 48.0)];

    [NSGraphicsContext restoreGraphicsState];
}

Regards,
Patrick

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to