Я пытаюсь читать данные текстуры, используя CIImage initWithTexture под iOS 9.0, но все, что я получаю, это черное изображение. Я даже попытался сначала загрузить текстуру, а затем прочитать ее, но все еще черное изображение.Создание CIImage с initWithTexture
Вот мой код:
CGImageRef brushImage;
CGContextRef brushContext;
GLubyte *brushData;
size_t width, height;
GLUint texId;
CIImage *cimage;
//
// Here I'm just loading an image and preparing it as a bitmap.
//
brushImage = [UIImage imageNamed:"brush"].CGImage;
width = CGImageGetWidth(brushImage);
height = CGImageGetHeight(brushImage);
brushData = (GLubyte *) calloc(width * height * 4, sizeof(GLubyte));
brushContext = CGBitmapContextCreate(brushData, width, height, 8, width * 4, CGImageGetColorSpace(brushImage), kCGImageAlphaPremultipliedLast);
CGContextDrawImage(brushContext, CGRectMake(0.0, 0.0, (CGFloat)width, (CGFloat)height), brushImage);
//
// Here I create the texture I want to use.
//
glGenTextures(1, &texId);
glBindTexture(GL_TEXTURE_2D, texId);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
//
// Load in my bitmap to the texture.
//
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, (int)width, (int)height, 0, GL_RGBA, GL_UNSIGNED_BYTE, brushData);
//
// Now, try to read the texture back out.
//
cimage = [[CIImage alloc] initWithTexture:texId size:CGSizeMake(width, height) flipped:YES colorSpace:CGImageGetColorSpace(brushImage)];
return [[UIImage alloc] initWithCIImage: cimage];
Возвращение UIImage, кажется, правильного размера - но изображение, кажется, пустые (все черные), хотя исходное изображение (а PNG) определенно имеет некоторое содержание в Это. Не уверен, что я делаю неправильно. Любая помощь, пожалуйста? Благодаря!!