Cant Load an Image into a CALayer
Cant Load an Image into a CALayer
- Subject: Cant Load an Image into a CALayer
- From: Gustavo Pizano <email@hidden>
- Date: Wed, 3 Dec 2008 14:36:09 +0100
Hello, me again,
I have another problem I hadn't been able to solve, Im trying to load
an image which is in my bundle, and then put it in a sublayer of the
Custom View of my app.
I have been readign the previous posts and nothing seem to be working
for me, I dunno what Im doing wrong, here is what Im doing.
- (id)initWithFrame:(NSRect)frame {
self = [super initWithFrame:frame];
if (self) {
// Initialization code here.
NSLog(@"Initializing the shps view panel");
shipsContainerLayer = [CALayer layer];
NSRect aux = [self convertRect:[self bounds] toView:nil];
CGRect aux2;
aux2.origin.x=aux.origin.x;
aux2.origin.y=aux.origin.y;
aux2.size.width=aux.size.width;
aux2.size.height=aux.size.height;
shipsContainerLayer.frame = aux2;
NSImage * image = [[NSImage alloc]
initByReferencingFile:@"Destroyer.png"];
if (image)
{
NSLog(@"got image");
CGImageRef imageRef = NULL;
CGImageSourceRef sourceRef;
sourceRef = CGImageSourceCreateWithData((CFDataRef)[image
TIFFRepresentation], NULL);
if(sourceRef) {
imageRef = CGImageSourceCreateImageAtIndex(sourceRef, 0, NULL);
CFRelease(sourceRef);
[shipsContainerLayer setContents:(id)imageRef];
}
}
}
return self;
}
Trying to track down the problem I see there after I "create" the
CGImageSourceRef it doesnt go into the if statement, I dunno what its
wrong.
Thanks if someone can help me in this one please.
Best regards
Gustavo
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden