oily_png 1.1.2 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1b84a04e46948ddd4be00b39c9875a2ab28f20b1
4
- data.tar.gz: 75442b85ad8fde3f8bed8a49767c4b03739ff469
3
+ metadata.gz: 8ac04ee8bba389a3335e3c2bab7d541669e007ca
4
+ data.tar.gz: 82a58ceea811af07716f47806b6e3470ade19016
5
5
  SHA512:
6
- metadata.gz: 2df5b8e3fdcb0c7bc55021231cbc06b077892de1a0cea5cdcbda979bdc7f94875a980520c67ca2e786c2ef5fb68780988c93d5ccf4e650bf67bbd108e3363ecf
7
- data.tar.gz: 70137f6debdd292c3b9bc5b443e740e849fef83ec35175e154f8b0feb84211537dab1508b0f5427ac23f182c8e917df583a1bd6d3c1236ce2c163fb36a92cbb1
6
+ metadata.gz: 3758ec87e787a7990bccb674241ef46eb4678226bfb745e08926c25227bc3d5254faaf7502b2ec067e3ba9052770cdcca8272f01abc2d96aa499474c91fa388e
7
+ data.tar.gz: 6468851a2871e1309457b51288fe8b33f35f52296f2a528d10574fc8758f01ae7b91c2ab685157b557e603014c89301a2c6351d5c1950fedc4f0adf9827dc60c
@@ -30,6 +30,8 @@ void Init_oily_png() {
30
30
  VALUE OilyPNG_Operations = rb_define_module_under(OilyPNG, "Operations");
31
31
  rb_define_method(OilyPNG_Operations, "compose!", oily_png_compose_bang, -1);
32
32
  rb_define_method(OilyPNG_Operations, "replace!", oily_png_replace_bang, -1);
33
+ rb_define_method(OilyPNG_Operations, "rotate_left!", oily_png_rotate_left_bang, 0);
34
+ rb_define_method(OilyPNG_Operations, "rotate_right!", oily_png_rotate_right_bang, 0);
33
35
  }
34
36
 
35
37
  char oily_png_samples_per_pixel(char color_mode) {
@@ -120,3 +120,41 @@ VALUE oily_png_replace_bang(int argc, VALUE *argv, VALUE self) {
120
120
  }
121
121
  return self;
122
122
  }
123
+
124
+ VALUE oily_png_rotate_left_bang(VALUE self){
125
+ int store_at;
126
+ VALUE pixel_value;
127
+ int canvas_width = NUM2INT(rb_funcall(self, rb_intern("width"), 0));
128
+ int canvas_height = NUM2INT(rb_funcall(self, rb_intern("height"), 0));
129
+ VALUE original_pixels = rb_funcall(self, rb_intern("pixels"), 0);
130
+ VALUE new_pixels = rb_ary_dup(original_pixels);
131
+ int i, j;
132
+ for( j = 0 ; j < canvas_width; j++ ){
133
+ for( i = 0 ; i < canvas_height; i++ ){
134
+ store_at = (canvas_width - 1 - j)*canvas_height + i;
135
+ pixel_value = rb_ary_entry(original_pixels, i*canvas_width + j);
136
+ rb_ary_store(new_pixels, store_at, pixel_value );
137
+ }
138
+ }
139
+ rb_funcall(self, rb_intern("replace_canvas!"), 3, INT2NUM(canvas_height), INT2NUM(canvas_width), new_pixels);
140
+ return self;
141
+ }
142
+
143
+ VALUE oily_png_rotate_right_bang(VALUE self){
144
+ int store_at;
145
+ VALUE pixel_value;
146
+ int canvas_width = NUM2INT(rb_funcall(self, rb_intern("width"), 0));
147
+ int canvas_height = NUM2INT(rb_funcall(self, rb_intern("height"), 0));
148
+ VALUE original_pixels = rb_funcall(self, rb_intern("pixels"), 0);
149
+ VALUE new_pixels = rb_ary_dup(original_pixels);
150
+ int i, j;
151
+ for( j = 0; j < canvas_width; j++ ){
152
+ for( i = 0; i < canvas_height; i++ ){
153
+ store_at = j * canvas_height + (canvas_height - i - 1);
154
+ pixel_value = rb_ary_entry(original_pixels, i*canvas_width + j);
155
+ rb_ary_store(new_pixels, store_at, pixel_value );
156
+ }
157
+ }
158
+ rb_funcall(self, rb_intern("replace_canvas!"), 3, INT2NUM(canvas_height), INT2NUM(canvas_width), new_pixels);
159
+ return self;
160
+ }
@@ -33,4 +33,15 @@ VALUE oily_png_compose_bang(int argc, VALUE *argv, VALUE c);
33
33
  */
