我使用的是vImageConvert_RGB888toARGB8888
and vImagePermuteChannels_ARGB8888
。先从RGB24改成ARGB,因为OPENGL ES不支持ARGB,所以需要把ARGB改成BGRA用vImagePermuteChannels_ARGB8888
. 但是当需要更改的数据很大时,时间成本很高,那么有人有更好的方法吗?谢谢!我的代码是这样的:
- (void)transformRGBToBGRA:(const UInt8 *)pict{
rgb.data = (void *)pict;
vImage_Error error = vImageConvert_RGB888toARGB8888(&rgb,NULL,0,&argb,NO,kvImageNoFlags);
if (error != kvImageNoError) {
NSLog(@"vImageConvert_RGB888toARGB8888 error");
}
const uint8_t permuteMap[4] = {3,2,1,0};
error = vImagePermuteChannels_ARGB8888(&argb,&bgra,permuteMap,kvImageNoFlags);
if (error != kvImageNoError) {
NSLog(@"vImagePermuteChannels_ARGB8888 error");
}
free((void *)pict);
}