Skip to content

Commit

Permalink
4.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
EyreFree committed Nov 1, 2017
1 parent 9795d12 commit c866f13
Show file tree
Hide file tree
Showing 9 changed files with 129 additions and 20 deletions.
3 changes: 2 additions & 1 deletion EFQRCode.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Pod::Spec.new do |s|
s.name = 'EFQRCode'
s.version = '4.0.0'
s.version = '4.1.0'
s.summary = 'A better way to operate quick response code in Swift.'

s.description = <<-DESC
Expand All @@ -22,5 +22,6 @@ s.tvos.deployment_target = '9.0'
s.requires_arc = true

s.source_files = 'Source/**/*.{h,swift}'

s.frameworks = 'ImageIO'
end
4 changes: 2 additions & 2 deletions Examples/iOS/Resources/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>4.0.0</string>
<string>4.1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>4.0.0.0</string>
<string>4.1.0.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppleMusicUsageDescription</key>
Expand Down
4 changes: 2 additions & 2 deletions Examples/macOS/macOS Example/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>4.0.0</string>
<string>4.1.0</string>
<key>CFBundleVersion</key>
<string>4.0.0.0</string>
<string>4.1.0.0</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.developer-tools</string>
<key>LSMinimumSystemVersion</key>
Expand Down
4 changes: 2 additions & 2 deletions Examples/tvOS/tvOS Example/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>4.0.0</string>
<string>4.1.0</string>
<key>CFBundleVersion</key>
<string>4.0.0.0</string>
<string>4.1.0.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIMainStoryboardFile</key>
Expand Down
30 changes: 27 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ EFQRCode is a lightweight, pure-Swift library for generating pretty QRCode image
## Overview

![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/QRCode1.jpg)|![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/QRCode2.jpg)|![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/QRCode3.jpg)|![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/QRCode4.jpg)
:---------------------:|:---------------------:|:---------------------:|:---------------------:
![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/QRCode5.jpg)|![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/QRCode6.jpg)|![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/QRCode7.jpg)|![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/QRCode8.jpg)
:---------------------:|:---------------------:|:---------------------:|:---------------------:
![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/QRCodeGIF1.gif)|![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/QRCodeGIF2.gif)|![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/QRCodeGIF7.gif)|![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/QRCodeGIF8.gif)

## Demo

Expand Down Expand Up @@ -161,7 +161,31 @@ Result:

<img src="https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/sample1.jpg" width = "36%"/>

#### 4. Next
#### 4. Generation from GIF

You can create GIF QRCode with function `generateWithGIF` of class `EFQRCode`, for example:

```swift
// data: Data of input GIF
// generator: An object of EFQRCodeGenerator, use for setting
// pathToSave (Optional): Path to save the output GIF, default is temp path
// delay (Optional): Output QRCode GIF delay, default is same as input GIF
// loopCount (Optional): Output QRCode GIF loopCount, default is same as input GIF
```

```swift
if let qrcodeData = EFQRCode.generateWithGIF(data: data, generator: generator) {
print("Create QRCode image success.")
} else {
print("Create QRCode image failed!")
}
```

You can get more information from the demo, result will like this:

<img src="https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/QRCodeGIF6.gif" width = "42%"/>

#### 5. Next

Learn more from [User Guide](https://github.com/EyreFree/EFQRCode/blob/master/USERGUIDE.md).

Expand Down
40 changes: 32 additions & 8 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ EFQRCode 是一个轻量级的、用来生成和识别二维码的纯 Swift 库
## 概述

![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/QRCode1.jpg)|![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/QRCode2.jpg)|![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/QRCode3.jpg)|![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/QRCode4.jpg)
:---------------------:|:---------------------:|:---------------------:|:---------------------:
![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/QRCode5.jpg)|![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/QRCode6.jpg)|![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/QRCode7.jpg)|![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/QRCode8.jpg)
:---------------------:|:---------------------:|:---------------------:|:---------------------:
![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/QRCodeGIF1.gif)|![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/QRCodeGIF2.gif)|![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/QRCodeGIF7.gif)|![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/QRCodeGIF8.gif)

## 示例

Expand Down Expand Up @@ -139,11 +139,11 @@ if let testImage = UIImage(named: "test.png")?.toCGImage() {
根据所输入参数创建各种艺术二维码图片,快速使用方式如下:

```swift
// content: Content of QR Code
// size (Optional): Width and height of image
// backgroundColor (Optional): Background color of QRCode
// foregroundColor (Optional): Foreground color of QRCode
// watermark (Optional): Background image of QRCode
// content: 二维码内容
// size (Optional): 二维码宽高
// backgroundColor (Optional): 二维码背景色
// foregroundColor (Optional): 二维码前景色
// watermark (Optional): 水印图
```

```swift
Expand All @@ -161,7 +161,31 @@ if let tryImage = EFQRCode.generate(

<img src="https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/sample1.jpg" width = "36%"/>

#### 4. 接下来
#### 4. 动态二维码

可通过 EFQRCode 的类方法 generateWithGIF 来创建 GIF 二维码,使用方式如下:

```swift
// data: 输入的 GIF 图片的数据
// generator: 一个用来获取设置的 EFQRCodeGenerator 对象
// pathToSave (Optional): 用来存储 GIF 的路径,默认不填的话会存储在临时路径
// delay (Optional): 输出的动态 QRCode 的帧间延时,默认不填的话从输入的 GIF 图片获取
// loopCount (Optional): 输出的动态 QRCode 的循环次数,默认不填的话从输入的 GIF 图片获取
```

```swift
if let qrcodeData = EFQRCode.generateWithGIF(data: data, generator: generator) {
print("Create QRCode image success.")
} else {
print("Create QRCode image failed!")
}
```

你可以通过查看 Demo 代码的方式来获取更多信息,结果预览:

<img src="https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/QRCodeGIF6.gif" width = "42%"/>

#### 5. 接下来

查看 [用户手册](https://github.com/EyreFree/EFQRCode/blob/master/USERGUIDE_CN.md) 了解更多细节。

Expand Down
4 changes: 2 additions & 2 deletions Source/EFQRCode+GIF.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public extension EFQRCode {

public static var tempResultPath: URL?

public static func generateWithGIF(data: Data, generator: EFQRCodeGenerator, delay: Double? = nil, loopCount: Int? = nil) -> Data? {
public static func generateWithGIF(data: Data, generator: EFQRCodeGenerator, pathToSave: URL? = nil, delay: Double? = nil, loopCount: Int? = nil) -> Data? {
if let source = CGImageSourceCreateWithData(data as CFData, nil) {
var frames = source.toCGImages()

Expand Down Expand Up @@ -85,7 +85,7 @@ public extension EFQRCode {
}

if let fileProperties = fileProperties, framePropertiesArray.count == frames.count {
if let url = frames.saveToGIFFile(framePropertiesArray: framePropertiesArray, fileProperties: fileProperties) {
if let url = frames.saveToGIFFile(framePropertiesArray: framePropertiesArray, fileProperties: fileProperties, url: pathToSave) {
return try? Data(contentsOf: url)
}
}
Expand Down
30 changes: 30 additions & 0 deletions USERGUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,3 +256,33 @@ Threshold for binarization (Only for mode binarization).
Origin | 0.3 | 0.5 | 0.8
:-------------------------:|:-------------------------:|:-------------------------:|:-------------------------:
![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/binarizationThreshold0.jpg)|![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/binarizationThreshold1.jpg)|![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/binarizationThreshold2.jpg)|![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/binarizationThreshold3.jpg)

### 3. Generation from GIF

1. First you should get the complete data of a GIF file, type is `Data`, can not get from `UIImage` or you will only get the first frame;
2. Then you can create GIF QRCode with function `generateWithGIF` of class `EFQRCode`, for example:

```swift
// data: Data of input GIF
// generator: An object of EFQRCodeGenerator, use for setting
// pathToSave (Optional): Path to save the output GIF, default is temp path
// delay (Optional): Output QRCode GIF delay, default is same as input GIF
// loopCount (Optional): Output QRCode GIF loopCount, default is same as input GIF
```

The `generator` here is an object of class `EFQRCodeGenerator`, to process each frame in GIF, you can find the use of it above.

```swift
if let qrcodeData = EFQRCode.generateWithGIF(data: data, generator: generator) {
print("Create QRCode image success.")
} else {
print("Create QRCode image failed!")
}
```

You can get more information from the demo, result will like this:

<img src="https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/QRCodeGIF6.gif" width = "42%"/>

3. Now you can get the complete data of output QRCode GIF, next we can save it to local path / system photo library / upload to server or some other things you want to do;
4. Emmmmmm, note that the `tempResultPath` of `EFQRcode` is the path of data of GIF of last generation.
30 changes: 30 additions & 0 deletions USERGUIDE_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,3 +256,33 @@ square | circle
Origin | 0.3 | 0.5 | 0.8
:-------------------------:|:-------------------------:|:-------------------------:|:-------------------------:
![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/binarizationThreshold0.jpg)|![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/binarizationThreshold1.jpg)|![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/binarizationThreshold2.jpg)|![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/binarizationThreshold3.jpg)

### 3. 动态二维码

1. 首先需要从网络/本地/相册等来源获取输入的 GIF 文件的完整数据,要 Data 类型,不能通过 UIImage 来获取,不然的话只能取到 GIF 的第一帧;
2. 然后可以通过 EFQRCode 的类方法 generateWithGIF 来创建 GIF 二维码,使用方式如下:

```swift
// data: 输入的 GIF 图片的数据
// generator: 一个用来获取设置的 EFQRCodeGenerator 对象
// pathToSave (Optional): 用来存储 GIF 的路径,默认不填的话会存储在临时路径
// delay (Optional): 输出的动态 QRCode 的帧间延时,默认不填的话从输入的 GIF 图片获取
// loopCount (Optional): 输出的动态 QRCode 的循环次数,默认不填的话从输入的 GIF 图片获取
```

这里的 generator 是一个 EFQRCodeGenerator 类型的对象,用来对 GIF 中的每一帧进行处理,详细用法参考上文。

```swift
if let qrcodeData = EFQRCode.generateWithGIF(data: data, generator: generator) {
print("Create QRCode image success.")
} else {
print("Create QRCode image failed!")
}
```

你可以通过查看 Demo 代码的方式来获取更多信息,结果预览:

<img src="https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/QRCodeGIF6.gif" width = "42%"/>

3. 到这里我们已经获取了生成的 GIF 文件的完整数据,接下来可以进行将返回的 Data 类型的数据直接保存到本地/系统相册/上传到服务器等你想做的操作;
4. 唔,这里有一个隐藏设定,最近一次生成的 GIF 二维码是保存在 EFQRcode 类的 tempResultPath 所在的位置的。

0 comments on commit c866f13

Please sign in to comment.