Re: Cant Load an Image into a CALayer Solved
Re: Cant Load an Image into a CALayer Solved
- Subject: Re: Cant Load an Image into a CALayer Solved
- From: Gustavo Pizano <email@hidden>
- Date: Wed, 3 Dec 2008 20:36:52 +0100
I just wanted to say tha tI solved the problem, I realize where I was
making my mistake, I guess I was trying to put the image in the init
method, and somehow it wasn't working (my guess is that in the init
the view wasn't initialized yet), so I put it in the awakeFromNib
method and it did Work.
thanks
Gustavo
On 3.12.2008, at 14:36, Gustavo Pizano wrote:
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