34
34
  VALUE oily_png_replace_bang(int argc, VALUE *argv, VALUE c);
35
35
 
36
+
37
+ /*
38
+ C replacement method for rotating the image 90 degrees counter-clockwise.
39
+ */
40
+ VALUE oily_png_rotate_left_bang(VALUE self);
41
+
42
+ /*
43
+ C replacement method for rotating the image 90 degrees clockwise.
44
+ */
45
+ VALUE oily_png_rotate_right_bang(VALUE self);
46
+
36
47
  #endif
data/lib/oily_png.rb CHANGED
@@ -10,6 +10,7 @@ module OilyPNG
10
10
 
11
11
  base::Color.extend OilyPNG::Color
12
12
  base::Canvas.send(:include, OilyPNG::Resampling)
13
+ base::Canvas.send(:include, OilyPNG::Operations)
13
14
  end
14
15
  end
15
16
 
@@ -1,3 +1,3 @@
1
1
  module OilyPNG
2
- VERSION = "1.1.2"
2
+ VERSION = "1.2.0"
3
3
  end
data/oily_png.gemspec CHANGED
@@ -29,7 +29,7 @@ Gem::Specification.new do |s|
29
29
 
30
30
  s.add_development_dependency('rake')
31
31
  s.add_development_dependency('rake-compiler')
32
- s.add_development_dependency('rspec', '~> 2')
32
+ s.add_development_dependency('rspec', '~> 3')
33
33
 
34
34
  s.rdoc_options << '--title' << s.name << '--main' << 'README.rdoc' << '--line-numbers' << '--inline-source'
35
35
  s.extra_rdoc_files = ['README.rdoc']
data/spec/color_spec.rb CHANGED
@@ -13,24 +13,24 @@ describe OilyPNG::Color do
13
13
 
14
14
  describe '#compose_quick' do
15
15
  it 'should use the foregorund color as is when the background color is fully transparent' do
16
- compose_quick(@non_opaque, @fully_transparent).should == @non_opaque
16
+ expect(compose_quick(@non_opaque, @fully_transparent)).to be(@non_opaque)
17
17
  end
18
18
 
19
19
  it 'should use the foregorund color as is when an opaque color is given as foreground color' do
20
- compose_quick(@opaque, @white).should == @opaque
20
+ expect(compose_quick(@opaque, @white)).to be(@opaque)
21
21
  end
22
22
 
23
23
  it 'should use the background color as is when a fully transparent pixel is given as foreground color' do
24
- compose_quick(@fully_transparent, @white).should == @white
24
+ expect(compose_quick(@fully_transparent, @white)).to be(@white)
25
25
  end
26
26
 
27
27
  it 'should compose pixels correctly' do
28
- compose_quick(@non_opaque, @white).should == 0x9fc2d6ff
28
+ expect(compose_quick(@non_opaque, @white)).to be(0x9fc2d6ff)
29
29
  end
30
30
 
31
31
  it 'should compose colors exactly the same as ChunkyPNG' do
32
32
  fg, bg = rand(0xffffffff), rand(0xffffffff)
33
- compose_quick(fg, bg).should == ChunkyPNG::Color.compose_quick(fg, bg)
33
+ expect(compose_quick(fg, bg)).to be(ChunkyPNG::Color.compose_quick(fg, bg))
34
34
  end
35
35
  end
36
36
 
@@ -39,11 +39,11 @@ describe OilyPNG::Color do
39
39
  let(:color_b) { rand(0xffffffff) }
40
40
  subject { euclidean_distance_rgba(color_a, color_b) }
41
41
 
42
- it { should == ChunkyPNG::Color.euclidean_distance_rgba(color_a, color_b) }
42
+ it { is_expected.to eq(ChunkyPNG::Color.euclidean_distance_rgba(color_a, color_b)) }
43
43
 
44
44
  context 'when both colors are the same' do
45
45
  let(:color_b) { color_a }
46
- it { should == 0 }
46
+ it { is_expected.to eq(0) }
47
47
  end
48
48
  end
49
49
  end
@@ -3,12 +3,12 @@ require 'spec_helper'
3
3
  describe OilyPNG::PNGDecoding do
4
4
 
5
5
  it "should call ChunkyPNG::Color.pixel_bytesize in the pure ruby version" do
6
- ChunkyPNG::Color.should_receive(:pixel_bytesize).and_return(3)
6
+ expect(ChunkyPNG::Color).to receive(:pixel_bytesize).and_return(3)
7
7
  ChunkyPNG::Canvas.from_file(resource_file('square.png'))
8
8
  end
9
9
 
