当前位置: 首页 > 编程日记 > 正文

TinyCrayon-iOS-SDK:强大到使人惊讶的 Mask 及切图工具库

原文链接:https://github.com/TinyCrayon/TinyCrayon-iOS-SDK
TinyCrayon-iOS-SDK:强大到使人惊讶的 Mask 及切图工具库。# 为开源点赞# —— 由SwiftLanguage分享

A smart and easy-to-use image masking and cutout SDK for mobile apps.

Website platform Compatible CocoaPods DocumentationApp Store license

TinyCrayon SDK provides tools for adding image cutout and layer mask capabilities to your mobile applications.

Quick Select ToolHair Brush Tool
Quick Select ToolHair Brush Tool

Try our sample apps Image Eraser, Color Effect, Focus Effect.

Table of Contents

  • Overview
  • Features
  • Installation
    • Prerequisites
    • Streamlined, using CocoaPods
    • Manually, using the SDK download
      • Download the SDK
      • Add the framework
    • Settings for Objective-C
  • Usage
    • Add a TCMaskView
    • TCMask class
  • Further reading
  • License
  • Terms of use

Overview

TinyCrayon SDK provides tools for adding image cutout and layer mask capabilities to your mobile applications.

Image layer mask is a fundamental technique in image manipulations. It allows you to selectively modify the opacity (transparency) of the layer they belong to. This flexibility to define the opacity of different areas of a layer is the basis for more interesting image manipulation techniques such as selective coloring and luminosity masking.

The current version of TinyCrayon SDK provides the following three tools:

  • Quick Select: Smart and easy to use, users just need to select part of the object and the edge detection algorithm will find the boundary.
  • Hair Brush: Smooth and natual looking, paint on the hair/fur of an object and the algorithm will select the hair/fur for you in high quality.
  • Regular Brush: A regular brush tool with the capability to adjust its size, hardness and opacity.

Features

  • Free: TinyCrayon SDK is provided under MIT license, you can use it in your commercial applications for free!
  • iPad support: TinyCrayon SDK uses auto layout for its views and adapts to each screen size - iPhone or iPad.
  • Highly customizable: Style the UI, view modes and localized languages as you wish.
  • Swift: Keeping up with time, we chose Swift as the main development language of the TinyCrayon SDK, leading to leaner easier code.
  • Objective-C support: All of our public API is Objective-C compatible.

create as many effects as you can think of

Installation

Prerequisites

  • Xcode 8.0 or later.
  • A physical iOS device.
  • Recommended: installation of CocoaPods to simplify dependency management

Streamlined, using CocoaPods

TinyCrayon SDK is available via CocoaPods. If you're new to CocoaPods, this Getting Started Guide will help you. CocoaPods is the preferred and simplest way to use the TinyCrayon SDK.

Important: Please make sure that you have a CocoaPods version >= 0.39.0 installed. You can check your version of CocoaPods with pod --version.

Here's what you have to add to your Podfile (if you do not have Podfile, create one in your project root directory):

target 'MyApp' dopod 'TinyCrayon'
end

Then run pod install in your project root directory (same directory as your Podfile).

Open MyApp.xcworkspace and build.

Manually, using the SDK download

If you don't want to use Cocoapods you can still take advantage of the TinyCrayon SDK by importing the frameworks directly.

Download the SDK

  1. Download the TinyCrayon SDK zip (this is a ~20MB file and may take some time).
  2. Unzip the TinyCrayon.zip

Add the framework

  1. Drag TCCore.framework into the Linked Frameworks and Libraries section of your target.
  2. Drag TCMask.framework into the Embedded Binaries section of your target.

Add the framework

Settings for Objective-C

If your project is using Objective-C, set Always Embed Swift Standard Libraries to be YES in your Build Settings.

Usage

Add a TCMaskView

The TCMaskView class is responsible to create a UIViewController for the user to mask the image. To present a TCMaskView:

Swift

let maskView = TCMaskView(image: image)
maskView.delegate = self
maskView.presentFrom(rootViewController: self, animated: true)

Objective-C

TCMaskView *maskView = [[TCMaskView alloc] initWithImage:image];
maskView.delegate = self;
[maskView presentFromRootViewController:self animated:true];

