chunky_png 0.0.5 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. data/README.rdoc +20 -10
  2. data/chunky_png.gemspec +18 -6
  3. data/lib/chunky_png.rb +11 -28
  4. data/lib/chunky_png/canvas.rb +186 -0
  5. data/lib/chunky_png/canvas/adam7_interlacing.rb +53 -0
  6. data/lib/chunky_png/canvas/drawing.rb +8 -0
  7. data/lib/chunky_png/{pixel_matrix → canvas}/operations.rb +12 -12
  8. data/lib/chunky_png/canvas/png_decoding.rb +145 -0
  9. data/lib/chunky_png/canvas/png_encoding.rb +182 -0
  10. data/lib/chunky_png/chunk.rb +101 -23
  11. data/lib/chunky_png/color.rb +307 -0
  12. data/lib/chunky_png/datastream.rb +143 -45
  13. data/lib/chunky_png/image.rb +31 -30
  14. data/lib/chunky_png/palette.rb +49 -47
  15. data/lib/chunky_png/rmagick.rb +43 -0
  16. data/spec/chunky_png/canvas/adam7_interlacing_spec.rb +108 -0
  17. data/spec/chunky_png/canvas/png_decoding_spec.rb +81 -0
  18. data/spec/chunky_png/canvas/png_encoding_spec.rb +70 -0
  19. data/spec/chunky_png/canvas_spec.rb +71 -0
  20. data/spec/chunky_png/color_spec.rb +104 -0
  21. data/spec/chunky_png/datastream_spec.rb +32 -0
  22. data/spec/chunky_png/image_spec.rb +25 -0
  23. data/spec/chunky_png/rmagick_spec.rb +21 -0
  24. data/spec/{integration/image_spec.rb → chunky_png_spec.rb} +14 -8
  25. data/spec/resources/composited.png +0 -0
  26. data/spec/resources/cropped.png +0 -0
  27. data/spec/resources/damaged_chunk.png +0 -0
  28. data/spec/resources/damaged_signature.png +13 -0
  29. data/spec/resources/pixelstream.rgba +67 -0
  30. data/spec/resources/replaced.png +0 -0
  31. data/spec/resources/text_chunk.png +0 -0
  32. data/spec/resources/ztxt_chunk.png +0 -0
  33. data/spec/spec_helper.rb +8 -5
  34. data/tasks/github-gem.rake +1 -1
  35. metadata +37 -18
  36. data/lib/chunky_png/pixel.rb +0 -272
  37. data/lib/chunky_png/pixel_matrix.rb +0 -136
  38. data/lib/chunky_png/pixel_matrix/decoding.rb +0 -159
  39. data/lib/chunky_png/pixel_matrix/encoding.rb +0 -89
  40. data/spec/unit/decoding_spec.rb +0 -83
  41. data/spec/unit/encoding_spec.rb +0 -27
  42. data/spec/unit/pixel_matrix_spec.rb +0 -93
  43. data/spec/unit/pixel_spec.rb +0 -47
@@ -1,47 +0,0 @@
1
- require File.expand_path('../spec_helper.rb', File.dirname(__FILE__))
2
-
3
- describe ChunkyPNG::Pixel do
4
-
5
- before(:each) do
6
- @white = ChunkyPNG::Pixel.rgba(255, 255, 255, 255)
7
- @black = ChunkyPNG::Pixel.rgba( 0, 0, 0, 255)
8
- @opaque = ChunkyPNG::Pixel.rgba( 10, 100, 150, 255)
9
- @non_opaque = ChunkyPNG::Pixel.rgba( 10, 100, 150, 100)
10
- @fully_transparent = ChunkyPNG::Pixel.rgba( 10, 100, 150, 0)
11
- end
12
-
13
- it "should represent pixels as the correct number" do
14
- @white.value.should == 0xffffffff
15
- @black.value.should == 0x000000ff
16
- @opaque.value.should == 0x0a6496ff
17
- end
18
-
19
- it "should correctly check for opaqueness" do
20
- @white.should be_opaque
21
- @black.should be_opaque
22
- @opaque.should be_opaque
23
- @non_opaque.should_not be_opaque
24
- @fully_transparent.should_not be_opaque
25
- end
26
-
27
- it "should convert the individual color values back correctly" do
28
- @opaque.to_truecolor_bytes.should == [10, 100, 150]
29
- @non_opaque.to_truecolor_alpha_bytes.should == [10, 100, 150, 100]
30
- end
31
-
32
- describe '#compose' do
33
- it "should use the foregorund pixel as is when an opaque pixel is given" do
34
- (@white & @opaque).should == @opaque
35
- end
36
-
37
- it "should use the background pixel as is when a fully_transparent pixel is given" do
38
- (@white & @fully_transparent).should == @white
39
- end
40
-
41
- it "should compose pixels correctly" do
42
- (@white.compose_quick(@non_opaque)).should == ChunkyPNG::Pixel.new(0x9fc2d6ff)
43
- (@white.compose_precise(@non_opaque)).should == ChunkyPNG::Pixel.new(0x9fc2d6ff)
44
- end
45
- end
46
- end
47
-