10
10
  it "should not call ChunkyPNG::Color.pixel_bytesize in the native version" do
11
- ChunkyPNG::Color.should_not_receive(:pixel_bytesize)
11
+ expect(ChunkyPNG::Color).to receive(:pixel_bytesize).never
12
12
  OilyPNG::Canvas.from_file(resource_file('square.png'))
13
13
  end
14
14
 
@@ -17,34 +17,34 @@ describe OilyPNG::PNGDecoding do
17
17
 
18
18
  it "should decode NONE filtering exactly the same as ChunkyPNG" do
19
19
  filtered_data = @reference.to_blob(:filtering => ChunkyPNG::FILTER_NONE)
20
- ChunkyPNG::Canvas.from_blob(filtered_data).should == OilyPNG::Canvas.from_blob(filtered_data)
20
+ expect(ChunkyPNG::Canvas.from_blob(filtered_data)).to eq(OilyPNG::Canvas.from_blob(filtered_data))
21
21
  end
22
22
 
23
23
  it "should decode SUB filtering exactly the same as ChunkyPNG" do
24
24
  filtered_data = @reference.to_blob(:filtering => ChunkyPNG::FILTER_SUB)
25
- ChunkyPNG::Canvas.from_blob(filtered_data).should == OilyPNG::Canvas.from_blob(filtered_data)
25
+ expect(ChunkyPNG::Canvas.from_blob(filtered_data)).to eq(OilyPNG::Canvas.from_blob(filtered_data))
26
26
  end
27
27
 
28
28
  it "should decode UP filtering exactly the same as ChunkyPNG" do
29
29
  filtered_data = @reference.to_blob(:filtering => ChunkyPNG::FILTER_UP)
30
- ChunkyPNG::Canvas.from_blob(filtered_data).should == OilyPNG::Canvas.from_blob(filtered_data)
30
+ expect(ChunkyPNG::Canvas.from_blob(filtered_data)).to eq(OilyPNG::Canvas.from_blob(filtered_data))
31
31
  end
32
32
 
33
33
  it "should decode AVERAGE filtering exactly the same as ChunkyPNG" do
34
34
  filtered_data = @reference.to_blob(:filtering => ChunkyPNG::FILTER_AVERAGE)
35
- ChunkyPNG::Canvas.from_blob(filtered_data).should == OilyPNG::Canvas.from_blob(filtered_data)
35
+ expect(ChunkyPNG::Canvas.from_blob(filtered_data)).to eq(OilyPNG::Canvas.from_blob(filtered_data))
36
36
  end
37
37
 
38
38
  it "should decode PAETH filtering exactly the same as ChunkyPNG" do
39
39
  filtered_data = @reference.to_blob(:filtering => ChunkyPNG::FILTER_PAETH)
40
- ChunkyPNG::Canvas.from_blob(filtered_data).should == OilyPNG::Canvas.from_blob(filtered_data)
40
+ expect(ChunkyPNG::Canvas.from_blob(filtered_data)).to eq(OilyPNG::Canvas.from_blob(filtered_data))
41
41
  end
42
42
  end
43
43
 
44
44
  context 'decoding compatibility with ChunkyPNG' do
45
45
  resource_files.each do |file|
46
46
  it "should #{File.basename(file)} the same as ChunkyPNG" do
47
- OilyPNG::Canvas.from_file(file).pixels.should == ChunkyPNG::Canvas.from_file(file).pixels
47
+ expect(OilyPNG::Canvas.from_file(file).pixels).to eq(ChunkyPNG::Canvas.from_file(file).pixels)
48
48
  end
49
49
  end
50
50
  end
@@ -11,43 +11,43 @@ describe OilyPNG::PNGEncoding do
11
11
  it "should encode an image using 8-bit grayscale correctly" do
12
12
  @canvas.send(:encode_png_image_pass_to_stream, stream2 = ChunkyPNG::Datastream.empty_bytearray, ChunkyPNG::COLOR_GRAYSCALE, 8, ChunkyPNG::FILTER_NONE)
13
13
  @oily_canvas.send(:encode_png_image_pass_to_stream, stream1 = ChunkyPNG::Datastream.empty_bytearray, ChunkyPNG::COLOR_GRAYSCALE, 8, ChunkyPNG::FILTER_NONE)
14
- stream1.should == stream2
14
+ expect(stream1).to eq(stream2)
15
15
  end
16
16
 
17
17
  it "should encode an image using 4-bit grayscale correctly" do
18
18
  @canvas.send(:encode_png_image_pass_to_stream, stream2 = ChunkyPNG::Datastream.empty_bytearray, ChunkyPNG::COLOR_GRAYSCALE, 4, ChunkyPNG::FILTER_NONE)
