ios (ios8 SDK)의 사진 라이브러리 (ALAsset)에 저장된 그림의 RGB 표현을 포함하는 데이터 배열을 가져오고 싶습니다.UIImage (사진 라이브러리)에서 RGB 데이터를 가져 오는 빠른 방법
- 는
- 가 CGContext로의 CGImage 그릴 [ALAssetRepresentation fullScreenImage]와 ALAsset에서 ㄱ의 CGImage 얻을 : 은 이미이 방법을 시도했다. 방법은 작동
, 내가 데이터를 RGB로 포인터를 얻을 수 있지만,이 정말 느린 (2 변환이 있습니다). 최종 목표는 이미지를 OpenGL 텍스처로 빠르게로드하는 것입니다.
내 코드는 사진 라이브러리에서 이미지를 얻을 수
ALAsset* currentPhotoAsset = (ALAsset*) [self.photoAssetList objectAtIndex:_currentPhotoAssetIndex];
ALAssetRepresentation *representation = [currentPhotoAsset defaultRepresentation];
//-> REALLY SLOW
UIImage *currentPhoto = [UIImage imageWithCGImage:[representation fullScreenImage]];
내 코드 CGContext에 그리려면 많이 없다
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
NSUInteger bytesPerPixel = 4;
NSUInteger bytesPerRow = bytesPerPixel * textureWidth;
NSUInteger bitsPerComponent = 8;
CGContextRef context = CGBitmapContextCreate(textureData, textureWidth, textureHeight,
bitsPerComponent, bytesPerRow, colorSpace,
kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);
CGColorSpaceRelease(colorSpace);
//--> THAT'S REALLY SLOW
CGContextDrawImage(context, CGRectMake(0, 0, textureWidth, textureHeight), cgimage);
CGContextRelease(context);
예 백그라운드 스레드를 사용합니다. 그러나 다른 문제는 기억이다. 먼저 ALAsset (10MB)에서 UIImage를 얻은 다음 UIImage를 복사하여 RGB 데이터 (10MB)를 얻습니다. 그것은 메모리 부족 문제를 유발할 수 있습니다. – Nitenq