gd2-ffij 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/gd2-ffij.gemspec CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
20
20
  s.homepage = "http://github.com/dark-panda/gd2-ffij"
21
21
  s.require_paths = ["lib"]
22
22
 
23
- s.add_dependency("ffi", ["~> 1.0.0"])
23
+ s.add_dependency("ffi", [">= 1.0.0"])
24
24
  s.add_dependency("rdoc")
25
25
  s.add_dependency("rake", ["~> 0.9"])
26
26
  end
data/lib/gd2-ffij.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # encoding: ASCII-8BIT
1
2
  #
2
3
  # Ruby/GD2 -- Ruby binding for gd 2 graphics library
3
4
  #
data/lib/gd2/canvas.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # encoding: ASCII-8BIT
1
2
  #
2
3
  # Ruby/GD2 -- Ruby binding for gd 2 graphics library
3
4
  #
data/lib/gd2/color.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # encoding: ASCII-8BIT
1
2
  #
2
3
  # Ruby/GD2 -- Ruby binding for gd 2 graphics library
3
4
  #
@@ -1,3 +1,4 @@
1
+ # encoding: ASCII-8BIT
1
2
  #
2
3
  # Ruby/GD2 -- Ruby binding for gd 2 graphics library
3
4
  #
data/lib/gd2/font.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # encoding: ASCII-8BIT
1
2
  #
2
3
  # Ruby/GD2 -- Ruby binding for gd 2 graphics library
3
4
  #
data/lib/gd2/image.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # encoding: ASCII-8BIT
1
2
  #
2
3
  # Ruby/GD2 -- Ruby binding for gd 2 graphics library
3
4
  #
@@ -88,17 +89,17 @@ module GD2
88
89
  # automatically (JPEG, PNG, GIF, WBMP, or GD2). The resulting image will be
89
90
  # either of class Image::TrueColor or Image::IndexedColor.
90
91
  def self.load(src)
91
- src = src.force_encoding("BINARY") if src.respond_to? :force_encoding
92
+ src = src.force_encoding("ASCII-8BIT") if src.respond_to? :force_encoding
92
93
  case src
93
94
  when File
94
95
  pos = src.pos
95
96
  magic = src.read(4)
96
97
  src.pos = pos
97
98
  data = src.read
98
- data = data.force_encoding("BINARY") if data.respond_to? :force_encoding
99
+ data = data.force_encoding("ASCII-8BIT") if data.respond_to? :force_encoding
99
100
  args = [ data.length, data ]
100
101
  when String
101
- magic = src
102
+ magic = src.slice(0, 4)
102
103
  args = [ src.length, src ]
103
104
  else
104
105
  raise TypeError, 'Unexpected argument type'
@@ -125,24 +126,17 @@ module GD2
125
126
  block_given? ? yield(image) : image
126
127
  end
127
128
 
128
- def self.data_type(str)
129
- ct = 0
130
- mgc = ""
131
- str.each_byte do |byte|
132
- break if ct == 4
133
- mgc << byte.to_s
134
- ct += 1
135
- end
136
- case mgc
137
- when "255216255224"
129
+ def self.data_type(magic)
130
+ case magic
131
+ when /^\xff\xd8/
138
132
  :jpeg
139
- when "137807871"
133
+ when /^\x89PNG/
140
134
  :png
141
- when "71737056"
135
+ when /^GIF8/
142
136
  :gif
143
- when "001300"
137
+ when /^\x00/
144
138
  :wbmp
145
- when "103100500"
139
+ when /^gd2/
146
140
  :gd2
147
141
  end
148
142
  end
@@ -200,7 +194,7 @@ module GD2
200
194
  'Format (or file extension) is not recognized' unless create_sym
201
195
 
202
196
  file = File.read(filename)
203
- file = file.force_encoding("BINARY") if file.respond_to? :force_encoding
197
+ file = file.force_encoding("ASCII-8BIT") if file.respond_to? :force_encoding
204
198
  file_ptr = FFI::MemoryPointer.new(file.size, 1, false)
205
199
  file_ptr.put_bytes(0, file)
206
200
 
@@ -408,9 +402,7 @@ module GD2
408
402
  def with_clipping(x1, y1, x2, y2) #:yields: image
409
403
  clip = clipping
410
404
  begin
411
- p clipping
412
405
  ::GD2::GD2FFI.send(:gdImageSetClip, image_ptr, x1.to_i, y1.to_i, x2.to_i, y2.to_i)
413
- p clipping
414
406
  yield self
415
407
  self
416
408
  ensure
data/lib/gd2/palette.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # encoding: ASCII-8BIT
1
2
  #
2
3
  # Ruby/GD2 -- Ruby binding for gd 2 graphics library
3
4
  #
data/lib/gd2/version.rb CHANGED
@@ -1,5 +1,6 @@
1
+ # encoding: ASCII-8BIT
1
2
 
2
3
  module GD2
3
- VERSION = "0.0.5"
4
+ VERSION = "0.0.6"
4
5
  end
5
6
 
data/test/canvas_tests.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # encoding: ASCII-8BIT
1
2
 
2
3
  require './test/test_helper'
3
4
 
data/test/image_tests.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # encoding: ASCII-8BIT
1
2
 
2
3
  require './test/test_helper'
3
4
 
data/test/test_helper.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # encoding: ASCII-8BIT
1
2
 
2
3
  require 'test/unit'
3
4
  require 'tmpdir'
metadata CHANGED
@@ -1,7 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gd2-ffij
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: !binary |-
5
+ MC4wLjY=
5
6
  prerelease:
6
7
  platform: ruby
7
8
  authors:
@@ -9,14 +10,14 @@ authors:
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2012-07-18 00:00:00.000000000 Z
13
+ date: 2012-08-14 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: ffi
16
17
  requirement: !ruby/object:Gem::Requirement
17
18
  none: false
18
19
  requirements:
19
- - - ~>
20
+ - - ! '>='
20
21
  - !ruby/object:Gem::Version
21
22
  version: 1.0.0
22
23
  type: :runtime
@@ -24,7 +25,7 @@ dependencies:
24
25
  version_requirements: !ruby/object:Gem::Requirement
25
26
  none: false
26
27
  requirements:
27
- - - ~>
28
+ - - ! '>='
28
29
  - !ruby/object:Gem::Version
29
30
  version: 1.0.0
30
31
  - !ruby/object:Gem::Dependency