19
19
  @oily_canvas.send(:encode_png_image_pass_to_stream, stream1 = ChunkyPNG::Datastream.empty_bytearray, ChunkyPNG::COLOR_GRAYSCALE, 4, ChunkyPNG::FILTER_NONE)
20
- stream1.should == stream2
20
+ expect(stream1).to eq(stream2)
21
21
  end
22
22
 
23
23
  it "should encode an image using 2-bit grayscale correctly" do
24
24
  @canvas.send(:encode_png_image_pass_to_stream, stream2 = ChunkyPNG::Datastream.empty_bytearray, ChunkyPNG::COLOR_GRAYSCALE, 2, ChunkyPNG::FILTER_NONE)
25
25
  @oily_canvas.send(:encode_png_image_pass_to_stream, stream1 = ChunkyPNG::Datastream.empty_bytearray, ChunkyPNG::COLOR_GRAYSCALE, 2, ChunkyPNG::FILTER_NONE)
26
- stream1.should == stream2
26
+ expect(stream1).to eq(stream2)
27
27
  end
28
28
 
29
29
  it "should encode an image using 1-bit grayscale correctly" do
30
30
  @canvas.send(:encode_png_image_pass_to_stream, stream2 = ChunkyPNG::Datastream.empty_bytearray, ChunkyPNG::COLOR_GRAYSCALE, 1, ChunkyPNG::FILTER_NONE)
31
31
  @oily_canvas.send(:encode_png_image_pass_to_stream, stream1 = ChunkyPNG::Datastream.empty_bytearray, ChunkyPNG::COLOR_GRAYSCALE, 1, ChunkyPNG::FILTER_NONE)
32
- stream1.should == stream2
32
+ expect(stream1).to eq(stream2)
33
33
  end
34
34
 
35
35
  it "should encode an image using 8-bit grayscale alpha correctly" do
36
36
  @oily_canvas.send(:encode_png_image_pass_to_stream, stream1 = ChunkyPNG::Datastream.empty_bytearray, ChunkyPNG::COLOR_GRAYSCALE_ALPHA, 8, ChunkyPNG::FILTER_NONE)
37
37
  @canvas.send(:encode_png_image_pass_to_stream, stream2 = ChunkyPNG::Datastream.empty_bytearray, ChunkyPNG::COLOR_GRAYSCALE_ALPHA, 8, ChunkyPNG::FILTER_NONE)
38
- stream1.should == stream2
38
+ expect(stream1).to eq(stream2)
39
39
  end
40
40
 
41
41
  it "should encode an image using 8-bit truecolor correctly" do
42
42
  @oily_canvas.send(:encode_png_image_pass_to_stream, stream1 = ChunkyPNG::Datastream.empty_bytearray, ChunkyPNG::COLOR_TRUECOLOR, 8, ChunkyPNG::FILTER_NONE)
43
43
  @canvas.send(:encode_png_image_pass_to_stream, stream2 = ChunkyPNG::Datastream.empty_bytearray, ChunkyPNG::COLOR_TRUECOLOR, 8, ChunkyPNG::FILTER_NONE)
44
- stream1.should == stream2
44
+ expect(stream1).to eq(stream2)
45
45
  end
46
46
 
47
47
  it "should encode an image using 8-bit truecolor alpha correctly" do
48
48
  @oily_canvas.send(:encode_png_image_pass_to_stream, stream1 = ChunkyPNG::Datastream.empty_bytearray, ChunkyPNG::COLOR_TRUECOLOR_ALPHA, 8, ChunkyPNG::FILTER_NONE)
49
49
  @canvas.send(:encode_png_image_pass_to_stream, stream2 = ChunkyPNG::Datastream.empty_bytearray, ChunkyPNG::COLOR_TRUECOLOR_ALPHA, 8, ChunkyPNG::FILTER_NONE)
50
- stream1.should == stream2
50
+ expect(stream1).to eq(stream2)
51
51
  end
52
52
  end
53
53
 
@@ -66,25 +66,25 @@ describe OilyPNG::PNGEncoding do
66
66
  it "should encode an image using 8-bit indexed colors correctly" do
67
67
  @canvas.send(:encode_png_image_pass_to_stream, stream2 = ChunkyPNG::Datastream.empty_bytearray, ChunkyPNG::COLOR_INDEXED, 8, ChunkyPNG::FILTER_NONE)
68
68
  @oily_canvas.send(:encode_png_image_pass_to_stream, stream1 = ChunkyPNG::Datastream.empty_bytearray, ChunkyPNG::COLOR_INDEXED, 8, ChunkyPNG::FILTER_NONE)