The delegate of the TCMaskView can be used to be notified when the user cancels or completes the edit. In last case the function tcMaskViewDidComplete(mask:image:) is called.

TCMask class

TCMask is provided by TCMaskViewDelegate functions as the first parameter when the user cancels or completes the edit. For example, when the user completes the edit with TCMaskView:

swift

func tcMaskViewDidComplete(mask: TCMask, image: UIImage) {}

Objective-C

- (void)tcMaskViewDidCompleteWithMask:(TCMask *)mask image:(UIImage *)image {}

TCMask is an encapsulation of image masking result from TCMaskView, it has the following properties:

  • data: An array of 8-bits unsigned char, its length is equal to the number of pixels of the image in TCMaskView. Each element in data represents the mask value.
  • size: The size of mask, which is equal to the size of the image in TCMaskView.

TCMask also provides some simple and easy to use functions to process layer mask with image. For example, to cutout an object:

Swift

let outputImage = mask.cutout(image: image, resize: false)

Objective-C

UIImage *outputImage = [mask cutoutWithImage:image resize:false];

To try these examples, and find out about more options please take a look at the Examples.

Further reading

  • Try our sample apps Image Eraser, Color Effect, Focus Effect.
  • Check out TinyCrayon guides and API reference for more details.

License

The MIT license

Terms of use

By using TinyCrayon SDK, you agree to keep the banner ad embedded in TCMaskView fully viewable and clickable to the users.

相关文章:

Android之自定义AlertDialog无法监听控件

参考:http://www.cnblogs.com/511mr/archive/2011/10/21/2220253.html 要做一个自定义的弹出框,以前都是用一个Activity来实现,总觉得不是很好看,弹出的框有时候感觉有点大,所以上网查资料说,可以给AlertDi…

Spring Cloud应用开发(五:API网关服务)

1、使用Zuul构建API网关服务; 注:本服务涉及到3个工程,起作用分别如下: ms-spring-eureka-server工程:服务注册中心,端口为8761。ms-spring-eureka-order工程:服务提供者,需要启动…

多态---父指针指向子类对象(父类引用指向子类对象)

我们都知道,面向对象程序设计中的类有三大特性:继承,封装,多态,这个也是介绍类的时候,必须提到的话题,那么今天就来看一下OC中类的三大特性: 一、封装 封装就是对类中的一些字段&…

ARKit从入门到精通-ARKit工作原理及流程介绍

2017-06-15 坤小 Cocoa开发者社区转载请注明出处:http://www.jianshu.com/p/0492c7122d2f 1.1-写在前面的话 1.2-ARKit与SceneKit的关系 1.3-ARKit工作原理 1.3.1-ARSCNView与ARSession 1.3.2-ARWorldTrackingSessionConfiguration与ARFrame 1.4-ARKit工作完整流程 1…

【C语言也能干大事】第五讲 组合框控件,下拉列表

