painter 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/painter.rb +3 -0
- data/lib/painter/cgd2.rb +6 -0
- data/spec/fixtures/image_with_alpha.png +0 -0
- data/spec/integration.rb +11 -0
- data/spec/output/alpha.gif +0 -0
- data/spec/output/alpha.png +0 -0
- data/spec/output/captcha.png +0 -0
- data/spec/output/format.gif +0 -0
- data/spec/output/format.png +0 -0
- data/spec/output/resized.png +0 -0
- metadata +6 -3
data/lib/painter.rb
CHANGED
@@ -104,6 +104,9 @@ class Painter
|
|
104
104
|
end
|
105
105
|
|
106
106
|
def resize_to(destination)
|
107
|
+
transparency_index = CGD2::gdImageColorAllocateAlpha(destination.image_pointer, 255, 255, 255, Painter::ALPHA_TRANSPARENT)
|
108
|
+
CGD2::gdImageColorTransparent(destination.image_pointer, transparency_index)
|
109
|
+
CGD2::gdImageFill(destination.image_pointer, 0, 0, transparency_index)
|
107
110
|
CGD2::gdImageCopyResampled(destination.image_pointer, self.image_pointer,
|
108
111
|
0, 0, 0, 0,
|
109
112
|
destination.info.x, destination.info.y, self.info.x, self.info.y)
|
data/lib/painter/cgd2.rb
CHANGED
@@ -39,5 +39,11 @@ class Painter
|
|
39
39
|
# gdImageDestroy(gdImagePtr im) (FUNCTION)
|
40
40
|
attach_function :gdImageDestroy, [:pointer], :void
|
41
41
|
attach_function :gdFree, [:pointer], :void
|
42
|
+
attach_function :gdImageColorTransparent, [:pointer, :int], :void
|
43
|
+
|
44
|
+
attach_function :gdImageColorAllocate, [:pointer, :int, :int, :int], :int
|
45
|
+
attach_function :gdImageColorAllocateAlpha, [:pointer, :int, :int, :int, :int], :int
|
46
|
+
attach_function :gdImageColorExact, [:pointer, :int, :int, :int], :int
|
47
|
+
attach_function :gdImageFill, [:pointer, :int, :int, :int], :void
|
42
48
|
end
|
43
49
|
end
|
Binary file
|
data/spec/integration.rb
CHANGED
@@ -52,4 +52,15 @@ describe 'integration' do
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
+
it "should handle alpha channels" do
|
56
|
+
Painter.open("#{File.dirname(__FILE__)}/fixtures/image_with_alpha.png", :png) do |source|
|
57
|
+
Painter.write("#{File.dirname(__FILE__)}/output/alpha.gif", 128, 128, :gif) do |output|
|
58
|
+
source.resize_to(output)
|
59
|
+
end
|
60
|
+
Painter.write("#{File.dirname(__FILE__)}/output/alpha.png", 128, 128, :png) do |output|
|
61
|
+
source.resize_to(output)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
55
66
|
end
|
Binary file
|
Binary file
|
data/spec/output/captcha.png
CHANGED
Binary file
|
data/spec/output/format.gif
CHANGED
Binary file
|
data/spec/output/format.png
CHANGED
Binary file
|
data/spec/output/resized.png
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: painter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 4
|
10
|
+
version: 0.1.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ben Sandofsky
|
@@ -54,10 +54,13 @@ files:
|
|
54
54
|
- lib/painter/text.rb
|
55
55
|
- lib/painter.rb
|
56
56
|
- spec/color_spec.rb
|
57
|
+
- spec/fixtures/image_with_alpha.png
|
57
58
|
- spec/fixtures/sample.jpg
|
58
59
|
- spec/fixtures/Vera.ttf
|
59
60
|
- spec/image_spec.rb
|
60
61
|
- spec/integration.rb
|
62
|
+
- spec/output/alpha.gif
|
63
|
+
- spec/output/alpha.png
|
61
64
|
- spec/output/captcha.png
|
62
65
|
- spec/output/format.gif
|
63
66
|
- spec/output/format.jpg
|