69
- stream1.should == stream2
69
+ expect(stream1).to eq(stream2)
70
70
  end
71
71
 
72
72
  it "should encode an image using 4-bit indexed colors correctly" do
73
73
  @canvas.send(:encode_png_image_pass_to_stream, stream2 = ChunkyPNG::Datastream.empty_bytearray, ChunkyPNG::COLOR_INDEXED, 4, ChunkyPNG::FILTER_NONE)
74
74
  @oily_canvas.send(:encode_png_image_pass_to_stream, stream1 = ChunkyPNG::Datastream.empty_bytearray, ChunkyPNG::COLOR_INDEXED, 4, ChunkyPNG::FILTER_NONE)
75
- stream1.should == stream2
75
+ expect(stream1).to eq(stream2)
76
76
  end
77
77
 
78
78
  it "should encode an image using 2-bit indexed colors correctly" do
79
79
  @canvas.send(:encode_png_image_pass_to_stream, stream2 = ChunkyPNG::Datastream.empty_bytearray, ChunkyPNG::COLOR_INDEXED, 2, ChunkyPNG::FILTER_NONE)
80
80
  @oily_canvas.send(:encode_png_image_pass_to_stream, stream1 = ChunkyPNG::Datastream.empty_bytearray, ChunkyPNG::COLOR_INDEXED, 2, ChunkyPNG::FILTER_NONE)
81
- stream1.should == stream2
81
+ expect(stream1).to eq(stream2)
82
82
  end
83
83
 
84
84
  it "should encode an image using 1-bit indexed colors correctly" do
85
85
  @canvas.send(:encode_png_image_pass_to_stream, stream2 = ChunkyPNG::Datastream.empty_bytearray, ChunkyPNG::COLOR_INDEXED, 1, ChunkyPNG::FILTER_NONE)
86
86
  @oily_canvas.send(:encode_png_image_pass_to_stream, stream1 = ChunkyPNG::Datastream.empty_bytearray, ChunkyPNG::COLOR_INDEXED, 1, ChunkyPNG::FILTER_NONE)
87
- stream1.should == stream2
87
+ expect(stream1).to eq(stream2)
88
88
  end
89
89
  end
90
90
 
@@ -97,31 +97,31 @@ describe OilyPNG::PNGEncoding do
97
97
  it "should encode correctly with no filtering" do
98
98
  @oily_canvas.send(:encode_png_image_pass_to_stream, stream1 = ChunkyPNG::Datastream.empty_bytearray, ChunkyPNG::COLOR_TRUECOLOR, 8, ChunkyPNG::FILTER_NONE)
99
99
  @canvas.send(:encode_png_image_pass_to_stream, stream2 = ChunkyPNG::Datastream.empty_bytearray, ChunkyPNG::COLOR_TRUECOLOR, 8, ChunkyPNG::FILTER_NONE)
100
- stream1.should == stream2
100
+ expect(stream1).to eq(stream2)
101
101
  end
102
102
 
103
103
  it "should encode correctly with sub filtering" do
104
104
  @oily_canvas.send(:encode_png_image_pass_to_stream, stream1 = ChunkyPNG::Datastream.empty_bytearray, ChunkyPNG::COLOR_TRUECOLOR, 8, ChunkyPNG::FILTER_SUB)
105
105
  @canvas.send(:encode_png_image_pass_to_stream, stream2 = ChunkyPNG::Datastream.empty_bytearray, ChunkyPNG::COLOR_TRUECOLOR, 8, ChunkyPNG::FILTER_SUB)
106
- stream1.should == stream2
106
+ expect(stream1).to eq(stream2)
107
107
  end
108
108
 
109
109
  it "should encode correctly with up filtering" do
110
110
  @oily_canvas.send(:encode_png_image_pass_to_stream, stream1 = ChunkyPNG::Datastream.empty_bytearray, ChunkyPNG::COLOR_TRUECOLOR, 8, ChunkyPNG::FILTER_UP)
111
111
  @canvas.send(:encode_png_image_pass_to_stream, stream2 = ChunkyPNG::Datastream.empty_bytearray, ChunkyPNG::COLOR_TRUECOLOR, 8, ChunkyPNG::FILTER_UP)
112
- stream1.should == stream2
112
+ expect(stream1).to eq(stream2)
113
113
  end
114
114
 
115
115
  it "should encode correctly with average filtering" do
116
116
  @oily_canvas.send(:encode_png_image_pass_to_stream, stream1 = ChunkyPNG::Datastream.empty_bytearray, ChunkyPNG::COLOR_TRUECOLOR, 8, ChunkyPNG::FILTER_AVERAGE)
