Now, I'm not quite so familiar with Quartz 2D and don't quite get this, if someone can explain it, it would be appreciated.
The following code didn't work, except to display white text :
Now, the bolded line, I simply changed it to the following, no other code changed in the function (I deleted a bunch of initialization here for readability) and everything suddenly works (text renders in any color I specify and pass to the function to initialize color4f) :
The difference I see is that I pass the actual colorSpace I made earlier to the function, but since I created the context with that color space anyhow, shouldn't CGContextSetFillColor() be able to get it from there and create its own CGColorRef object ?
What's even the purpose of CGContextSetFillColor() if it doesn't work ?
The following code didn't work, except to display white text :
Code:
UIFont * usedfont = ...
CGFloat color4f [] = ...
CGRect currentimage = ...;
CGColorSpaceRef colorSpace;
CGContextRef context;
colorSpace = CGColorSpaceCreateDeviceRGB();
context = CGBitmapContextCreate(imagePixels,
width,
height,
8,
width * bytesPerChannel,
colorSpace,
kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);
CGContextTranslateCTM(context, 0.0f, height);
CGContextScaleCTM(context, 1.0f, -1.0f);
[B]CGContextSetFillColor(context, color4f);[/B]
UIGraphicsPushContext(context);
[string drawInRect: currentimage withFont: usedfont lineBreakMode: UILineBreakModeWordWrap];
UIGraphicsPopContext();
CGContextRelease(context);
CGColorSpaceRelease(colorSpace);
Now, the bolded line, I simply changed it to the following, no other code changed in the function (I deleted a bunch of initialization here for readability) and everything suddenly works (text renders in any color I specify and pass to the function to initialize color4f) :
Code:
CGContextSetFillColorWithColor(context, CGColorCreate(colorSpace, color4f));
The difference I see is that I pass the actual colorSpace I made earlier to the function, but since I created the context with that color space anyhow, shouldn't CGContextSetFillColor() be able to get it from there and create its own CGColorRef object ?
What's even the purpose of CGContextSetFillColor() if it doesn't work ?