获得组合框控件的句柄HWND hwndCombo1 GetDlgItem(hwnd, IDC_COMBO1); 确定目前选项的索引 int curSel ComboBox_GetCurSel(hwndCombo1); 删除项 ComboBox_DeleteString(hwndCombo1, 2); 取得有多少项int getCount ComboBox_GetCount(hwndCombo1);TCHAR getcount[256];itoa(…

Spring Cloud应用开发(六:使用本地存储方式实现分布式配置管理 )

1、搭建Config Server; 1.1、创建配置中心工程microservice-config-server,并在其pom.xml中引入Config Server的依赖; 1.2、编写配置文件application.yml,添加服务端口号和存储属性等信息; 1.3、在scr/main/resources…

PL SQL笔记(三)

loopif credit_rating < 3 then..exit;end if; end loop; select to_char(sysdate, YYYY-MM-DD HH24:MI:SS) from dual; select cast(sysdate as timestamp) from dual; 复合类型数据 1.记录: declaretypeemp_record_typeis record(r_name emp.ename%type,r_job emp.job%typ…

iOS-仿膜拜贴纸滚动(物理仿真)

导读 简单用OC写了一个小球滚动效果; 类似平衡球. GitHub地址&#xff1a;https://github.com/wangliujiayou/WLBallView 欢迎Star. 膜拜滚动进入正题-(传感器) 传感器是一种感应\检测装置, 目前已经广泛应用于智能手机上&#xff0c;用于感应\检测设备周边的信息&#xff0c;不…

Redhat、centos安装配置postgresql

一.安装postgresql 本文仅以 redhat&#xff0c;postgresql9.4为例&#xff0c;使用yum方式进行介绍。 官网&#xff1a;http://www.postgresql.org/download/linux/redhat/ 1.下载postgresql的yum源 yum install http://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/pgdg-red…

Spring Cloud应用开发(七:使用Git存储方式实现分布式配置管理 )

1、使用Git存储实现管理&#xff1b; 1.1、配置Git。在Git上创建microservice-study-config目录&#xff0c;并在目录中添加开发&#xff0c;预发布和测试的配置文件&#xff1b; 1.2、修改服务端配置文件。将microservice-config-server工程的配置文件中本地文件存储方式的配…

IOS 自定义相机, 使用 AVFoundation(附实现部分腾讯水印相机功能 demo)

原文链接&#xff1a;http://www.jianshu.com/p/c64bf543f16a这是一款使用 AVFoundation 自定义的相机&#xff0c;与系统原生相机有一样的外观但比系统的相机更好、更符合实际的开发需要、可以自己修改 UI、实现拍照、取消、闪光灯控制、前后摄像头控制、聚焦、放大缩小、拍照…

如何成为一个好的测试工程师(转载,大意)

对于测试功能是的两个不同观点&#xff1a;软实力和技术能力。 个人觉得技术能力80%可以被大众掌握&#xff0c;但是软实力是需要花费很多时间去培养和塑造的。一下几点也是能够衡量个人技能的一些标准&#xff1a; 1&#xff0c;沟通技能-口头和书面能力 与人的第一印象&#…

ubuntu下7z文件的解压方法

apt-get install p7zip-full 控制台会打出以下信息&#xff1a; 正在读取软件包列表... 完成正在分析软件包的依赖关系树 正在读取状态信息... 完成 建议安装的软件包&#xff1a; p7zip-rar下列【新】软件包将被安装&#xff1a; p7zip-full升级了 0 个软件包&…

Docker的使用(一:Docker入门程序)

1、编写Dockerfile文件&#xff1b; 注&#xff1a;创建一个空的Docker工作目录dockerspace&#xff0c;进而进入该目录&#xff0c;并创建编写dockerfile文件&#xff1b; 2、编写外部文件。 注&#xff1a;在当前目录&#xff08;dockerspace&#xff09;下分别创建require…

iOS OpenCV 图像灰度处理

2017-06-21 小溪彼岸 Cocoa开发者社区推荐人&#xff1a;wo709128079 有时候开发过程中&#xff0c;切图满足不了我们的需求&#xff0c;此时我们需要对图像进行灰度处理&#xff0c;例如QQ头像在线、离线等不同状态等。 可以尝试的解决方案&#xff1a; 第一种&#xff1a;让U…

【VS开发】【电子电路技术】RJ45以太网传输线研究

RJ45以太网传输线研究 最近研究远距离差分视频传输方案&#xff0c;理所当然想到了LVDS协议。至于选用cameralink传输线&#xff0c;还是选用其他方案&#xff0c;本人更倾向于廉价的RJ45以太网线来实现LVDS差分信号的传输。 由于RJ45网线内部为4对双绞线&#xff0c;至于以太网…

Wiz开发 定时器的使用与处理

这只是一些代码片段&#xff0c;由于Wiz开发的资料实在不多&#xff0c;而且内容都不够新。这里的代码主要参考Tools.Timer这个插件&#xff0c;但是由于内部实现的很多变化&#xff0c;Tools.Timer这个插件基本上已经无法使用了。定时器的注册与删除 使用定时器&#xff0c;是…

Docker的使用(二:Docker客户端常用指令练习)

1、列出镜像&#xff1b; 2、搜索镜像&#xff1b; 3、拉取镜像&#xff1b; 4、构建镜像&#xff1b; 4.1、在Dockerfile文件所在目录构建镜像&#xff1b; 4.2、在其他目录构建镜像&#xff1b; 4.3、查看镜像是否构建成功&#xff1b; 5、删除镜像&#xff1b; 6、创建并启…

实现简书个人中心UI效果

这两天比较闲&#xff0c;简单实现了一下个人中心页面scrollView嵌套的效果&#xff0c;也就是下边这个页面,大家感受一下先&#xff1a; JSDemo2.gif 首先讲下实现思路&#xff0c;很多人看到这个界面觉得是多个scrollView嵌套实现的&#xff0c;其实苹果不推荐scrollView的嵌…

PHPCMSv9首页显示分页点击下一页跳转链接出现错误,跳转到后台的解决方案

1 引用页写为 {pc:content action"lists" catid"10" order"updatetime DESC" thumb"0" num"1" page"$_GET[page]"}{loop $data $v}....{/loop}{$pages} {/pc}2 phpcms/libs/functions/global.func.php文件 get_…

顺序查找和二分查找

{线性的顺序查找}function seqSearch(sArr: array of Integer;aCount: Integer;const index: Integer):Integer;var i: Integer;begin Result : -1; for i : 0 to aCount do if sArr[i]index then begin Result : i; Break; end;end;{对数性的二分查找}f…

Docker的使用(三:Docker Hub远程镜像管理)

1、登录 Docker Hub&#xff1b; 2、修改镜像名称&#xff1b; 3、登录认证&#xff1b; 4、推送镜像&#xff1b; 5、查看验证&#xff1b;

啊里大鱼短信发送API

https://api.alidayu.com/doc2/apiDetail?spm0.0.0.0.SEe3dm&apiId25450 转载于:https://www.cnblogs.com/shiningrise/p/5626708.html

GCD API

&#xff08;可直接复制到Xcode中查看&#xff09; /***********************************************************************************************************************************##目录##知识点&#xff1a;GCD中有2个核心概念&#xff1a;任务和队列任务&#…

查看Linux系统中某目录的大小

命令&#xff1a;du -sh 目录名来查看&#xff0c;如下 du -sh /root 命令显示结果为&#xff1a;1.2M /root 检查是否有分区使用率use&#xff05;过高&#xff0c;如发现某个分区空间接近用完&#xff0c;可以进入该分区的挂载点&#xff0c;用以下命令找出占用空间最多的文件…

Docker的使用(四:Docker Registry本地私有仓库搭建知识点总结)

任务一&#xff1a; Docker Registry本地私有仓库搭建 1、启动Docker Registry&#xff1b; 2、重命名镜像&#xff1b; 3、推送镜像&#xff1b; 4、浏览器查看验证&#xff1b; 5、文件查看验证&#xff1b; 任务二&#xff1a;Docker Registry本地私有仓库配置&#xff1b;…

iOS多线程全套:线程生命周期,多线程的四种解决方案,线程安全问题,GCD的使用,NSOperation的使用(上)

2017-07-08 remember17 Cocoa开发者社区目的 本文主要是分享iOS多线程的相关内容&#xff0c;为了更系统的讲解&#xff0c;将分为以下7个方面来展开描述。 多线程的基本概念 线程的状态与生命周期 多线程的四种解决方案&#xff1a;pthread&#xff0c;NSThread&#xff…

C基础知识小总结(十)

"如有不正确之处&#xff0c;请指出&#xff0c;谢谢" --Mood <指针和函数> 指针函数 函数指针 <最基本的使用函数指针> < 函数指针做为形参 > <字符指针> <字符数组> < 返回局部变量指针 > < 结构体指针> 指向结构体变…

支付方式(2)——支付宝集成及使用

每一个支付平台都有自己的加密、解密的原理&#xff1b;还有各种签名的原理&#xff1b;通过各种内容发送数据&#xff0c;防止恶意攻击等功能的原理。 接下来对于部署支付方式&#xff0c;首先要分清几个名词&#xff1a; 集成接入&#xff1a;支付宝已经集成好各种原理和函数…

Kali Linux攻防系统(一:攻防系统Kali Linux下载安装与更新)

任务一&#xff1a;攻防系统Kali Linux下载安装与更新 1.1、安装Kali Linux虚拟机 1.1.1、电脑硬件配置至少达到 CPU 内存 存储 >四核 >4G >20G 1.1.2、VMware Workstations版本为14及以上&#xff1b; 1.1.3、虚拟机系统版本选择Debian 8.X或者Ubuntu&#x…