117
117
  @canvas.send(:encode_png_image_pass_to_stream, stream2 = ChunkyPNG::Datastream.empty_bytearray, ChunkyPNG::COLOR_TRUECOLOR, 8, ChunkyPNG::FILTER_AVERAGE)
118
- stream1.should == stream2
118
+ expect(stream1).to eq(stream2)
119
119
  end
120
120
 
121
121
  it "should encode correctly with paeth filtering" do
122
122
  @oily_canvas.send(:encode_png_image_pass_to_stream, stream1 = ChunkyPNG::Datastream.empty_bytearray, ChunkyPNG::COLOR_TRUECOLOR, 8, ChunkyPNG::FILTER_PAETH)
123
123
  @canvas.send(:encode_png_image_pass_to_stream, stream2 = ChunkyPNG::Datastream.empty_bytearray, ChunkyPNG::COLOR_TRUECOLOR, 8, ChunkyPNG::FILTER_PAETH)
124
- stream1.should == stream2
124
+ expect(stream1).to eq(stream2)
125
125
  end
126
126
  end
127
127
 
@@ -129,7 +129,7 @@ describe OilyPNG::PNGEncoding do
129
129
  canvas = ChunkyPNG::Canvas.from_file(resource_file('interlaced.png'))
130
130
  data = OilyPNG::Canvas.from_canvas(canvas).to_blob(:interlace => true)
131
131
  ds = ChunkyPNG::Datastream.from_blob(data)
132
- ds.header_chunk.interlace.should == ChunkyPNG::INTERLACING_ADAM7
133
- ChunkyPNG::Canvas.from_datastream(ds).should == canvas
132
+ expect(ds.header_chunk.interlace).to eq(ChunkyPNG::INTERLACING_ADAM7)
133
+ expect(ChunkyPNG::Canvas.from_datastream(ds)).to eq(canvas)
134
134
  end
135
135
  end
@@ -8,21 +8,21 @@ describe OilyPNG::Operations do
8
8
  it "should compose two images without offset exactly the same way as ChunkyPNG" do
9
9
  subcanvas = ChunkyPNG::Canvas.new(4, 8, ChunkyPNG::Color.rgba(0, 0, 0, 75))
10
10
  subject.compose!(subcanvas)
11
- ChunkyPNG::Canvas.from_canvas(subject).should == reference_canvas('operations').compose(subcanvas)
11
+ expect(ChunkyPNG::Canvas.from_canvas(subject)).to eq(reference_canvas('operations').compose(subcanvas))
12
12
  end
13
13
 
14
14
  it "should compose two images with offset exactly the same way as ChunkyPNG" do
15
15
  subject.compose!(ChunkyPNG::Canvas.new(4, 8, ChunkyPNG::Color.rgba(0, 0, 0, 75)), 8, 4)
16
- subject.should == oily_reference_canvas('composited')
16
+ expect(subject).to eql(oily_reference_canvas('composited'))
17
17
  end
18
18
 
19
19
  it "should return itself" do
20
- subject.compose!(OilyPNG::Canvas.new(1,1)).should equal(subject)
20
+ expect(subject.compose!(OilyPNG::Canvas.new(1,1))).to be(subject)
21
21
  end
22
22
 
23
23
  it "should raise an exception when the pixels to compose fall outside the image" do
24
24
  # For now this raises a runtime error, but it should probably raise a ChunkyPNG::OutOfBounds error
25
- lambda { subject.compose!(OilyPNG::Canvas.new(1,1), 16, 16) }.should raise_error
25
+ expect { subject.compose!(OilyPNG::Canvas.new(1,1), 16, 16) }.to raise_error
26
26
  end
27
27
  end
28
28
 
@@ -32,21 +32,87 @@ describe OilyPNG::Operations do
32
32
  it "should compose two images without offset exactly the same way as ChunkyPNG" do
33
33
  subcanvas = ChunkyPNG::Canvas.new(3, 2, ChunkyPNG::Color.rgb(200, 255, 0))
34
34
  subject.replace!(subcanvas)
35
- ChunkyPNG::Canvas.from_canvas(subject).should == reference_canvas('operations').replace(subcanvas)
35
+ expect(ChunkyPNG::Canvas.from_canvas(subject)).to eq(reference_canvas('operations').replace(subcanvas))
36
36
  end
37
37
 
38
38
  it "should compose two images with offset exactly the same way as ChunkyPNG" do
39
39
  subject.replace!(ChunkyPNG::Canvas.new(3, 2, ChunkyPNG::Color.rgb(200, 255, 0)), 5, 4)
40
- subject.should == oily_reference_canvas('replaced')
40
+ expect(subject).to eq(oily_reference_canvas('replaced'))
41
41
  end
