hornetseye-rmagick 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -6,7 +6,7 @@ require 'rake/packagetask'
6
6
  require 'rbconfig'
7
7
 
8
8
  PKG_NAME = 'hornetseye-rmagick'
9
- PKG_VERSION = '0.1.0'
9
+ PKG_VERSION = '0.2.0'
10
10
  RB_FILES = FileList[ 'lib/**/*.rb' ]
11
11
  TC_FILES = FileList[ 'test/tc_*.rb' ]
12
12
  TS_FILES = FileList[ 'test/ts_*.rb' ]
@@ -55,7 +55,37 @@ module Magick
55
55
  Hornetseye::MultiArray.import typecode,
56
56
  export_pixels_to_str( 0, 0, columns, rows, format, pixel_type ),
57
57
  columns, rows
58
-
58
+ end
59
+
60
+ def to_multiarray
61
+ case image_type
62
+ when BilevelType, GrayscaleType, GrayscaleMatteType
63
+ case depth
64
+ when 32
65
+ to_type UINT
66
+ when 16
67
+ to_type USINT
68
+ when 1, 8
69
+ to_type UBYTE
70
+ else
71
+ Kernel.raise "Conversion for grayscale image with depth #{depth} not " +
72
+ "implemented"
73
+ end
74
+ when PaletteType, PaletteMatteType, TrueColorType, TrueColorMatteType
75
+ case depth
76
+ when 32
77
+ to_type UINTRGB
78
+ when 16
79
+ to_type USINTRGB
80
+ when 8
81
+ to_type UBYTERGB
82
+ else
83
+ Kernel.raise "Conversion for colour image with depth #{depth} not " +
84
+ "implemented"
85
+ end
86
+ else
87
+ Kernel.raise "Unknown image type #{image_type.inspect}"
88
+ end
59
89
  end
60
90
 
61
91
  end
@@ -0,0 +1,76 @@
1
+ # hornetseye-rmagick - RMagick integration for Hornetseye
2
+ # Copyright (C) 2010 Jan Wedekind
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+ module Hornetseye
17
+
18
+ class Node
19
+
20
+ def to_magick
21
+ unless dimension == 2
22
+ raise "Array must have two dimensions (but has #{dimension})"
23
+ end
24
+ case typecode
25
+ when UBYTE
26
+ pixel_type = Magick::CharPixel
27
+ colourspace = 'I'
28
+ depth = 8
29
+ when USINT
30
+ pixel_type = Magick::ShortPixel
31
+ colourspace = 'I'
32
+ depth = 16
33
+ when UINT
34
+ pixel_type = Magick::IntegerPixel
35
+ colourspace = 'I'
36
+ depth = 32
37
+ when SFLOAT
38
+ pixel_type = Magick::FloatPixel
39
+ colourspace = 'I'
40
+ depth = nil
41
+ when DFLOAT
42
+ pixel_type = Magick::DoublePixel
43
+ colourspace = 'I'
44
+ depth = nil
45
+ when UBYTERGB
46
+ pixel_type = Magick::CharPixel
47
+ colourspace = 'RGB'
48
+ depth = 8
49
+ when USINTRGB
50
+ pixel_type = Magick::ShortPixel
51
+ colourspace = 'RGB'
52
+ depth = 16
53
+ when UINTRGB
54
+ pixel_type = Magick::IntegerPixel
55
+ colourspace = 'RGB'
56
+ depth = 32
57
+ when SFLOATRGB
58
+ pixel_type = Magick::FloatPixel
59
+ colourspace = 'RGB'
60
+ depth = nil
61
+ when DFLOATRGB
62
+ pixel_type = Magick::DoublePixel
63
+ colourspace = 'RGB'
64
+ depth = nil
65
+ else
66
+ raise "Conversion from #{typecode} to Magick::Image not implemented"
67
+ end
68
+ retval = Magick::Image.new( *shape ) { self.depth = depth if depth }
69
+ str = memory.read memory.size
70
+ retval.import_pixels 0, 0, shape[0], shape[1], colourspace, str, pixel_type
71
+ retval
72
+ end
73
+
74
+ end
75
+
76
+ end
@@ -18,5 +18,6 @@ require 'RMagick'
18
18
  require 'malloc'
19
19
  require 'multiarray'
20
20
  require 'hornetseye_frame'
21
+ require 'hornetseye-rmagick/node'
21
22
  require 'hornetseye-rmagick/image'
22
23
 
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 1
7
+ - 2
8
8
  - 0
9
- version: 0.1.0
9
+ version: 0.2.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jan Wedekind
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-10-05 00:00:00 +01:00
17
+ date: 2010-10-06 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -87,6 +87,7 @@ files:
87
87
  - .document
88
88
  - lib/hornetseye_rmagick.rb
89
89
  - lib/hornetseye-rmagick/image.rb
90
+ - lib/hornetseye-rmagick/node.rb
90
91
  has_rdoc: yard
91
92
  homepage: http://wedesoft.github.com/hornetseye-rmagick/
92
93
  licenses: []