GPUImage: GPUImageToneCurveFilter not working

Now I managed to use GPUImage in my application and tried to put filters in my photos at the click of a button, but there is another problem.

    GPUImageFilter *selectedFilter;
    if (sender.tag == 1) {
        selectedFilter = [[GPUImageFilter alloc] init];
    } else if (sender.tag == 2) {
        selectedFilter = [[GPUImageThresholdEdgeDetection alloc] init];
    } else if (sender.tag == 3) {
        selectedFilter = [[GPUImageSketchFilter alloc] init];
    } else if (sender.tag == 4) {
        selectedFilter = [[GPUImageToneCurveFilter alloc] initWithACV:@"crossprocess.acv"];
    } else if (sender.tag == 5) {
        selectedFilter = [[GPUImageToneCurveFilter alloc] initWithACV:@"Summer.acv"];
    } else if (sender.tag == 6) {
        selectedFilter = [[GPUImageToneCurveFilter alloc] initWithACV:@"NightCat.acv"];
    } else if (sender.tag == 7) {
        selectedFilter = [[GPUImageToneCurveFilter alloc] initWithACV:@"Breeze.acv"];
    } else if (sender.tag == 8) {
        selectedFilter = [[GPUImageToneCurveFilter alloc] initWithACV:@"OldTone.acv"];
    } else if (sender.tag == 9) {
        selectedFilter = [[GPUImageToneCurveFilter alloc] initWithACV:@"Sky.acv"];         
    }
    filteredImg = [selectedFilter imageByFilteringImage:image];
    [insertPhoto1 setImage:filteredImg];

GPUImageToneCurveFilter does not work, whenever I clicked the button with the .acv filter, it resets the application and throws this error.

Thread 1: Program received signal: "EXC_BAD_ACCESS".

Backlit on this part

version = CFSwapInt16BigToHost(*(int*)([databuffer bytes]));

What should I do? What does the error mean?

0
source share
1 answer

It seems you have a memory management problem here when you change your variables. You are using two pointers. It seems wrong to me.

version = CFSwapInt16BigToHost((int*)([databuffer bytes]));

or better

version = CFSwapInt16BigToHost([databuffer bytes]);

Make sure the arg and return values ​​match the function as per the manual!

in the Apple manual this is indicated about this function:

CFSwapInt16HostToBig

16- .

uint16_t CFSwapInt16HostToBig (
   uint16_t arg
);

* Arg * , . . big-endian, arg .

0

All Articles