42
42
 
43
43
  it "should return itself" do
44
- subject.replace!(OilyPNG::Canvas.new(1,1)).should equal(subject)
44
+ expect(subject.replace!(OilyPNG::Canvas.new(1,1))).to be(subject)
45
45
  end
46
46
 
47
47
  it "should raise an exception when the pixels to compose fall outside the image" do
48
48
  # For now this raises a runtime error, but it should probably raise a ChunkyPNG::OutOfBounds error
49
- lambda { subject.replace!(OilyPNG::Canvas.new(1,1), 16, 16) }.should raise_error
49
+ expect { subject.replace!(OilyPNG::Canvas.new(1,1), 16, 16) }.to raise_error
50
+ end
51
+ end
52
+
53
+ describe '#rotate_left!' do
54
+ subject { OilyPNG::Canvas.new(2, 3, [1, 2, 3, 4, 5, 6]) }
55
+
56
+ it "should rotate the pixels 90 degrees clockwise" do
57
+ subject.rotate_left!
58
+ expect(subject).to eql OilyPNG::Canvas.new(3, 2, [2, 4, 6, 1, 3, 5] )
59
+ end
60
+
61
+ it "should return itself" do
62
+ expect(subject.rotate_left!).to equal(subject)
63
+ end
64
+
65
+ it "should change the image dimensions" do
66
+ expect { subject.rotate_left! }.to change { subject.dimension }.
67
+ from(ChunkyPNG::Dimension('2x3')).to(ChunkyPNG::Dimension('3x2'))
68
+ end
69
+
70
+ it "it should rotate 180 degrees when applied twice" do
71
+ subject_dup = subject.dup
72
+ expect(subject.rotate_left!.rotate_left!).to eql subject_dup.rotate_180
73
+ end
74
+
75
+ it "it should rotate right when applied three times" do
76
+ subject_dup = subject.dup
77
+ expect(subject.rotate_left!.rotate_left!.rotate_left!).to eql subject_dup.rotate_right!
78
+ end
79
+
80
+ it "should return itself when applied four times" do
81
+ subject_dup = subject.dup
82
+ expect(subject.rotate_left!.rotate_left!.rotate_left!.rotate_left!).to eql subject_dup
83
+ end
84
+ end
85
+
86
+ describe '#rotate_right!' do
87
+ subject { OilyPNG::Canvas.new(2, 3, [1, 2, 3, 4, 5, 6]) }
88
+
89
+ it "should rotate the pixels 90 degrees clockwise" do
90
+ subject.rotate_right!
91
+ expect(subject).to eql OilyPNG::Canvas.new(3, 2, [5, 3, 1, 6, 4, 2] )
92
+ end
93
+
94
+ it "should return itself" do
95
+ expect(subject.rotate_right!).to equal(subject)
96
+ end
97
+
98
+ it "should change the image dimensions" do
99
+ expect { subject.rotate_right! }.to change { subject.dimension }.
100
+ from(ChunkyPNG::Dimension('2x3')).to(ChunkyPNG::Dimension('3x2'))
101
+ end
102
+
103
+ it "it should rotate 180 degrees when applied twice" do
104
+ subject_dup = subject.dup
105
+ expect(subject.rotate_right!.rotate_right!).to eql subject_dup.rotate_180
106
+ end
107
+
108
+ it "it should rotate left when applied three times" do
109
+ subject_dup = subject.dup
110
+ expect(subject.rotate_right!.rotate_right!.rotate_right!).to eql subject_dup.rotate_left
111
+ end
112
+
113
+ it "should return itself when applied four times" do
114
+ subject_dup = subject.dup
115
+ expect(subject.rotate_right!.rotate_right!.rotate_right!.rotate_right!).to eql subject_dup
50
116
  end
51
117
  end
52
118
  end
@@ -6,14 +6,14 @@ describe OilyPNG::Resampling do
6
6
 
7
7
  describe '#steps' do
8
8
  it "should generate the steps from 4 to 8 as [0,0,1,1,2,2,3,3]" do
9
- steps(4,8).should == [0,0,1,1,2,2,3,3]
9
+ expect(steps(4, 8)).to eq([0, 0, 1, 1, 2, 2, 3, 3])
10
10
  end
11
11
 
12
12
  it "should generate the steps the same as ChunkyPNG" do
13
13
  image = ChunkyPNG::Image.new(1,1)
14
- steps(2,8).should == image.send(:steps,2,8)
15
- steps(2,11).should == image.send(:steps,2,11)
16
- steps(11,5).should == image.send(:steps,11,5)
14
+ expect(steps( 2, 8)).to eq(image.send(:steps, 2, 8))
15
+ expect(steps( 2, 11)).to eq(image.send(:steps, 2,11))
16
+ expect(steps(11, 5)).to eq(image.send(:steps,11, 5))
17
17
  end
18
18
  end
19
19
 
@@ -21,19 +21,19 @@ describe OilyPNG::Resampling do
21
21
  before(:all) { @reference = ChunkyPNG::Canvas.from_file(resource_file('nonsquare.png'))}
22
22
 
23
23
  it "should resample [0,1,2,3] to 4x4 properly" do
24
- OilyPNG::Canvas.new(2,2,[0,1,2,3]).resample_nearest_neighbor(4,4).should == OilyPNG::Canvas.new(4,4,[0,0,1,1,0,0,1,1,2,2,3,3,2,2,3,3])
24
+ expect(OilyPNG::Canvas.new(2,2,[0,1,2,3]).resample_nearest_neighbor(4,4)).to eq(OilyPNG::Canvas.new(4,4,[0,0,1,1,0,0,1,1,2,2,3,3,2,2,3,3]))
25
25
  end
26
26
 
27
27
  it "should resample [0,1,2,3] to 99x45 as ChunkyPNG does" do
28
- ChunkyPNG::Canvas.new(2,2,[0,1,2,3]).resample_nearest_neighbor(99,45).should == OilyPNG::Canvas.new(2,2,[0,1,2,3]).resample_nearest_neighbor(99,45)
28
+ expect(ChunkyPNG::Canvas.new(2,2,[0,1,2,3]).resample_nearest_neighbor(99,45)).to eq(OilyPNG::Canvas.new(2,2,[0,1,2,3]).resample_nearest_neighbor(99,45))
29
29
  end
30
30
 
31
31
  it "should resample an image to 10x20 as ChunkyPNG does" do
32
- @reference.resample_nearest_neighbor(10,20).should == OilyPNG::Canvas.from_canvas(@reference).resample_nearest_neighbor(10,20)
32
+ expect(@reference.resample_nearest_neighbor(10,20)).to eq(OilyPNG::Canvas.from_canvas(@reference).resample_nearest_neighbor(10,20))
33
33
  end
34
34
 
35
35
  it "should resample an image to 11x19 as ChunkyPNG does" do
36
- @reference.resample_nearest_neighbor(11,19).should == OilyPNG::Canvas.from_canvas(@reference).resample_nearest_neighbor(11,19)
36
+ expect(@reference.resample_nearest_neighbor(11,19)).to eq(OilyPNG::Canvas.from_canvas(@reference).resample_nearest_neighbor(11,19))
37
37
  end
38
38
  end
39
39
 
@@ -41,15 +41,15 @@ describe OilyPNG::Resampling do
41
41
  before(:all) { @reference = ChunkyPNG::Canvas.from_file(resource_file('nonsquare.png'))}
42
42
 
43
43
  it "should resample an image to 10x20 as ChunkyPNG does" do
44
- @reference.resample_bilinear(10,20).should == OilyPNG::Canvas.from_canvas(@reference).resample_bilinear(10,20)
44
+ expect(@reference.resample_bilinear(10,20)).to eq(OilyPNG::Canvas.from_canvas(@reference).resample_bilinear(10,20))
45
45
  end
46
46
 
47
47
  it "should resample an image to 11x19 as ChunkyPNG does" do
48
- @reference.resample_bilinear(11,19).should == OilyPNG::Canvas.from_canvas(@reference).resample_bilinear(11,19)
48
+ expect(@reference.resample_bilinear(11,19)).to eq(OilyPNG::Canvas.from_canvas(@reference).resample_bilinear(11,19))
49
49
  end
50
50
 
51
51
  it "should upsample an image to 88x44 as ChunkyPNG does" do
52
- @reference.resample_bilinear(88,44).should == OilyPNG::Canvas.from_canvas(@reference).resample_bilinear(88,44)
52
+ expect(@reference.resample_bilinear(88,44)).to eq(OilyPNG::Canvas.from_canvas(@reference).resample_bilinear(88,44))
53
53
  end
54
54
 
55
55
  it "should not crash upsampling tall image" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oily_png
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Willem van Bergen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-21 00:00:00.000000000 Z
11
+ date: 2015-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chunky_png
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - ~>
60
60
  - !ruby/object:Gem::Version
61
- version: '2'
61
+ version: '3'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ~>
67
67
  - !ruby/object:Gem::Version
68
- version: '2'
68
+ version: '3'
69
69
  description: |2
70
70
  This Ruby C extenstion defines a module that can be included into ChunkyPNG to improve its speed.
71
71
  email: