insta经典滤镜下载
好不容易找到的Insta的经典滤镜源码,贴出来帮大家学习。
//
// IFImageFilter.m
// InstaFilters
//
// Created by Di Wu on 2/28/12.
// Copyright (c) 2012 twitter:@diwup. All rights reserved.
// #import "IFImageFilter.h" @interface IFImageFilter ()
{
GLint filterPositionAttribute, filterTextureCoordinateAttribute;
GLint filterInputTextureUniform, filterInputTextureUniform2, filterInputTextureUniform3, filterInputTextureUniform4, filterInputTextureUniform5, filterInputTextureUniform6; GLuint filterFramebuffer;
} @end @implementation IFImageFilter - (id)initWithFragmentShaderFromString:(NSString *)fragmentShaderString;
{
if (!(self = [super init]))
{
return nil;
} [GPUImageOpenGLESContext useImageProcessingContext];
filterProgram = [[GLProgram alloc] initWithVertexShaderString:kGPUImageVertexShaderString fragmentShaderString:fragmentShaderString]; [filterProgram addAttribute:@"position"];
[filterProgram addAttribute:@"inputTextureCoordinate"]; if (![filterProgram link])
{
NSString *progLog = [filterProgram programLog];
NSLog(@"Program link log: %@", progLog);
NSString *fragLog = [filterProgram fragmentShaderLog];
NSLog(@"Fragment shader compile log: %@", fragLog);
NSString *vertLog = [filterProgram vertexShaderLog];
NSLog(@"Vertex shader compile log: %@", vertLog);
filterProgram = nil;
NSAssert(NO, @"Filter shader link failed");
} filterPositionAttribute = [filterProgram attributeIndex:@"position"];
filterTextureCoordinateAttribute = [filterProgram attributeIndex:@"inputTextureCoordinate"];
filterInputTextureUniform = [filterProgram uniformIndex:@"inputImageTexture"]; // This does assume a name of "inputImageTexture" for the fragment shader
filterInputTextureUniform2 = [filterProgram uniformIndex:@"inputImageTexture2"]; // This does assume a name of "inputImageTexture2" for second input texture in the fragment shader
filterInputTextureUniform3 = [filterProgram uniformIndex:@"inputImageTexture3"]; // This does assume a name of "inputImageTexture3" for second input texture in the fragment shader
filterInputTextureUniform4 = [filterProgram uniformIndex:@"inputImageTexture4"]; // This does assume a name of "inputImageTexture4" for second input texture in the fragment shader
filterInputTextureUniform5 = [filterProgram uniformIndex:@"inputImageTexture5"]; // This does assume a name of "inputImageTexture5" for second input texture in the fragment shader
filterInputTextureUniform6 = [filterProgram uniformIndex:@"inputImageTexture6"]; // This does assume a name of "inputImageTexture6" for second input texture in the fragment shader [filterProgram use];
glEnableVertexAttribArray(filterPositionAttribute);
glEnableVertexAttribArray(filterTextureCoordinateAttribute);
NSLog(@".0.0.0%@",NSStringFromCGSize(inputTextureSize)); return self;
} - (void)renderToTextureWithVertices:(const GLfloat *)vertices textureCoordinates:(const GLfloat *)textureCoordinates;
{
NSLog(@".0.0.0%@",NSStringFromCGSize(inputTextureSize)); [GPUImageOpenGLESContext useImageProcessingContext];
[self setFilterFBO]; [filterProgram use]; glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, filterSourceTexture); glUniform1i(filterInputTextureUniform, ); if (filterSourceTexture2 != )
{
glActiveTexture(GL_TEXTURE3);
glBindTexture(GL_TEXTURE_2D, filterSourceTexture2); glUniform1i(filterInputTextureUniform2, );
}
if (filterSourceTexture3 != )
{
glActiveTexture(GL_TEXTURE4);
glBindTexture(GL_TEXTURE_2D, filterSourceTexture3);
glUniform1i(filterInputTextureUniform3, );
}
if (filterSourceTexture4 != )
{
glActiveTexture(GL_TEXTURE5);
glBindTexture(GL_TEXTURE_2D, filterSourceTexture4);
glUniform1i(filterInputTextureUniform4, );
}
if (filterSourceTexture5 != )
{
glActiveTexture(GL_TEXTURE6);
glBindTexture(GL_TEXTURE_2D, filterSourceTexture5);
glUniform1i(filterInputTextureUniform5, );
}
if (filterSourceTexture6 != )
{
glActiveTexture(GL_TEXTURE7);
glBindTexture(GL_TEXTURE_2D, filterSourceTexture6);
glUniform1i(filterInputTextureUniform6, );
} glVertexAttribPointer(filterPositionAttribute, , GL_FLOAT, , , vertices);
glVertexAttribPointer(filterTextureCoordinateAttribute, , GL_FLOAT, , , textureCoordinates); glDrawArrays(GL_TRIANGLE_STRIP, , ); for (id<GPUImageInput> currentTarget in targets)
{
[currentTarget setInputSize:inputTextureSize];
[currentTarget newFrameReady];
}
} - (void)setFilterFBO;
{
if (!filterFramebuffer)
{
[self createFilterFBO];
} glBindFramebuffer(GL_FRAMEBUFFER, filterFramebuffer); CGSize currentFBOSize = [self sizeOfFBO];
glViewport(, , (int)currentFBOSize.width, (int)currentFBOSize.height);
} - (void)createFilterFBO;
{
glActiveTexture(GL_TEXTURE1);
glGenFramebuffers(, &filterFramebuffer);
glBindFramebuffer(GL_FRAMEBUFFER, filterFramebuffer);
NSLog(@".0.0.0%@",NSStringFromCGSize(inputTextureSize));
CGSize currentFBOSize = [self sizeOfFBO];
// NSLog(@"Filter size: %f, %f", currentFBOSize.width, currentFBOSize.height); glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8_OES, (int)currentFBOSize.width, (int)currentFBOSize.height);
glBindTexture(GL_TEXTURE_2D, outputTexture);
glTexImage2D(GL_TEXTURE_2D, , GL_RGBA, (int)currentFBOSize.width, (int)currentFBOSize.height, , GL_RGBA, GL_UNSIGNED_BYTE, );
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, outputTexture, ); GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER); NSAssert(status == GL_FRAMEBUFFER_COMPLETE, @"Incomplete filter FBO: %d", status);
} - (CGSize)sizeOfFBO;
{
CGSize outputSize = [self maximumOutputSize];
if ( (CGSizeEqualToSize(outputSize, CGSizeZero)) || (inputTextureSize.width < outputSize.width) )
{
return inputTextureSize;
}
else
{
return outputSize;
}
} - (void)setInputTexture:(GLuint)newInputTexture atIndex:(NSInteger)textureIndex;
{
if (textureIndex == )
{
filterSourceTexture = newInputTexture;
}
else if (filterSourceTexture2 == )
{
filterSourceTexture2 = newInputTexture;
}
else if (filterSourceTexture3 == ) {
filterSourceTexture3 = newInputTexture;
}
else if (filterSourceTexture4 == ) {
filterSourceTexture4 = newInputTexture;
}
else if (filterSourceTexture5 == ) {
filterSourceTexture5 = newInputTexture;
}
else if (filterSourceTexture6 == ) {
filterSourceTexture6 = newInputTexture;
} } @end
效果图
百度网盘下载http://pan.baidu.com/s/1c04sFTY
insta经典滤镜下载的更多相关文章
- c++学习书籍推荐《Visual C++2008入门经典》下载
百度云及其他网盘下载地址:点我 <Visual C++2008入门经典>学习目标: 使用标准模板库(STL)来组织和操作本地C++程序中的数据 C++程序调试技术 构造Microsoft ...
- Ruby On Rails经典书籍下载地址
Web开发敏捷之道-应用Rails进行敏捷Web开发 http://vdisk.weibo.com/s/t47M5Q3WInwc RUBY ON RAILS入门经典 http://downlo ...
- 经典书籍---MySQL经典书籍下载
以下是一些经典的MySQL书籍电子版,括号内为提取码,若需自取. 欢迎阅读纸质版,尊重作者版权 高性能MySQL_中文版 [ hre3 ] 高性能MySQL_英文版[ m2xj ] MySQL技术内幕 ...
- C# NOPI 项目实战(经典)(可下载项目源码)
1 -.首先说明下项目目的: 之前我有写过一篇 "NPOI操作EXCEL" 这篇文章主要介绍了如何安装NPOI,以及NPOI具体如何使用,并且用具体实例介绍了excel导入到da ...
- VC++/MFC(VC6)开发技术精品学习资料下载汇总
工欲善其事,必先利其器,VC开发MFC Windows程序,Visual C++或Visual Studio是必须的,恩,这里都给你总结好了,拿去吧:VC/MFC开发必备Visual C++.Visu ...
- Java--使用多线程下载,断点续传技术原理(RandomAccessFile)
一.基础知识 1.什么是线程?什么是进程?它们之间的关系? 可以参考之前的一篇文章:java核心知识点学习----并发和并行的区别,进程和线程的区别,如何创建线程和线程的四种状态,什么是线程计时器 简 ...
- Spring学习笔记下载
动力节点的spring视频教程相当的经典:下载地址 https://pan.baidu.com/s/1eTSOaae
- iOS二十种超酷时尚艺术滤镜汇总【附源码】
本文总结了20种ios滤镜都是基于GPUImage的,有3种滤镜是GPUImage库中包含的,还有17种是Instagram中的经典滤镜,集成在一个项目中.使用GPUImage可以非常容易创建我们自己 ...
- C++学习网站总结(转)
总结帖: http://club.topsage.com/thread-361504-1-1.html Visual C++ (VC) / MFC 电子书下载: Visual C++ 2008 入门经 ...
随机推荐
- 78-WS2812-Library (STM32F4)
78-WS2812-Library (STM32F4) //-------------------------------------------------------------- // File ...
- DMA/TIM capture
This is a more free standing example measuring the LSI (TIM5_CH4 internally) and demonstrating DMA/T ...
- 【Go入门教程3】基本类型 和 高级类型
基本类型 Go 有很多预定义类型,这里简单地把它们分为 基本类型 和 高级类型.Go 的基本类型并不多,而且大部分都与整数相关,如下表所示: 名 称 宽度(字节) 零 值 说 明 bool 1 fal ...
- TFS 2015 Build Agent failing syncing the repository 获取源码 不全 失败
当我们使用TFS2015d的生成代理时,我们将生成定义加入代理池队列中,但是代理可能无法完全下载我们在TFS代码浏览器中看到的所有目录,这肯定会导致编译失败呀!为什么呢? 原因在于tfscompile ...
- MySQL 5.6主从Slave_IO_Running:Connecting/error connecting to master *- retry
刚配置的MySQL主从,在从机上看到 点击(此处)折叠或打开 mysql> SHOW slave STATUS \\G *************************** 1. row ** ...
- .Net Discovery系列之三 深入理解.Net垃圾收集机制(上)
前言: 组成.Net平台一个很重要的部分----垃圾收集器(Garbage Collection),今天我们就来讲讲它.想想看没有GC,.Net还能称之为一个平台吗?各种语言虽然都被编译成MSIL,但 ...
- AngularJS路由系列(3)-- UI-Router初体验
本系列探寻AngularJS的路由机制,在WebStorm下开发. AngularJS路由系列包括: 1.AngularJS路由系列(1)--基本路由配置2.AngularJS路由系列(2)--刷新. ...
- ASP.NET Identity系列02,在ASP.NET MVC中增删改查用户
本篇体验在ASP.NET MVC中使用ASP.NET Identity增删改查用户. 源码在这里:https://github.com/darrenji/UseIdentityCRUDUserInMV ...
- 在Oracle电子商务套件版本12.2中创建自定义应用程序(文档ID 1577707.1)
在本文档中 本笔记介绍了在Oracle电子商务套件版本12.2中创建自定义应用程序所需的基本步骤.如果您要创建新表单,报告等,则需要自定义应用程序.它们允许您将自定义编写的文件与Oracle电子商务套 ...
- 每天一个linux命令-ls命令
查看统计当前目录下文件的个数,包括子目录里的. ls -lR| grep "^-" | wc -l[喝小酒的网摘]http://blog.hehehehehe.cn/a/12311 ...