Note that there are some explanatory texts on larger screens.

plurals
  1. POFlipped NSString drawing in CGContext
    text
    copied!<p>I try to draw a string in this texture:</p> <p><a href="http://picasaweb.google.it/lh/photo/LkYWBv_S_9v2d6BAfbrhag?feat=directlink" rel="nofollow noreferrer">http://picasaweb.google.it/lh/photo/LkYWBv_S_9v2d6BAfbrhag?feat=directlink</a></p> <p>but the green numbers seem vertical flipped. I've created my context in this way:</p> <pre><code> colorSpace = CGColorSpaceCreateDeviceRGB(); data = malloc(height * width * 4); context = CGBitmapContextCreate(data, width, height, 8, 4 * width, colorSpace, kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big); </code></pre> <p>and i've draw the strings:</p> <pre><code> UIGraphicsPushContext(context); for(int i=0;i&lt;packs.size();++i) { CGPoint points[4] = { gltextures[i].texCoords[0] * size.width, //0 gltextures[i].texCoords[1] * size.height, //1 gltextures[i].texCoords[2] * size.width, //2 gltextures[i].texCoords[3] * size.height, //3 gltextures[i].texCoords[4] * size.width, //4 gltextures[i].texCoords[5] * size.height, //5 gltextures[i].texCoords[6] * size.width, //6 gltextures[i].texCoords[7] * size.height //7 }; CGRect debugRect = CGRectMake ( gltextures[i].texCoords[0] * size.width, gltextures[i].texCoords[1] * size.height, gltextures[i].width, gltextures[i].height ); CGContextSetStrokeColorWithColor(context, [[UIColor redColor] CGColor]); CGContextAddLines(context, points, 4); CGContextClosePath(context); CGContextDrawPath(context, kCGPathStroke); NSString* s = [NSString stringWithFormat:@"%d",gltextures[i].texID]; UIFont* font = [UIFont fontWithName:@"Arial" size:12]; CGContextSetRGBFillColor(context, 0, 1, 0, 1); [s drawAtPoint:points[0] withFont:font]; } UIGraphicsPopContext(); </code></pre> <p>The transformation matrix seems the Identity matrix... no CGAffineTransform is applied to THIS context. If the string is flipped, maybe, all my images are flipped! Any suggestion?</p> <p>PS: sorry for my english ;)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload