我正在使用CGBitmapContext将一个软件blitter适配到iOS上。我将数据写入位图,然后使用CoreGraphics函数在CGBitmapContext上写入文本。软件blitter使用左上角原点,而CoreGraphics函数使用左下角原点。因此,当我在(0,0)处使用blitter绘制图像时,它出现在左上角。当我使用CG在(0,0)处绘制文本时,它出现在左下角,且未被倒转。是的,我已经阅读了所有其他关于倒转坐标的问题,并将结果CG图像反转以正确显示视图。也许一个代码示例会有所帮助...
// 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原点为基础的坐标系中将文本正向显示?