IOS inverted chaos coordinates

So, I use CGBitmapContext to adapt the software blitter to iOS. I write my data into a bitmap, then I use the CoreGraphics functions to write text through a CGBitmapContext. Software blitter uses Upper Left Hand Origin, while CoreGraphics features use lower left hand start. Therefore, when I draw an image using the blitter in (0, 0), it appears in the upper left corner. When I draw text using CG in (0, 0), it appears in the lower left corner and DO NOT WRONG. Yes, I read all other questions about coordinate inversion, and I do this with the resulting CG image to display it correctly in the view. Perhaps a sample code will help ...

    // This image is at the top left corner using the custom blitter.
screen->write(image, ark::Point(0, 0));
// This text is at the bottom left corner RIGHT SIDE UP
// cg context is a CGBitmapContext
CGContextShowTextAtPoint(
    cgcontext, 
    0, 0, 
    str.c_str(), 
    str.length());

// Send final image to video output.
CGImageRef screenImage = CGBitmapContextCreateImage(cgcontext);

CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);
CGContextTranslateCTM(context, 0, 480);
// Here I flip the whole image, so if I flip the text above, then
// it ends up upside down.
CGContextScaleCTM(context, 1, -1); 
CGContextDrawImage(context, 
    CGRectMake(0, 0, 320, 480), screenImage);
CGContextRestoreGState(context);

CGImageRelease(screenImage);

? ULC?

+3
1

, . . ( - -, , .)

, - . y y. y. () - .

, , , , ; . . y y, . , 0, 0.

, , (). , . , 0,0, , 0,0, , - ( ).

, . .

, . ( ) .

+1

Source: https://habr.com/ru/post/1793326/


All Articles