iPhone/iPod 용 사진 앱을 제작 중입니다.iOS 무손실 이미지 편집
아이폰 앱의 큰 이미지에서 원시 데이터를 가져 와서 일부 픽셀 조작을 수행하여 디스크/갤러리에 다시 쓰고 싶습니다.
CGImageRef imageBuff = [imageBuffer CGImage];//imageBuffer is an UIImage *
CFDataRef pixelData = CGDataProviderCopyData(CGImageGetDataProvider(imageBuff));
unsigned char *input_image = (unsigned char *)CFDataGetBytePtr(pixelData);
//height & width represents the dimensions of the input image
unsigned char *resultant = (unsigned char *)malloc(height*4*width);
for (int i=0; i<height;i++)
{
for (int j=0; j<4*width; j+=4)
{
resultant[i*4*width+4*(j/4)+0] = input_image[i*4*width+4*(j/4)];
resultant[i*4*width+4*(j/4)+1] = input_image[i*4*width+4*(j/4)+1];
resultant[i*4*width+4*(j/4)+2] = input_image[i*4*width+4*(j/4)+2];
resultant[i*4*width+4*(j/4)+3] = 255;
}
}
CFRelease(pixelData);
내가 결과에 모든 작업을하고 있어요하고 다시 디스크에 쓰기 :
지금까지 나는 다음과 같은 기술을 사용하여 서명 숯불 포인터로 이미지 피커에서 얻은있는 UIImage을 변환했습니다 사용하여 원본 해상도 : 내가 좋아하는 것
NSData* data = UIImagePNGRepresentation(image);
[data writeToFile:path atomically:YES];
알고 :
- 실제로 변환은 무손실입니까?
- 손에 20-22 MP 이미지가있는 경우 ... 백그라운드 스레드에서이 작업을 수행하는 것이 현명한 방법입니까? (충돌의 기회 등 ... 나는 이것을하는 가장 좋은 방법을 알고 싶다).
- 여기에 을 구현하는 더 좋은 방법이 있습니다 (여기 픽셀 데이터를 가져 오는 것이 필요합니다)?