Skip to content
This repository was archived by the owner on Nov 21, 2018. It is now read-only.

Commit b468468

Browse files
Fix build errors in piston-image by updating to 0.10.3
1 parent 762c204 commit b468468

File tree

213 files changed

+3874
-1957
lines changed

Some content is hidden

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

213 files changed

+3874
-1957
lines changed

piston-image-0.10.3/.gitattributes

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.jpg binary -delta
2+
*.png binary -delta

piston-image-0.10.3/.gitignore

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
.DS_Store
2+
*~
3+
*#
4+
*.o
5+
*.so
6+
*.swp
7+
*.dylib
8+
*.dSYM
9+
*.dll
10+
*.rlib
11+
*.dummy
12+
*.exe
13+
*-test
14+
/bin/main
15+
/bin/test-internal
16+
/bin/test-external
17+
/doc/
18+
/target/
19+
/build/
20+
/.rust/
21+
rusti.sh
22+
Cargo.lock

piston-image-0.10.3/.travis.yml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
language: rust
2+
sudo: false
3+
notifications:
4+
irc: "irc.mozilla.org#piston-internals"
5+
os:
6+
- linux
7+
- osx
8+
rust:
9+
- stable
10+
- beta
11+
- nightly
12+
env:
13+
global:
14+
- secure: M2MCRtyP5P/Xf2TSqrbz8cs41TQY04mK/5Fi6qgr77OKLNZlDclKiFY8BmQ6f1JhVccoE5gMIFpfPoVUu8wZ0Pe7/X4IyO4vxWawVQfE6f0NYErD9yqiE1KEi/RGKPOQfL5HFUK7ifnXvLwsAMh1ix9XMgaBZfZLQ8KhkxNRXwI=
15+
matrix:
16+
- FEATURES=''
17+
- FEATURES='gif_codec'
18+
- FEATURES='jpeg'
19+
- FEATURES='png_codec'
20+
- FEATURES='ppm'
21+
- FEATURES='tga'
22+
- FEATURES='tiff'
23+
- FEATURES='webp'
24+
- FEATURES='hdr'
25+
script:
26+
- if [ -z "$FEATURES" ]; then
27+
cargo build -v;
28+
if [ "$TRAVIS_RUST_VERSION" = "nightly" ]; then cargo test -v; fi;
29+
cargo doc -v;
30+
else
31+
cargo build -v --no-default-features --features "$FEATURES";
32+
if [ "$TRAVIS_RUST_VERSION" = "nightly" ]; then cargo test -v --no-default-features --features "$FEATURES"; fi;
33+
cargo doc -v;
34+
fi
35+
after_success: |
36+
[ $TRAVIS_BRANCH = master ] &&
37+
[ $TRAVIS_PULL_REQUEST = false ] &&
38+
cargo doc &&
39+
echo '<meta http-equiv=refresh content=0;url=image/index.html>' > target/doc/index.html &&
40+
pip install --user ghp-import &&
41+
ghp-import -n target/doc &&
42+
git push -fq https://${GH_TOKEN}:[email protected]/${TRAVIS_REPO_SLUG}.git gh-pages

piston-image-0.3.11/CHANGES.md renamed to piston-image-0.10.3/CHANGES.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1-
# Rust Image 0.3 Release Notes
1+
# Rust Image 0.4 Release Notes
22

33
Rust image aims to be a pure-Rust implementation of various popular image formats. Accompanying reading/write support, rust image provides basic imaging processing function. See `README.md` for further details.
44

55
## Known issues
66
- Interlaced (progressive) or animated images are not well supported.
77
- Images with *n* bit/channel (*n ≠ 8*) are not well supported.
8-
- No support for alpha channel in paletted PNG images.
98

109
## Changes
1110

11+
### Version 0.4
12+
- Various improvements.
13+
- Additional supported image formats (BMP and ICO).
14+
- GIF and PNG codec moved into separate crates.
15+
1216
### Version 0.3
1317
- Replace `std::old_io` with `std::io`.
1418

piston-image-0.3.11/Cargo.toml renamed to piston-image-0.10.3/Cargo.toml

