Title: [923] trunk/image_voodoo: hoe it up.
Revision
923
Author
enebo
Date
2008-03-04 09:44:36 -0500 (Tue, 04 Mar 2008)

Log Message

hoe it up.  make cropped_thumbnail work again.  minor editing

Modified Paths


Added Paths

Diff

Added: trunk/image_voodoo/History.txt (0 => 923)


--- trunk/image_voodoo/History.txt	                        (rev 0)
+++ trunk/image_voodoo/History.txt	2008-03-04 14:44:36 UTC (rev 923)
@@ -0,0 +1,3 @@
+== 0.1
+
+- Initial packaging of library into a gem

Added: trunk/image_voodoo/LICENSE.txt (0 => 923)


--- trunk/image_voodoo/LICENSE.txt	                        (rev 0)
+++ trunk/image_voodoo/LICENSE.txt	2008-03-04 14:44:36 UTC (rev 923)
@@ -0,0 +1,20 @@
+Copyright (c) 2008 Thomas E Enebo <[EMAIL PROTECTED]>
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Added: trunk/image_voodoo/Manifest.txt (0 => 923)


--- trunk/image_voodoo/Manifest.txt	                        (rev 0)
+++ trunk/image_voodoo/Manifest.txt	2008-03-04 14:44:36 UTC (rev 923)
@@ -0,0 +1,5 @@
+Manifest.txt
+Rakefile
+README.txt
+LICENSE.txt
+lib/image_voodoo.rb

Added: trunk/image_voodoo/README.txt (0 => 923)


--- trunk/image_voodoo/README.txt	                        (rev 0)
+++ trunk/image_voodoo/README.txt	2008-03-04 14:44:36 UTC (rev 923)
@@ -0,0 +1,6 @@
+This is an Image manipulation library with a ImageScience-compatible API for
+JRuby. See:
+
+http://jruby-extras.rubyforge.org/image_voodoo/
+
+for more information.

Added: trunk/image_voodoo/Rakefile (0 => 923)


--- trunk/image_voodoo/Rakefile	                        (rev 0)
+++ trunk/image_voodoo/Rakefile	2008-03-04 14:44:36 UTC (rev 923)
@@ -0,0 +1,27 @@
+MANIFEST = FileList["Manifest.txt", "Rakefile", "README.txt", "LICENSE.txt", "lib/**/*"]
+
+file "Manifest.txt" => :manifest
+task :manifest do
+  File.open("Manifest.txt", "w") {|f| MANIFEST.each {|n| f << "#{n}\n"} }
+end
+Rake::Task['manifest'].invoke # Always regen manifest, so Hoe has up-to-date list of files
+
+$LOAD_PATH << 'lib'
+require 'image_voodoo'
+begin
+  require 'hoe'
+  Hoe.new("image_voodoo", ImageVoodoo::VERSION) do |p|
+    p.rubyforge_name = "jruby-extras"
+    p.url = ""
+    p.author = "Thomas Enebo, Charles Nutter and JRuby contributors"
+    p.email = "[EMAIL PROTECTED], [EMAIL PROTECTED]"
+    p.summary = "Image manipulation with ImageScience compatible API"
+    p.changes = "Updated to ImageVoodoo version #{ImageVoodoo::VERSION}."
+    p.description = "Install this gem and require 'image_voodoo' to load the library."
+  end.spec.dependencies.delete_if { |dep| dep.name == "hoe" }
+rescue LoadError
+  puts "You need Hoe installed to be able to package this gem"
+rescue => e
+  p e.backtrace
+  puts "ignoring error while loading hoe: #{e.to_s}"
+end

Modified: trunk/image_voodoo/lib/image_voodoo.rb (922 => 923)


--- trunk/image_voodoo/lib/image_voodoo.rb	2008-03-02 04:25:33 UTC (rev 922)
+++ trunk/image_voodoo/lib/image_voodoo.rb	2008-03-04 14:44:36 UTC (rev 923)
@@ -1,4 +1,6 @@
 class ImageVoodoo
+  VERSION = "0.1"
+
   include Java
   
   import java.awt.Image
@@ -17,7 +19,7 @@
   end
 
   def cropped_thumbnail(size)
-    half = (width - height).abs / 2
+    l, t, r, b, half = 0, 0, width, height, (width - height).abs / 2
     l, r = half, half + height if width > height
     t, b = half, half + width if height > width
 
@@ -35,18 +37,15 @@
   end
 
   def resize(width, height)
-    target = BufferedImage.new(
-      width, height, BufferedImage::TYPE_4BYTE_ABGR)
+    target = BufferedImage.new(width, height, BufferedImage::TYPE_4BYTE_ABGR)
     graphics = target.graphics
-    graphics.set_rendering_hint(
-      RenderingHints::KEY_INTERPOLATION,
-      RenderingHints::VALUE_INTERPOLATION_BICUBIC)
+    graphics.set_rendering_hint(RenderingHints::KEY_INTERPOLATION,
+                                RenderingHints::VALUE_INTERPOLATION_BICUBIC)
     
-    w_scale = width.to_f/@src.width
-    h_scale = height.to_f/@src.height
+    w_scale = width.to_f / @src.width
+    h_scale = height.to_f / @src.height
     
-    transform =
-      AffineTransform.get_scale_instance w_scale, h_scale
+    transform = AffineTransform.get_scale_instance w_scale, h_scale
     
     graphics.draw_rendered_image @src, transform
     graphics.dispose
@@ -55,12 +54,10 @@
   end
   
   def greyscale
-    target = BufferedImage.new(
-      width, height, BufferedImage::TYPE_USHORT_GRAY)
+    target = BufferedImage.new(width, height, BufferedImage::TYPE_USHORT_GRAY)
     graphics = target.graphics
-    graphics.set_rendering_hint(
-      RenderingHints::KEY_INTERPOLATION,
-      RenderingHints::VALUE_INTERPOLATION_BICUBIC)
+    graphics.set_rendering_hint(RenderingHints::KEY_INTERPOLATION,
+                                RenderingHints::VALUE_INTERPOLATION_BICUBIC)
     
     graphics.draw_rendered_image @src, nil
     graphics.dispose
@@ -101,9 +98,7 @@
   end
 
   def self.with_bytes(bytes)
-    if String === bytes
-      bytes = bytes.to_java_bytes
-    end
+    bytes = bytes.to_java_bytes if String === bytes
 
     image = ImageIO.read(BAIS.new(bytes))
     yield ImageVoodoo.new(image)
_______________________________________________
Jruby-extras-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/jruby-extras-devel

Reply via email to