• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Cant Load an Image into a CALayer
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Cant Load an Image into a CALayer Solved
      • From: Gustavo Pizano <email@hidden>
    • Re: Cant Load an Image into a CALayer
      • From: Benjamin Stiglitz <email@hidden>
  • Prev by Date: Re: NSPersistentDocument packages update
  • Next by Date: Re: Button title irregularities
  • Previous by thread: Re: Killing a Thread
  • Next by thread: Re: Cant Load an Image into a CALayer
  • Index(es):
    • Date
    • Thread