Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/rust/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 如何设置图像以填充全视图?_Iphone_Cgbitmapcontextcreate - Fatal编程技术网

Iphone 如何设置图像以填充全视图?

Iphone 如何设置图像以填充全视图?,iphone,cgbitmapcontextcreate,Iphone,Cgbitmapcontextcreate,我使用下面的代码来填充rgba的完整视图。但我得到的宽度只有一半(1/2)。任何人请告诉我我的密码有什么问题 CGContextRef bitmap = CGBitmapContextCreate( rgba, width, // width = 320 height, // 460 8 //CGImageGetBit

我使用下面的代码来填充rgba的完整视图。但我得到的宽度只有一半(1/2)。任何人请告诉我我的密码有什么问题

             CGContextRef bitmap = CGBitmapContextCreate(
             rgba,
             width,     // width = 320
             height,        // 460
             8               //CGImageGetBitsPerComponent(imageRef),    
             4 * width, // rowbytes
             colorSpace,
             kCGImageAlphaNoneSkipLast);
             );

尝试使用:
width*[UIDevice currentDevice]。缩放
而不是
width
height*[UIDevice currentDevice]。缩放
而不是
height

             CGContextRef bitmap = CGBitmapContextCreate(
             rgba,
             width,     // width = 320
             height,        // 460
             8               //CGImageGetBitsPerComponent(imageRef),    
             4 * width, // rowbytes
             colorSpace,
             kCGImageAlphaNoneSkipLast);
             );

请记住,您的设备可以有一个视网膜屏幕,而您的320px视图实际上是640px视图。(scale=2)

你是说你的主视图是320x460 pxhi neo ya我的屏幕宽度是320x460我得到的是160x460用CGContextScaleCTM缩放你的核心图形上下文怎么样?你在视网膜和非视网膜上测试过吗?
             CGContextRef bitmap = CGBitmapContextCreate(
             rgba,
             width,     // width = 320
             height,        // 460
             8               //CGImageGetBitsPerComponent(imageRef),    
             4 * width, // rowbytes
             colorSpace,
             kCGImageAlphaNoneSkipLast);
             );