prawn-fast-png 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,20 +15,18 @@ This gem doesn't introduce any API changes, so please refer to
15
15
  pdf.render_file 'example.pdf'
16
16
 
17
17
  = Running Prawn's tests
18
- To run tests you need to execute first...
19
18
 
20
- git submodule init
21
- git submodule update
19
+ cd path_to_prawn_src
20
+ git tag # available versions
21
+ git checkout version.tag
22
+ # or
23
+ git checkout master
24
+ cd -
25
+ rake test PRAWN_DIR=path_to_prawn_src
22
26
 
23
- cd vendor/prawn
24
- git submodule init
25
- git submodule update
27
+ for versions 0.5.1-0.8.3 add PRAWN_REQUIRE=prawn/core option
26
28
 
27
- cd ../..
28
-
29
- ...then...
30
-
31
- rake test
29
+ rake test PRAWN_DIR=path_to_prawn_src PRAWN_REQUIRE=prawn/core
32
30
 
33
31
  = GitHub
34
32
  http://github.com/amberbit/prawn-fast-png
@@ -39,3 +37,4 @@ http://groups.google.com/group/prawn-ruby
39
37
  =Credits
40
38
  prawn-fast-png is maintained by {Wojciech Piekutowski}[http://piekutowski.net],
41
39
  and is funded by AmberBit[http://amberbit.com].
40
+
@@ -1,3 +1,10 @@
1
1
  # Monkey-patches RGB and A separation code in Prawn::Images::PNG class.
2
2
 
3
- require File.join(File.dirname(__FILE__), 'images', 'png_patch')
3
+ require 'prawn/images/png_patch'
4
+
5
+ module Prawn
6
+ module FastPng
7
+ VERSION = '0.2.1'
8
+ end
9
+ end
10
+
@@ -1,7 +1,10 @@
1
1
  # Extracts the data from a PNG that is needed for embedding. Uses RMagick to
2
2
  # separate RGB and A channels.
3
3
 
4
- require 'prawn'
4
+ unless Object.const_defined?(:Prawn)
5
+ raise %q{Prawn not loaded yet. Make sure you "require 'prawn'" or "require 'prawn/core'" before "require 'prawn/fast_png'"}
6
+ end
7
+
5
8
  require 'RMagick'
6
9
 
7
10
  module Prawn
@@ -31,8 +34,19 @@ module Prawn
31
34
  when 16
32
35
  # export_pixels_to_str returns little-endian data, but we need big-endian
33
36
  # so it's usually more efficient to use export_pixels and pack
34
- img_data = img.export_pixels(0, 0, width, height, format).pack('n*')
35
- alpha_channel = img.export_pixels(0, 0, width, height, 'A').pack('n*')
37
+ img_data = img.export_pixels(0, 0, width, height, format).pack('n*')
38
+ alpha_data = img.export_pixels(0, 0, width, height, 'A')
39
+ alpha_bits = respond_to?(:alpha_channel_bits) ? alpha_channel_bits : 16
40
+ alpha_channel =
41
+ case alpha_bits
42
+ when 8
43
+ # downsample 16-bit alpha channel to 8 bits for Adobe Reader support
44
+ alpha_data.map { |byte| byte >> 8 }.pack('c*')
45
+ when 16
46
+ alpha_data.pack('n*')
47
+ else
48
+ raise Errors::UnsupportedImageType, "Can't create #{alpha_channel_bits}-bit alpha channel"
49
+ end
36
50
  else
37
51
  raise Errors::UnsupportedImageType, "Can't handle #{bits}-bit PNG images"
38
52
  end
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prawn-fast-png
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 2
8
+ - 2
9
+ version: 0.2.2
5
10
  platform: ruby
6
11
  authors:
7
12
  - Wojciech Piekutowski
@@ -9,29 +14,33 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2009-08-19 00:00:00 +02:00
17
+ date: 2010-04-26 00:00:00 +02:00
13
18
  default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: prawn
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
20
24
  requirements:
21
25
  - - ">="
22
26
  - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
23
29
  version: "0"
24
- version:
30
+ type: :runtime
31
+ version_requirements: *id001
25
32
  - !ruby/object:Gem::Dependency
26
33
  name: rmagick
27
- type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
34
+ prerelease: false
35
+ requirement: &id002 !ruby/object:Gem::Requirement
30
36
  requirements:
31
37
  - - ">="
32
38
  - !ruby/object:Gem::Version
39
+ segments:
40
+ - 0
33
41
  version: "0"
34
- version:
42
+ type: :runtime
43
+ version_requirements: *id002
35
44
  description: " An extension of Prawn that improves the performance when embedding PNG\n images containing an alpha channel\n"
36
45
  email: wojciech@piekutowski.net
37
46
  executables: []
@@ -65,18 +74,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
65
74
  requirements:
66
75
  - - ">="
67
76
  - !ruby/object:Gem::Version
77
+ segments:
78
+ - 0
68
79
  version: "0"
69
- version:
70
80
  required_rubygems_version: !ruby/object:Gem::Requirement
71
81
  requirements:
72
82
  - - ">="
73
83
  - !ruby/object:Gem::Version
84
+ segments:
85
+ - 0
74
86
  version: "0"
75
- version:
76
87
  requirements: []
77
88
 
78
89
  rubyforge_project: prawn-fast-png
79
- rubygems_version: 1.3.4
90
+ rubygems_version: 1.3.6
80
91
  signing_key:
81
92
  specification_version: 3
82
93
  summary: An extension of Prawn that improves the performance when embedding PNG images containing an alpha channel