gd2 1.1 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYRIGHT +1 -1
- data/README +1 -1
- data/lib/gd2.rb +33 -5
- data/lib/gd2/image.rb +5 -5
- metadata +2 -3
- data/test/dl.rb +0 -11
data/COPYRIGHT
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
|
2
2
|
Ruby/GD2 - Ruby binding for gd 2.x graphics library
|
3
|
-
Copyright (C) 2005 Robert Leslie
|
3
|
+
Copyright (C) 2005-2006 Robert Leslie
|
4
4
|
|
5
5
|
This program is free software; you can redistribute it and/or modify
|
6
6
|
it under the terms of the GNU General Public License as published by
|
data/README
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
|
2
2
|
Ruby/GD2 - Ruby binding for Thomas Boutell's gd 2.x graphics library
|
3
|
-
Copyright (C) 2005 Robert Leslie <rob@mars.org>
|
3
|
+
Copyright (C) 2005-2006 Robert Leslie <rob@mars.org>
|
4
4
|
|
5
5
|
I wrote this Ruby library because I wasn't satisfied with the existing
|
6
6
|
Ruby/GD extension library. Among other things, it had no support for
|
data/lib/gd2.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#
|
2
2
|
# Ruby/GD2 -- Ruby binding for gd 2 graphics library
|
3
3
|
#
|
4
|
-
# Copyright © 2005 Robert Leslie
|
4
|
+
# Copyright © 2005-2006 Robert Leslie
|
5
5
|
#
|
6
6
|
# This file is part of Ruby/GD2.
|
7
7
|
#
|
@@ -24,10 +24,38 @@ require 'dl'
|
|
24
24
|
require 'rbconfig'
|
25
25
|
|
26
26
|
module GD2
|
27
|
-
VERSION = '1.1'.freeze
|
27
|
+
VERSION = '1.1.1'.freeze
|
28
|
+
|
29
|
+
def self.gd_library_name
|
30
|
+
case Config::CONFIG['arch']
|
31
|
+
when /darwin/
|
32
|
+
'libgd.2.dylib'
|
33
|
+
when /mswin32/, /cygwin/
|
34
|
+
'bgd.dll'
|
35
|
+
else
|
36
|
+
'libgd.so.2'
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.name_for_symbol(symbol, signature)
|
41
|
+
case Config::CONFIG['arch']
|
42
|
+
when /mswin32/, /cygwin/
|
43
|
+
sum = -4
|
44
|
+
signature.each_byte do |char|
|
45
|
+
sum += case char
|
46
|
+
when ?D: 8
|
47
|
+
else 4
|
48
|
+
end
|
49
|
+
end
|
50
|
+
"#{symbol}@#{sum}"
|
51
|
+
else
|
52
|
+
symbol.to_s
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
private_class_method :gd_library_name, :name_for_symbol
|
28
57
|
|
29
|
-
LIB = DL.dlopen(
|
30
|
-
'libgd.2.dylib' : 'libgd.so.2')
|
58
|
+
LIB = DL.dlopen(gd_library_name)
|
31
59
|
SYM = {
|
32
60
|
:gdImageCreate => 'PII',
|
33
61
|
:gdImageCreateTrueColor => 'PII',
|
@@ -119,7 +147,7 @@ module GD2
|
|
119
147
|
:gdFontCacheShutdown => '0',
|
120
148
|
:gdFTUseFontConfig => 'II',
|
121
149
|
:gdFree => '0P'
|
122
|
-
}.inject({}) { |x, (k, v)| x[k] = LIB[k
|
150
|
+
}.inject({}) { |x, (k, v)| x[k] = LIB[name_for_symbol(k, v), v]; x }
|
123
151
|
|
124
152
|
# Bit flags for Image#compare
|
125
153
|
|
data/lib/gd2/image.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#
|
2
2
|
# Ruby/GD2 -- Ruby binding for gd 2 graphics library
|
3
3
|
#
|
4
|
-
# Copyright © 2005 Robert Leslie
|
4
|
+
# Copyright © 2005-2006 Robert Leslie
|
5
5
|
#
|
6
6
|
# This file is part of Ruby/GD2.
|
7
7
|
#
|
@@ -172,7 +172,7 @@ module GD2
|
|
172
172
|
options.empty?
|
173
173
|
raise ArgumentError, 'Missing required option :width' if width.nil?
|
174
174
|
raise ArgumentError, 'Missing required option :height' if height.nil?
|
175
|
-
ptr = File.open(filename) do |file|
|
175
|
+
ptr = File.open(filename, 'rb') do |file|
|
176
176
|
SYM[:gdImageCreateFromGd2Part].call(file, x, y, width, height)[0]
|
177
177
|
end
|
178
178
|
else
|
@@ -190,7 +190,7 @@ module GD2
|
|
190
190
|
}[format]
|
191
191
|
raise UnrecognizedImageTypeError,
|
192
192
|
'Format (or file extension) is not recognized' unless create_sym
|
193
|
-
ptr = File.open(filename) { |file| SYM[create_sym].call(file)[0] }
|
193
|
+
ptr = File.open(filename, 'rb') { |file| SYM[create_sym].call(file)[0] }
|
194
194
|
end
|
195
195
|
raise LibraryError unless ptr
|
196
196
|
|
@@ -302,7 +302,7 @@ module GD2
|
|
302
302
|
|
303
303
|
# Return the pixel value at image location (+x+, +y+).
|
304
304
|
def get_pixel(x, y)
|
305
|
-
SYM[:gdImageGetPixel].call(@image_ptr, x, y)
|
305
|
+
SYM[:gdImageGetPixel].call(@image_ptr, x, y).at(0)
|
306
306
|
end
|
307
307
|
alias pixel get_pixel
|
308
308
|
|
@@ -480,7 +480,7 @@ module GD2
|
|
480
480
|
raise ArgumentError, "Unrecognized options #{options.inspect}" unless
|
481
481
|
options.empty?
|
482
482
|
|
483
|
-
File.open(filename, '
|
483
|
+
File.open(filename, 'wb') do |file|
|
484
484
|
args[args[0].nil? ? 0 : 1] = file
|
485
485
|
SYM[write_sym].call(image_ptr, *args)
|
486
486
|
file.pos
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
|
|
3
3
|
specification_version: 1
|
4
4
|
name: gd2
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version:
|
7
|
-
date: 2006-
|
6
|
+
version: 1.1.1
|
7
|
+
date: 2006-05-12 00:00:00 -07:00
|
8
8
|
summary: Ruby interface to gd 2 library.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -40,7 +40,6 @@ files:
|
|
40
40
|
- lib/gd2/image.rb
|
41
41
|
- lib/gd2/palette.rb
|
42
42
|
test_files:
|
43
|
-
- test/dl.rb
|
44
43
|
- test/image.rb
|
45
44
|
rdoc_options:
|
46
45
|
- "--title"
|