Help needed in Quartz
Hi,
Pls tell me what is wrong with the following code.The text is not getting displayed in the screen.
-----
Code:
-----
CGContextRef textcontext;
CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB();
textcontext = CGBitmapContextCreate(NULL,1024,512,8,1024*4,color space,kCGImageAlphaPremultipliedLast);
float rect[4] = {0,0,1024.0,512.0};
float transparent[4] = {0,0,0,0};
float text_color[4] = {0.2,0,1.0,1.0};
CGContextSetFillColorWithColor(textcontext,CGColor Create(colorspace,transparent));
CGContextFillRect(textcontext,*(CGRect*)rect);
CGContextSetFillColorWithColor(textcontext,CGColor Create(colorspace, text_color));
CGContextSelectFont(textcontext,"Zapfino",500.0,kC GEncodingMacRoman);
CGContextShowTextAtPoint(textcontext,240,450,str,s trlen(str));
CGContextFlush(textcontext);
Pls tell me what is wrong with the following code.The text is not getting displayed in the screen.
-----
Code:
-----
CGContextRef textcontext;
CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB();
textcontext = CGBitmapContextCreate(NULL,1024,512,8,1024*4,color space,kCGImageAlphaPremultipliedLast);
float rect[4] = {0,0,1024.0,512.0};
float transparent[4] = {0,0,0,0};
float text_color[4] = {0.2,0,1.0,1.0};
CGContextSetFillColorWithColor(textcontext,CGColor Create(colorspace,transparent));
CGContextFillRect(textcontext,*(CGRect*)rect);
CGContextSetFillColorWithColor(textcontext,CGColor Create(colorspace, text_color));
CGContextSelectFont(textcontext,"Zapfino",500.0,kC GEncodingMacRoman);
CGContextShowTextAtPoint(textcontext,240,450,str,s trlen(str));
CGContextFlush(textcontext);
Please post your question only once (this is the fourth time)
Just drawing to a random bitmap context will not put text on the screen, obviously. You need to draw to a CGContext that's associated with a window.
Just drawing to a random bitmap context will not put text on the screen, obviously. You need to draw to a CGContext that's associated with a window.
Seriously.... I already answered this question. Read the documentation. It's super easy to understand and has code examples for what you want to do. How do you expect to port an entire project without knowing what you're doing? It'll take you 15 minutes to read and understand this stuff.
http://developer.apple.com/documentation...-TPXREF101
http://developer.apple.com/documentation...-TPXREF101
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Suggested tool: SDL, Quartz 2D, ...? | TimMcD | 0 | 2,232 |
Sep 30, 2009 08:46 PM Last Post: TimMcD |
|
| Quartz Composer | DesertPenguin | 1 | 2,054 |
Feb 26, 2008 10:08 AM Last Post: maximile |
|

