• xcode配置openGL


    git clone https://github.com/BradLarson/GPUImage

    先git clone 下这个库:

    可以看到拉下来的代码里有一些examples:选择Mac文件夹里的SimplePhotoFilter文件夹里的SimplePhotoFilter.xcodeproj

     打开工程之后,把 GPUImageMac.xcodeproj 文件拖到 Frameworks下面。

     再点击工程里的TARGETS -> Build Phases -> Dependencies -> 添加GPUImage

     添加 TARGETS -> Build Phases -> Link Binary With Libraies -> (点击+号) 添加GPUImage.framework 和 Cocoa.framework

     在SLSDocument.m文件中写主要步骤,自己再定义一个filter文件来重写想要实现的滤镜逻辑。

    - (void)windowControllerDidLoadNib:(NSWindowController *)aController
    {
        [super windowControllerDidLoadNib:aController];
        // Add any code here that needs to be executed once the windowController has loaded the document's window.
        
        NSLog(@"Did load nib");
        
    //    [inputPicture addTarget:imageFilter];
    //    [imageFilter addTarget:self.imageView];
        
    //    [inputPicture addTarget:self.imageView];
    //    [inputPicture processImage];
        
        NSImage *sourceImage = [[NSImage alloc] initWithContentsOfFile:@"/Users/bella/Desktop/单步数据/IMG_0154.JPG"];
        //获取数据源
        inputPicture = [[GPUImagePicture alloc] initWithImage:sourceImage];
        //创建黑白素描滤镜
        TempFilter *sobelFilter = [[TempFilter alloc] init];
    //    GPUImageBrightnessFilter *sketchFilter = [[GPUImageBrightnessFilter alloc] init];
    //    sketchFilter.brightness = 0.5;
        
        //设置要渲染的区域
        [sobelFilter setupFilterForSize:sourceImage.size];
        
        
        [inputPicture addTarget:sobelFilter];
        GPUImageFilter *lasterFilter = sobelFilter;
    //    [imageFilter addTarget:sketchFilter];
        
        [lasterFilter addTarget:self.imageView];
        [lasterFilter useNextFrameForImageCapture];
        
        //开始渲染
        [inputPicture processImage];
        //获取渲染后的图片
        NSImage *resultImage = [lasterFilter imageFromCurrentFramebuffer];
        NSData *imageData = [resultImage TIFFRepresentation];
        NSBitmapImageRep *imageRep = [NSBitmapImageRep imageRepWithData:imageData];
        NSDictionary *imageProps = [NSDictionary dictionaryWithObject:[NSNumber numberWithFloat:1.0] forKey:NSImageCompressionFactor];
        imageData = [imageRep representationUsingType:NSJPEGFileType properties:imageProps];
        BOOL writeResult = [imageData writeToFile:@"/Users/bella/Desktop/单步数据/output.JPG" atomically:NO];
        NSLog(@"Write result %@", @(writeResult));
        NSLog(@"");
        
        return;
    }
  • 相关阅读:
    virtual Box在Centos 7上的安装
    Spark MLlib使用有感
    storm集群配置
    eclipse配置hadoop插件
    HDFS的java接口——简化HDFS文件系统操作
    【hbase】——HBase 写优化之 BulkLoad 实现数据快速入库
    【hbase】——Java操作Hbase进行建表、删表以及对数据进行增删改查,条件查询
    【转】RHadoop实践系列之二:RHadoop安装与使用
    【转】RHadoop实践系列之一:Hadoop环境搭建
    Hadoop生态系统如何选择搭建
  • 原文地址:https://www.cnblogs.com/Bella2017/p/13025150.html
Copyright © 2020-2023  润新知