문제

I have an application that applies various filters to an image. It works great on iOS 5 but crashes on 6. Below is a sample of where it's crashing:

CGImageRef inImage = self.CGImage;
CFDataRef m_DataRef = CGDataProviderCopyData(CGImageGetDataProvider(inImage)); 
UInt8 * m_PixelBuf = (UInt8 *) CFDataGetBytePtr(m_DataRef); 

int length = CFDataGetLength(m_DataRef);

for (int i=0; i<length; i+=4)
{
    if(filter == filterCurve){

    int r = i;
    int g = i+1;
    int b = i+2;

    int red = m_PixelBuf[r];
    int green = m_PixelBuf[g];
    int blue = m_PixelBuf[b];

    m_PixelBuf[r] = SAFECOLOR(red); //    <==== EXC_BAD_ACCESS (code = 2)
    m_PixelBuf[g] = SAFECOLOR(green);
    m_PixelBuf[b] = SAFECOLOR(blue);
   }
}

Notice the bad access point when I try to assign a value back to m_PixelBuf. Anybody have any idea why this is occuring? What in iOS 6 would cause this?

도움이 되었습니까?

해결책

This solves the problem: http://www.iphonedevsdk.com/forum/iphone-sdk-development/108072-exc_bad_access-in-ios-6-but-not-in-ios-5.html

In iOS 6 you need to use CFDataCreateMutableCopy() (instead of CGDataProviderCopyData()), followed by CFDataGetMutableBytePtr() (instead of CFDataGetBytePtr()) if you're going to be manipulating the data's bytes directly.

다른 팁

This is the url where you find new class which works with ios 6:https://github.com/kypselia/ios-image-filters/blob/6ef9a937a931f32dd0b7b5e5bbdca6cce2f690dc/Classes/ImageFilter.m

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top