prawn-fast-png 0.1.2 → 0.2.1
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.
- data/lib/prawn/images/png_patch.rb +15 -3
- metadata +7 -5
@@ -12,19 +12,30 @@ module Prawn
|
|
12
12
|
def initialize(data) #:nodoc:
|
13
13
|
@prawn_fast_png_data = data
|
14
14
|
prawn_fast_png_old_initialize(data)
|
15
|
-
@prawn_fast_png_data = nil
|
16
15
|
end
|
17
16
|
|
18
17
|
private
|
19
18
|
|
20
19
|
def unfilter_image_data
|
21
20
|
img = Magick::Image.from_blob(@prawn_fast_png_data).first
|
21
|
+
# image blob not needed anymore, let GC take care of it
|
22
|
+
@prawn_fast_png_data = nil
|
22
23
|
|
23
24
|
# get only one color value per pixel (Intensity) for grayscale+alpha images
|
24
25
|
format = color_type == 4 ? 'I' : 'RGB'
|
25
26
|
|
26
|
-
|
27
|
-
|
27
|
+
case bits
|
28
|
+
when 8
|
29
|
+
img_data = img.export_pixels_to_str(0, 0, width, height, format)
|
30
|
+
alpha_channel = img.export_pixels_to_str(0, 0, width, height, 'A')
|
31
|
+
when 16
|
32
|
+
# export_pixels_to_str returns little-endian data, but we need big-endian
|
33
|
+
# 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*')
|
36
|
+
else
|
37
|
+
raise Errors::UnsupportedImageType, "Can't handle #{bits}-bit PNG images"
|
38
|
+
end
|
28
39
|
|
29
40
|
@img_data = Zlib::Deflate.deflate(img_data)
|
30
41
|
@alpha_channel = Zlib::Deflate.deflate(alpha_channel)
|
@@ -32,3 +43,4 @@ module Prawn
|
|
32
43
|
end
|
33
44
|
end
|
34
45
|
end
|
46
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prawn-fast-png
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wojciech Piekutowski
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-08-19 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: "0"
|
34
34
|
version:
|
35
|
-
description: An extension of Prawn that improves the performance when embedding PNG
|
35
|
+
description: " An extension of Prawn that improves the performance when embedding PNG\n images containing an alpha channel\n"
|
36
36
|
email: wojciech@piekutowski.net
|
37
37
|
executables: []
|
38
38
|
|
@@ -50,6 +50,8 @@ files:
|
|
50
50
|
- COPYING
|
51
51
|
has_rdoc: true
|
52
52
|
homepage: http://github.com/amberbit/prawn-fast-png
|
53
|
+
licenses: []
|
54
|
+
|
53
55
|
post_install_message:
|
54
56
|
rdoc_options:
|
55
57
|
- --title
|
@@ -74,9 +76,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
74
76
|
requirements: []
|
75
77
|
|
76
78
|
rubyforge_project: prawn-fast-png
|
77
|
-
rubygems_version: 1.3.
|
79
|
+
rubygems_version: 1.3.4
|
78
80
|
signing_key:
|
79
|
-
specification_version:
|
81
|
+
specification_version: 3
|
80
82
|
summary: An extension of Prawn that improves the performance when embedding PNG images containing an alpha channel
|
81
83
|
test_files: []
|
82
84
|
|