• 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
CoreGraphics help
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CoreGraphics help


  • Subject: CoreGraphics help
  • From: Hisaoki Nishida <email@hidden>
  • Date: Thu, 19 Jul 2001 13:48:41 -0400

Hi,

I am trying to draw an image to a CG context in a widow that I've set up with it.
I have no idea what's wrong with my code, I'd appreciate any help.
The window renders fine. But drawing the image is the part I'm having trouble with.
The image I think is loaded fine because I can see it load in the build log.

Here's the code:


// Obtaining the path for image
bundle = [NSBundle bundleForClass:[self class]];
path = [bundle pathForResource:@"logo_yggdral" ofType:@"tiff"];
url = [NSURL fileURLWithPath:path];

// Setting up a window
window = [[NSWindow alloc]
initWithContentRect:NSMakeRect( 0, 0, kDesiredWidth, kDesiredHeight )
styleMask: NSBorderlessWindowMask
backing: NSBackingStoreNonretained
defer:NO];

[window makeKeyAndOrderFront:window];
[[window contentView] lockFocusIfCanDraw];
context = [[NSGraphicsContext currentContext] graphicsPort];

provider = CGDataProviderCreateWithURL( url );
colorSpace = CGColorSpaceCreateDeviceRGB();

image = CGImageCreate( 128,
128,
8,
32,
4 * 128,
colorSpace,
kCGImageAlphaFirst,
provider,
NULL,
0,
kCGRenderingIntentDefault );

CGDataProviderRelease( provider );

CGContextDrawImage( context,
CGRectMake( 0, 0, 128, 128 ),
image );

CGImageRelease( image );


Thank you,

HN


  • Prev by Date: AuthenticationButton
  • Next by Date: Re: AuthenticationButton
  • Previous by thread: Re: AuthenticationButton
  • Next by thread: NSToolBar Implementation
  • Index(es):
    • Date
    • Thread