GPUImage: GPUImageToneCurveFilter Not Working

浪尽此生 提交于 2019-12-11 14:11:23

问题


I have managed to use the GPUImage in my app now and tried putting filters in my photos on button click, but there another issue.

    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 is not working, whenever i clicked a button with .acv filter it crashes the app and throws this error.

Thread 1: Program received signal: "EXC_BAD_ACCESS".

With highlight on this part

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

What should i do? What does the error mean?


回答1:


seems you have a memory managment issue here with casting your variables. You use two pointer signs. It seems to me wrong.

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

or better

version = CFSwapInt16BigToHost([databuffer bytes]);

Make sure the arg and return values matches the function according to the manual!

in the apple manual this is stated about this function:

CFSwapInt16HostToBig

Converts a 16-bit integer from the host’s native byte order to big-endian format.

uint16_t CFSwapInt16HostToBig (
   uint16_t arg
);

Parameters *arg* The integer whose bytes should be swapped. Return Value The integer with its bytes swapped. If the host is big-endian, this function returns arg unchanged.



来源:https://stackoverflow.com/questions/12722880/gpuimage-gpuimagetonecurvefilter-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!