또는이 코드는 백그라운드 스레드에서 안전하게 실행할 수 있습니까?이 UIImage 데이터 판독기 스레드가 안전합니까?
CGImageRef cgImage;
CGContextRef context;
CGColorSpaceRef colorSpace;
// Sets the CoreGraphic Image to work on it.
cgImage = [uiImage CGImage];
// Sets the image's size.
_width = CGImageGetWidth(cgImage);
_height = CGImageGetHeight(cgImage);
// Extracts the pixel informations and place it into the data.
colorSpace = CGColorSpaceCreateDeviceRGB();
_data = malloc(_width * _height * 4);
context = CGBitmapContextCreate(_data, _width, _height, 8, 4 * _width, colorSpace,
kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);
CGColorSpaceRelease(colorSpace);
// Adjusts position and invert the image.
// The OpenGL uses the image data upside-down compared commom image files.
CGContextTranslateCTM(context, 0, _height);
CGContextScaleCTM(context, 1.0, -1.0);
// Clears and ReDraw the image into the context.
CGContextClearRect(context, CGRectMake(0, 0, _width, _height));
CGContextDrawImage(context, CGRectMake(0, 0, _width, _height), cgImage);
// Releases the context.
CGContextRelease(context);
동일한 결과를 얻으려면 어떻게해야합니까?
는
나는이 대답을 좋아하지만 완전히 이해할 수는 없다. – Geri
잠시 동안 버퍼를 "유지"하는 것과 같은 것입니까? 텍스처에 이미지를 푸시 할 때마다 UIImageDataParser 인스턴스를 생성하므로 버퍼가 "혼합"해서는 안됩니다. 어쩌면 버퍼를 일찍 풀어 줄 수 있을까요? – Geri
백그라운드 스레드에서 데이터 개체를 릴리스하려고 시도했지만 결과가 없습니다. – Geri