Fork me on GitHub

使用CGBitmapContextCreate创建的CGContextRef画文字时发现文字都变得模糊

http://www.cocoachina.com/bbs/simple/?t73051.html

CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef context = CGBitmapContextCreate(NULL, 
  pageSize.width,        /* size_t width */
  pageSize.height,       /* size_t height */
  8,      /* bits per component 32/4 */
  pageSize.width * 4,  /* bytes per row 每行字节数,每一个位图像素的代表是4个字节 */
  colorSpace,            /* CGColorSpaceRef */
  kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);
CGColorSpaceRelease(colorSpace);


UIGraphicsPushContext(ctx);

CGContextTranslateCTM(ctx, 0, 480);
CGContextScaleCTM(ctx, 1.0, -1.0);

// 文字内容
[@"中文中文中文" drawInRect:CGRectMake(10, 25, MAX_WIDTH, MAX_HEIGHT) withFont:font];
UIGraphicsPopContext();

创建context时,pageSize.width和pageSize.height都相应的乘2就好了

posted on 2012-04-26 14:50  pengyingh  阅读(3890)  评论(0)    收藏  举报

导航