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