+23-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "image"
3-
version = "0.3.11"
3+
version = "0.10.3"
44
license = "MIT"
55
description = "Imaging library written in Rust. Provides basic filters and decoders for the most common image formats."
66
authors = [
@@ -22,27 +22,42 @@ name = "image"
2222
path = "./src/lib.rs"
2323

2424
[dependencies]
25-
byteorder = "0.3.10"
26-
num = "0.1.25"
27-
enum_primitive = "0.0.1"
25+
byteorder = "0.5.1"
26+
num-iter = "0.1.32"
27+
num-rational = "0.1.32"
28+
num-traits = "0.1.32"
29+
enum_primitive = "0.1.0"
2830
glob = "0.2.10"
2931

3032
[dependencies.gif]
31-
version = "0.5"
33+
version = "0.9"
34+
optional = true
35+
36+
[dependencies.jpeg-decoder]
37+
version = "0.1"
3238
optional = true
3339

3440
[dependencies.png]
35-
version = "0.3"
41+
version = "0.5"
3642
optional = true
3743

44+
[dependencies.scoped_threadpool]
45+
version = "0.1"
46+
optional = true
47+
48+
[dev-dependencies]
49+
num-complex = "0.1.32"
50+
3851
[features]
39-
default = ["gif_codec", "jpeg", "png_codec", "ppm", "tga", "tiff", "webp", "bmp"]
52+
default = ["gif_codec", "jpeg", "ico", "png_codec", "ppm", "tga", "tiff", "webp", "bmp", "hdr"]
4053

4154
gif_codec = ["gif"]
42-
jpeg = []
55+
ico = ["bmp", "png_codec"]
56+
jpeg = ["jpeg-decoder"]
4357
png_codec = ["png"]
4458
ppm = []
4559
tga = []
4660
tiff = []
4761
webp = []
4862
bmp = []
63+
hdr = ["scoped_threadpool"]
File renamed without changes.

piston-image-0.3.11/README.md renamed to piston-image-0.10.3/README.md

+20-17
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@ All image processing functions provided operate on types that implement the ```G
1414

1515
Add the following to the Cargo.toml in your project:
1616

17-
```
17+
```toml
1818
[dependencies]
1919
image = "*"
2020
```
2121

2222
and import using ```extern crate```:
2323

2424
```rust
25-
extern crate image;
25+
extern crate image;
2626

27-
//Use image::
27+
//Use image::
2828
```
2929

3030
## 1. Documentation
@@ -38,8 +38,10 @@ http://www.piston.rs/image/image/index.html
3838
| Format | Decoding | Encoding |
3939
|--- |--- | --- |
4040
| PNG | All supported color types | Same as decoding|
41-
| JPEG | Baseline JPEG | Baseline JPEG |
41+
| JPEG | Baseline and progressive | Baseline JPEG |
4242
| GIF | Yes | Yes |
43+
| BMP | Yes | No |
44+
| ICO | Yes | Yes |
4345
| TIFF | Baseline(no fax and packbits support) + LZW | No |
4446
| Webp | Lossy(Luma channel only) | No |
4547
| PPM | No | Yes |
@@ -188,38 +190,37 @@ The image format is determined from the path's file extension.
188190
```rust
189191
extern crate image;
190192

191-
use std::old_io::File;
193+
use std::fs::File;
194+
use std::path::Path;
192195

193196
use image::GenericImage;
194197

195198
fn main() {
196-
//Use the open function to load an image from a PAth.
197-
//```open``` returns a dynamic image.
199+
// Use the open function to load an image from a Path.
200+
// ```open``` returns a dynamic image.
198201
let img = image::open(&Path::new("test.jpg")).unwrap();
199202

200-
//The dimensions method returns the images width and height
203+
// The dimensions method returns the images width and height
201204
println!("dimensions {:?}", img.dimensions());
202205

203-
//The color method returns the image's ColorType
206+
// The color method returns the image's ColorType
204207
println!("{:?}", img.color());
205208

206209
let ref mut fout = File::create(&Path::new("test.png")).unwrap();
207210

208-
//Write the contents of this image to the Writer in PNG format.
209-
let _ = img.save(fout, image::PNG);
211+
// Write the contents of this image to the Writer in PNG format.
212+
let _ = img.save(fout, image::PNG).unwrap();
210213
}
211214
```
212215

213216
### 6.2 Generating Fractals
214217
```rust
215218
//!An example of generating julia fractals.
216-
#![feature(old_path, old_io)]
217-
218219
extern crate num;
219220
extern crate image;
220221

221-
use std::old_io::File;
222-
use std::old_path::Path;
222+
use std::fs::File;
223+
use std::path::Path;
223224

224225
use num::complex::Complex;
225226

@@ -264,7 +265,7 @@ fn main() {
264265
let ref mut fout = File::create(&Path::new("fractal.png")).unwrap();
265266

266267
// We must indicate the image’s color type and what format to save as
267-
image::ImageLuma8(imgbuf).save(fout, image::PNG);
268+
let _ = image::ImageLuma8(imgbuf).save(fout, image::PNG);
268269
}
269270
```
270271

@@ -278,12 +279,14 @@ If the high level interface is not needed because the image was obtained by othe
278279
```rust
279280
extern crate image;
280281

282+
use std::path::Path;
283+
281284
fn main() {
282285

283286
let buffer: &[u8] = ...; // Generate the image data
284287

285288
// Save the buffer as "image.png"
286-
image::save_buffer(&Path::new("image.png"), buffer, 800, 600, image::RGB(8))
289+
image::save_buffer(&Path::new("image.png"), buffer, 800, 600, image::RGB(8)).unwrap()
287290
}
288291

289292
```

piston-image-0.10.3/benches/load.rs

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#![feature(test)]
2+
3+
extern crate image;
4+
extern crate test;
5+
6+
use std::{fs, path};
7+
use std::io::Read;
8+
use image::ImageFormat;
9+
10+
struct BenchDef<'a> {
11+
dir: &'a [&'a str],
12+
format: ImageFormat,
13+
}
14+
15+
const IMAGE_DIR: [&'static str; 3] = [".", "tests", "images"];
16+
const BMP: BenchDef<'static> = BenchDef {dir: &["bmp", "images"], format: ImageFormat::BMP};
17+
18+
fn bench_load(b: &mut test::Bencher, def: &BenchDef, filename: &str, ) {
19+
let mut path: path::PathBuf = IMAGE_DIR.iter().collect();
20+
for d in def.dir {
21+
path.push(d);
22+
}
23+
path.push(filename);
24+
let mut fin = fs::File::open(path).unwrap();
25+
let mut buf = Vec::new();
26+
fin.read_to_end(&mut buf).unwrap();
27+
b.iter(|| {
28+
image::load_from_memory_with_format(&buf, def.format).unwrap();
29+
})
30+
}
31+
32+
#[bench]
33+
fn bench_load_bmp_1bit(b: &mut test::Bencher) {
34+
bench_load(b, &BMP, "Core_1_Bit.bmp");
35+
}
36+
37+
#[bench]
38+
fn bench_load_bmp_4bit(b: &mut test::Bencher) {
39+
bench_load(b, &BMP, "Core_4_Bit.bmp");
40+
}
41+
42+
#[bench]
43+
fn bench_load_bmp_8bit(b: &mut test::Bencher) {
44+
bench_load(b, &BMP, "Core_8_Bit.bmp");
45+
}
46+
47+
#[bench]
48+
fn bench_load_bmp_16bit(b: &mut test::Bencher) {
49+
bench_load(b, &BMP, "rgb16.bmp");
50+
}
51+
52+
#[bench]
53+
fn bench_load_bmp_24bit(b: &mut test::Bencher) {
54+
bench_load(b, &BMP, "rgb24.bmp");
55+
}
56+
57+
#[bench]
58+
fn bench_load_bmp_32bit(b: &mut test::Bencher) {
59+
bench_load(b, &BMP, "rgb32.bmp");
60+
}
61+
62+
#[bench]
63+
fn bench_load_bmp_4rle(b: &mut test::Bencher) {
64+
bench_load(b, &BMP, "pal4rle.bmp");
65+
}
66+
67+
#[bench]
68+
fn bench_load_bmp_8rle(b: &mut test::Bencher) {
69+
bench_load(b, &BMP, "pal8rle.bmp");
70+
}
71+
72+
#[bench]
73+
fn bench_load_bmp_16bf(b: &mut test::Bencher) {
74+
bench_load(b, &BMP, "rgb16-565.bmp");
75+
}
76+
77+
#[bench]
78+
fn bench_load_bmp_32bf(b: &mut test::Bencher) {
79+
bench_load(b, &BMP, "rgb32bf.bmp");
80+
}
34.6 KB
Loading
+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
//!An example of generating julia fractals.
2+
extern crate num_complex;
3+
extern crate image;
4+
5+
use std::fs::File;
6+
use std::path::Path;
7+
8+
use num_complex::Complex;
9+
10+
fn main() {
11+
let max_iterations = 256u16;
12+
13+
let imgx = 800;
14+
let imgy = 800;
15+
16+
let scalex = 4.0 / imgx as f32;
17+
let scaley = 4.0 / imgy as f32;
18+
19+
// Create a new ImgBuf with width: imgx and height: imgy
20+
let mut imgbuf = image::ImageBuffer::new(imgx, imgy);
21+
22+
// Iterate over the coordiantes and pixels of the image
23+
for (x, y, pixel) in imgbuf.enumerate_pixels_mut() {
24+
let cy = y as f32 * scaley - 2.0;
25+
let cx = x as f32 * scalex - 2.0;
26+
27+
let mut z = Complex::new(cx, cy);
28+
let c = Complex::new(-0.4, 0.6);
29+
30+
let mut i = 0;
31+
32+
for t in 0..max_iterations {
33+
if z.norm() > 2.0 {
34+
break
35+
}
36+
z = z * z + c;
37+
i = t;
38+
}
39+
40+
// Create an 8bit pixel of type Luma and value i
41+
// and assign in to the pixel at position (x, y)
42+
*pixel = image::Luma([i as u8]);
43+
44+
}
45+
46+
47+
// Save the image as “fractal.png”
48+
let ref mut fout = File::create(&Path::new("fractal.png")).unwrap();
49+
50+
// We must indicate the image’s color type and what format to save as
51+
let _ = image::ImageLuma8(imgbuf).save(fout, image::PNG);
52+
}

0 commit comments

Comments
 (0)