gd2-ffij 0.2.0 → 0.3.0
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.
- checksums.yaml +4 -4
- data/.travis.yml +20 -0
- data/COPYRIGHT +1 -1
- data/Gemfile +1 -1
- data/Guardfile +1 -1
- data/Rakefile +3 -0
- data/lib/gd2-ffij.rb +1 -1
- data/lib/gd2/canvas.rb +1 -1
- data/lib/gd2/color.rb +1 -1
- data/lib/gd2/ffi_struct.rb +1 -1
- data/lib/gd2/font.rb +1 -1
- data/lib/gd2/image.rb +13 -3
- data/lib/gd2/palette.rb +1 -1
- data/lib/gd2/version.rb +2 -2
- data/test/canvas_tests.rb +2 -2
- data/test/image_tests.rb +29 -3
- data/test/images/test_color_indexed.gd2 +0 -0
- data/test/images/test_color_sharpened.gd2 +0 -0
- data/test/images/test_filled_wedge.gd2 +0 -0
- data/test/images/test_text.gd2 +0 -0
- data/test/images/test_text_circle.gd2 +0 -0
- data/test/test_helper.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6aa4ff4f4aa7e5c580dd3c9d464c8c1df57a98a5
|
4
|
+
data.tar.gz: 211bf9eef3b61bffe85ec4a2e5a2a97affe26bad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7ed5a027a534a36f2b144392aa8e1f1f56e2a3c2e230d31f4d31409353ab8d7a6d7a9846d12d024ccc9d9b892219e8a4e27a48d2a4b7cc641cdfcc3e7efde88
|
7
|
+
data.tar.gz: 3b5973311c1080fe04273a0dd4923589f9192b1265fe3e5b2fe607acb648af87001fd7fc54cd72a35a02664a26c23c5db60595182d404f1aabbc9e254092a411
|
data/.travis.yml
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
dist: precise
|
2
|
+
cache: bundler
|
3
|
+
sudo: false
|
4
|
+
language: ruby
|
5
|
+
rvm:
|
6
|
+
- 2.4.2
|
7
|
+
- 2.3.5
|
8
|
+
- 2.2.8
|
9
|
+
- rbx-3
|
10
|
+
- jruby-head
|
11
|
+
matrix:
|
12
|
+
allow_failures:
|
13
|
+
- rvm: rbx-3
|
14
|
+
- rvm: jruby-head
|
15
|
+
addons:
|
16
|
+
apt:
|
17
|
+
packages:
|
18
|
+
- libgd2-noxpm
|
19
|
+
before_install:
|
20
|
+
- wget -q -O - https://www.mongodb.org/static/pgp/server-3.2.pub | sudo apt-key add -
|
data/COPYRIGHT
CHANGED
@@ -16,7 +16,7 @@ See https://github.com/dark-panda/gd2-ffij/issues/10 ("Consider moving back to
|
|
16
16
|
BSD now that FFI is back to BSD?") for details.
|
17
17
|
|
18
18
|
|
19
|
-
Subsequent code added and modified to create gd2-ffij copyright (C) 2010-
|
19
|
+
Subsequent code added and modified to create gd2-ffij copyright (C) 2010-2017
|
20
20
|
J Smith <dark.panda@gmail.com> and published under the MIT license as follows:
|
21
21
|
|
22
22
|
Permission is hereby granted, free of charge, to any person
|
data/Gemfile
CHANGED
data/Guardfile
CHANGED
data/Rakefile
CHANGED
@@ -12,11 +12,14 @@ version = GD2::VERSION
|
|
12
12
|
|
13
13
|
desc 'Test GD2 interface'
|
14
14
|
Rake::TestTask.new(:test) do |t|
|
15
|
+
t.libs << "#{File.dirname(__FILE__)}/test"
|
15
16
|
t.test_files = FileList['test/**/*_tests.rb']
|
16
17
|
t.verbose = !!ENV['VERBOSE_TESTS']
|
17
18
|
t.warning = !!ENV['WARNINGS']
|
18
19
|
end
|
19
20
|
|
21
|
+
task :default => :test
|
22
|
+
|
20
23
|
desc 'Build docs'
|
21
24
|
Rake::RDocTask.new do |t|
|
22
25
|
t.title = "gd2-ffij #{version}"
|
data/lib/gd2-ffij.rb
CHANGED
data/lib/gd2/canvas.rb
CHANGED
data/lib/gd2/color.rb
CHANGED
data/lib/gd2/ffi_struct.rb
CHANGED
data/lib/gd2/font.rb
CHANGED
data/lib/gd2/image.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# encoding: ASCII-8BIT
|
1
|
+
# frozen_string_literal: true; encoding: ASCII-8BIT
|
2
2
|
#
|
3
3
|
# See COPYRIGHT for license details.
|
4
4
|
|
@@ -44,6 +44,7 @@ module GD2
|
|
44
44
|
#
|
45
45
|
class Image
|
46
46
|
class UnrecognizedImageTypeError < StandardError; end
|
47
|
+
class MemoryAllocationError < StandardError; end
|
47
48
|
|
48
49
|
attr_reader :image_ptr #:nodoc:
|
49
50
|
|
@@ -138,7 +139,7 @@ module GD2
|
|
138
139
|
# part of the image. Use options :x, :y, :width, and :height to specify the
|
139
140
|
# part of the image to import.
|
140
141
|
def self.import(filename, options = {})
|
141
|
-
raise Errno::ENOENT.new(filename) unless File.
|
142
|
+
raise Errno::ENOENT.new(filename) unless File.exist?(filename)
|
142
143
|
|
143
144
|
unless format = options.delete(:format)
|
144
145
|
md = filename.match(/\.([^.]+)\z/)
|
@@ -203,7 +204,16 @@ module GD2
|
|
203
204
|
private_class_method :image_true_color?
|
204
205
|
|
205
206
|
def self.create_image_ptr(sx, sy, alpha_blending = true) #:nodoc:
|
206
|
-
|
207
|
+
x = sx.to_i
|
208
|
+
y = sy.to_i
|
209
|
+
|
210
|
+
raise ArgumentError, "sx must be > 0" unless x.positive?
|
211
|
+
raise ArgumentError, "sy must be > 0" unless y.positive?
|
212
|
+
|
213
|
+
ptr = FFIStruct::ImagePtr.new(::GD2::GD2FFI.send(create_image_sym, x, y))
|
214
|
+
|
215
|
+
raise MemoryAllocationError, "Could not allocation memory for image" if ptr.null?
|
216
|
+
|
207
217
|
::GD2::GD2FFI.send(:gdImageAlphaBlending, ptr, alpha_blending ? 1 : 0)
|
208
218
|
ptr
|
209
219
|
end
|
data/lib/gd2/palette.rb
CHANGED
data/lib/gd2/version.rb
CHANGED
data/test/canvas_tests.rb
CHANGED
data/test/image_tests.rb
CHANGED
@@ -1,10 +1,36 @@
|
|
1
|
-
# encoding: ASCII-8BIT
|
1
|
+
# frozen_string_literal: true; encoding: ASCII-8BIT
|
2
2
|
|
3
3
|
require './test/test_helper'
|
4
4
|
|
5
|
-
class ImageTest <
|
5
|
+
class ImageTest < Minitest::Test
|
6
6
|
include TestHelper
|
7
7
|
|
8
|
+
def test_invalid_image_sizes
|
9
|
+
assert_raises(ArgumentError) do
|
10
|
+
GD2::Image.new(-10, 10)
|
11
|
+
end
|
12
|
+
|
13
|
+
assert_raises(ArgumentError) do
|
14
|
+
GD2::Image.new(0, 10)
|
15
|
+
end
|
16
|
+
|
17
|
+
assert_raises(ArgumentError) do
|
18
|
+
GD2::Image.new(10, -10)
|
19
|
+
end
|
20
|
+
|
21
|
+
assert_raises(ArgumentError) do
|
22
|
+
GD2::Image.new(10, 0)
|
23
|
+
end
|
24
|
+
|
25
|
+
assert_raises(GD2::Image::MemoryAllocationError) do
|
26
|
+
n_bytes = [42].pack('i').size
|
27
|
+
n_bits = n_bytes * 8
|
28
|
+
max = 2 ** (n_bits - 2) - 1
|
29
|
+
|
30
|
+
GD2::Image.new(max, max)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
8
34
|
def test_image_new_and_release
|
9
35
|
GD2::Image.new(50, 50)
|
10
36
|
end
|
@@ -41,7 +67,7 @@ class ImageTest < MiniTest::Unit::TestCase
|
|
41
67
|
out = File.join(Dir.tmpdir, 'test.#{ext}')
|
42
68
|
img.export(out)
|
43
69
|
|
44
|
-
assert(File.
|
70
|
+
assert(File.exist?(out))
|
45
71
|
|
46
72
|
imgA = GD2::Image.import(out)
|
47
73
|
imgB = GD2::Image.import(File.join(PATH_TO_IMAGES, 'test.#{ext}'))
|
Binary file
|
Binary file
|
Binary file
|
data/test/images/test_text.gd2
CHANGED
Binary file
|
Binary file
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gd2-ffij
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- J Smith
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-11-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -32,6 +32,7 @@ extra_rdoc_files:
|
|
32
32
|
- README.rdoc
|
33
33
|
files:
|
34
34
|
- ".gitignore"
|
35
|
+
- ".travis.yml"
|
35
36
|
- COPYRIGHT
|
36
37
|
- Gemfile
|
37
38
|
- Guardfile
|
@@ -108,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
109
|
version: '0'
|
109
110
|
requirements: []
|
110
111
|
rubyforge_project:
|
111
|
-
rubygems_version: 2.
|
112
|
+
rubygems_version: 2.6.13
|
112
113
|
signing_key:
|
113
114
|
specification_version: 4
|
114
115
|
summary: gd2-ffij is a refactoring of the Ruby/GD2 library implemented with FFI
|