Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Aug 31, 2006, 11:37 AM   #1
swimlikehell
macrumors member
 
Join Date: Aug 2006
One quick question about xcode

I know you will probaly thing i am stupid but i am just starting out so please help. I am trying to do multiple image functions using carbon and they all need CGContectRef. what was wondering was how i can go about finding that i am making a basic sketch program. any help will be much appreciated. Thanks

Last edited by swimlikehell; Aug 31, 2006 at 01:20 PM.
swimlikehell is offline   0 Reply With Quote
Old Aug 31, 2006, 12:24 PM   #2
MrFrankly
macrumors regular
 
Join Date: Jan 2006
I'm not entirely sure what you're trying to do. Your description isn't totally clear. But you say you're just starting out. Writing graphics programs can be quite complex to start out with. Did you already try writing console applications, or just simple GUI applications?
MrFrankly is offline   0 Reply With Quote
Old Aug 31, 2006, 12:59 PM   #3
swimlikehell
Thread Starter
macrumors member
 
Join Date: Aug 2006
i have done a little of both, the start of my code is this, im trying to find out what i need to do to call this function:


void MyColoredPatternPainting (CGContextRef myContext, CGRect rect)
{
CGPatternRef pattern;
CGColorSpaceRef patternSpace;
float alpha = 1,
width, height;
static const CGPatternCallbacks callbacks = {0, &MyDrawPattern, NULL};

CGContextSaveGState (myContext);
patternSpace = CGColorSpaceCreatePattern (NULL);
CGContextSetFillColorSpace (myContext, patternSpace);
CGColorSpaceRelease (patternSpace);

pattern = CGPatternCreate (NULL,
CGRectMake (0, 0, H_PSIZE, V_PSIZE),
CGAffineTransformMake (1, 0, 0, 1, 0, 0),
H_PATTERN_SIZE,
V_PATTERN_SIZE,
kCGPatternTilingConstantSpacing,
true,
&callbacks);

CGContextSetFillPattern (myContext, pattern, &alpha);
CGPatternRelease (pattern);
CGContextFillRect (myContext, rect);
CGContextRestoreGState (myContext);
}*/
swimlikehell is offline   0 Reply With Quote
Old Aug 31, 2006, 01:04 PM   #4
kpua
macrumors 6502
 
Join Date: Jul 2006
Sounds like you're trying to do some lower level stuff, which is fine, but not to be attempted without some consulting the docs.

I suggest you search for "Graphics Context" within Xcode and look at the both the Cocoa and Quartz 2D references.

To answer your immediate question though, a CGContextRef for display on the screen cannot be created from the Quartz/CG APIs. You can either obtain the current graphics context from a Cocoa app using the following code:

Code:
CGContextRef myContext = [[NSGraphicsContext currentContext] graphicsPort];
... or you can obtain it from a Carbon HIView, but that code is too complicated to post here. You can find it in the documentation though.

Alternatively, you can create a bitmap image, OpenGL, or printing CGContextRef if that's what you intend to do. Again, look to the docs for those.
kpua is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
One quick question about mirroring Che Castro Apple TV and Home Theater 4 Oct 22, 2011 10:15 PM
One quick question about apple tv. jlyanks85 Apple TV and Home Theater 3 Jan 19, 2011 11:56 AM
One quick question about Jailbreaking Pennyroyal Jailbreaks and iOS Hacks 7 Nov 4, 2009 02:27 PM
One quick question about Jailbreaking Pennyroyal Jailbreaks and iOS Hacks 4 Nov 3, 2009 08:46 AM
One quick question about FanControl. 66217 MacBook Pro 1 Oct 29, 2006 01:13 PM


All times are GMT -5. The time now is 06:29 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC