Skip to content

Commit 91b83c8

Browse files
authored
Merge pull request #32 from koher/dev-0.6.0
Develop 0.6.0
2 parents 961ed8f + d0413f6 commit 91b83c8

48 files changed

Lines changed: 2124 additions & 5682 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.travis.yml

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,5 @@
11
matrix:
22
include:
3-
- os: osx
4-
language: objective-c
5-
osx_image: xcode9.4
6-
script:
7-
- set -o pipefail
8-
- xcodebuild test -scheme EasyImagy-macOS -configuration Debug | xcpretty -c
9-
- xcodebuild test -scheme EasyImagy-iOS -configuration Debug -sdk iphonesimulator -destination "platform=iOS Simulator,name=iPhone X" | xcpretty -c
10-
- xcodebuild test -scheme EasyImagy-tvOS -configuration Debug -sdk appletvsimulator -destination "platform=tvOS Simulator,name=Apple TV 4K" | xcpretty -c
11-
- xcodebuild build -scheme EasyImagy-watchOS -configuration Debug -sdk watchsimulator -destination "platform=watchOS Simulator,name=Apple Watch Series 3 - 38mm" | xcpretty -c
12-
- xcodebuild test -scheme EasyImagy-macOS -configuration Release | xcpretty -c
13-
- xcodebuild test -scheme EasyImagy-iOS -configuration Release -sdk iphonesimulator -destination "platform=iOS Simulator,name=iPhone X" | xcpretty -c
14-
- xcodebuild test -scheme EasyImagy-tvOS -configuration Release -sdk appletvsimulator -destination "platform=tvOS Simulator,name=Apple TV 4K" | xcpretty -c
15-
- xcodebuild build -scheme EasyImagy-watchOS -configuration Release -sdk watchsimulator -destination "platform=watchOS Simulator,name=Apple Watch Series 3 - 38mm" | xcpretty -c
163
- os: osx
174
language: objective-c
185
osx_image: xcode10
@@ -39,15 +26,6 @@ matrix:
3926
- xcodebuild test -scheme EasyImagy-iOS -configuration Release -sdk iphonesimulator -destination "platform=iOS Simulator,name=iPhone XS" | xcpretty -c
4027
- xcodebuild test -scheme EasyImagy-tvOS -configuration Release -sdk appletvsimulator -destination "platform=tvOS Simulator,name=Apple TV 4K" | xcpretty -c
4128
- xcodebuild build -scheme EasyImagy-watchOS -configuration Release -sdk watchsimulator -destination "platform=watchOS Simulator,name=Apple Watch Series 4 - 44mm" | xcpretty -c
42-
- os: osx
43-
language: generic
44-
osx_image: xcode9.4
45-
script:
46-
- swift --version
47-
- swift build
48-
- swift test
49-
- swift build -c release
50-
- swift test -c release
5129
- os: osx
5230
language: generic
5331
osx_image: xcode10
@@ -66,18 +44,6 @@ matrix:
6644
- swift test
6745
- swift build -c release
6846
- swift test -c release
69-
- os: linux
70-
language: generic
71-
sudo: required
72-
env: SWIFT_VERSION=4.1
73-
install:
74-
- eval "$(curl -sL https://swiftenv.fuller.li/install.sh)"
75-
script:
76-
- swift --version
77-
- swift build
78-
- swift test
79-
- swift build -c release
80-
- swift test -c release
8147
- os: linux
8248
language: generic
8349
sudo: required
@@ -100,3 +66,5 @@ matrix:
10066
- swift --version
10167
- swift build
10268
- swift test
69+
- swift build -c release
70+
- swift test -c release

EasyImagy.xcodeproj/project.pbxproj

Lines changed: 82 additions & 86 deletions
Large diffs are not rendered by default.

EasyImagy.xcodeproj/xcshareddata/xcschemes/EasyImagy-iOS.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0940"
3+
LastUpgradeVersion = "1000"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

EasyImagy.xcodeproj/xcshareddata/xcschemes/EasyImagy-macOS.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0940"
3+
LastUpgradeVersion = "1000"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

EasyImagy.xcodeproj/xcshareddata/xcschemes/EasyImagy-tvOS.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0940"
3+
LastUpgradeVersion = "1000"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

EasyImagy.xcodeproj/xcshareddata/xcschemes/EasyImagy-watchOS.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0940"
3+
LastUpgradeVersion = "1000"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:4.0
1+
// swift-tools-version:4.2
22
// The swift-tools-version declares the minimum version of Swift required to build this package.
33

44
import PackageDescription

README.md

Lines changed: 26 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
[![Build Status](https://travis-ci.org/koher/EasyImagy.svg?branch=master)](https://travis-ci.org/koher/EasyImagy)
44

5-
_EasyImagy_ makes it easy to process images in Swift.
5+
_EasyImagy_ is a Swift library for image processing.
66

77
```swift
88
var image = Image<RGBA<UInt8>>(named: "ImageName")!
99

10-
print(image[x, y])
10+
let pixel: RGBA<UInt8> = image[x, y]
1111
image[x, y] = RGBA(red: 255, green: 0, blue: 0, alpha: 127)
1212
image[x, y] = RGBA(0xFF00007F) // red: 255, green: 0, blue: 0, alpha: 127
1313

@@ -16,7 +16,7 @@ for pixel in image {
1616
// ...
1717
}
1818

19-
// Processes images (e.g. binarizations)
19+
// Image processing (e.g. binarizations)
2020
let binarized: Image<Bool> = image.map { $0.gray >= 127 }
2121

2222
// From/to `UIImage`
@@ -26,9 +26,21 @@ imageView.image = image.uiImage
2626

2727
## Introduction
2828

29-
Processing images by _CoreGraphics_ is complicated: various formats, old C APIs and painful memory management. _EasyImagy_ provides easier APIs to process images.
29+
Image processing by _CoreGraphics_ is complicated: various formats, old C APIs and painful memory management. _EasyImagy_ provides easy and Swifty APIs for image processing.
3030

31-
Typically the `Image` type is used with the `RGBA` type. The `RGBA` is a simple structure declared as follows.
31+
With _EasyImagy_, images are handled as instances of the `Image` type. `Image` is a type similar to `Array`.
32+
33+
```swift
34+
var image: Image<UInt8> = Image(width: 640, height: 480, pixels: [255, 248, /* ... */])
35+
36+
let pixel: UInt8 = image[x, y]
37+
image[x, y] = 255
38+
39+
let width: Int = image.width // 640
40+
let height: Int = image.height // 480
41+
```
42+
43+
Typically `Image` is used with the `RGBA` type. `RGBA` is a simple structure declared as follows.
3244

3345
```swift
3446
struct RGBA<Channel> {
@@ -39,15 +51,17 @@ struct RGBA<Channel> {
3951
}
4052
```
4153

42-
You can easily access to pixels using subscripts like `image[x, y]` and also their channels using properties `red`, `green`, `blue` and `alpha`.
54+
Because both `Image` and `RGBA` are generic types, concrete image types have a nested type parameter like `Image<RGBA<UInt8>>` when `Image` and `RGBA` are combined.
4355

44-
In addition, `Image` and `RGBA` provide some powerful APIs to process images. For example, it is possible to convert an image to grayscale combining `Image.map` with `RGBA.gray` in one line as shown below.
56+
`Image` and `RGBA` provide some powerful APIs to process images. For example, it is possible to convert an RGBA image to grayscale combining `Image.map` with `RGBA.gray` in one line as shown below.
4557

4658
```swift
59+
var image = Image<RGBA<UInt8>>(named: "ImageName")!
4760
let grayscale: Image<UInt8> = image.map { $0.gray }
61+
4862
```
4963

50-
Another notable feature of _EasyImagy_ is that the `Image` is a `struct`, i.e. a value type, with copy-on-write. It means
64+
Another notable feature of _EasyImagy_ is that `Image` is a structure, i.e. a value type, with copy-on-write. It means
5165

5266
- `Image` instances never be shared
5367
- defensive copying is unnecessary
@@ -281,42 +295,21 @@ imageView.image = image.uiImage
281295

282296
## Requirements
283297

284-
- Swift 4 or later
285-
- Xcode 9 or later
298+
- Swift 4.2 or later
299+
- Xcode 10 or later
286300

287301
## Installation
288302

289303
### Swift Package Manager
290304

291-
**Package.swift**
292-
293305
```swift
294-
// swift-tools-version:4.0
295-
// The swift-tools-version declares the minimum version of Swift required to build this package.
296-
297-
import PackageDescription
298-
299-
let package = Package(
300-
...
301-
dependencies: [
302-
.package(url: "https://github.com/koher/EasyImagy.git", from: "0.5.0"),
303-
],
304-
targets: [
305-
.target(
306-
...
307-
dependencies: [
308-
"EasyImagy",
309-
]),
310-
]
311-
)
306+
.package(url: "https://github.com/koher/EasyImagy.git", from: "0.6.0"),
312307
```
313308

314309
### [Carthage](https://github.com/Carthage/Carthage)
315310

316-
**Cartfile**
317-
318311
```
319-
github "koher/EasyImagy" ~> 0.5.0
312+
github "koher/EasyImagy" ~> 0.6.0
320313
```
321314

322315
### Manually

Sources/EasyImagy/AnyImage.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ public struct AnyImage<Pixel> : ImageProtocol {
77
private var box: AnyImageBox<Pixel>
88
private let lock = NSLock()
99

10-
public let xRange: CountableRange<Int>
11-
public let yRange: CountableRange<Int>
10+
public let xRange: Range<Int>
11+
public let yRange: Range<Int>
1212

13-
private init(box: AnyImageBox<Pixel>, xRange: CountableRange<Int>, yRange: CountableRange<Int>) {
13+
private init(box: AnyImageBox<Pixel>, xRange: Range<Int>, yRange: Range<Int>) {
1414
self.box = box
1515
self.xRange = xRange
1616
self.yRange = yRange
1717
}
1818

19-
internal init<I : ImageProtocol>(_ image: I, xRange: CountableRange<Int>, yRange: CountableRange<Int>) where I.Pixel == Pixel {
19+
internal init<I : ImageProtocol>(_ image: I, xRange: Range<Int>, yRange: Range<Int>) where I.Pixel == Pixel {
2020
self.box = ImageBox<I>(image)
2121
self.xRange = xRange
2222
self.yRange = yRange
@@ -46,7 +46,7 @@ public struct AnyImage<Pixel> : ImageProtocol {
4646
}
4747
}
4848

49-
public subscript(xRange: CountableRange<Int>, yRange: CountableRange<Int>) -> AnyImage<Pixel> {
49+
public subscript(xRange: Range<Int>, yRange: Range<Int>) -> AnyImage<Pixel> {
5050
return AnyImage(box: self.box, xRange: xRange, yRange: yRange)
5151
}
5252
}

0 commit comments

Comments
 (0)