You want a Ruby extension? Talk to me, baby

Quoting Eric Hodel <drbrain@segment7.net>:

You don't need an extension for that. You've already got
Ruby-GTK and RMagick. Just glue them together with Ruby.

He's probably wondering specifically how to get from an RMagick
image to a GdkPixbuf or similar (a question I don't know the answer
to offhand), in pure Ruby.

-mental

If this helps, I work with unixODBC + Ruby ODBC + Informix on Solaris
all the time without problems. I wrote an Informix adapter for Rails
this way that works fine

Talking about extensions, I'll attempt to write the native Informix
extension for Ruby. It would be nice to see if someone else find it
useful.

···

2006/1/8, Gregory Brown <gregory.t.brown@gmail.com>:

On 1/8/06, Robert Klemme <bob.news@gmx.net> wrote:
> Gregory Brown <gregory.t.brown@gmail.com> wrote:
> > On 1/8/06, Joe Van Dyk <joevandyk@gmail.com> wrote:
> >> Hi,
> >>
> >> I've figured that it's probably worth my time to learn how to better
> >> write Ruby extensions (as a way to practice my C).
> >>
> >> Are there any C or C++ libraries out there that someone would
> >> appreciate an open-sourced Ruby extension for?
> >>
> > Improving, expanding, cleaning up and otherwise working on the mysql c
> > binding would certainly be something I'd appreciate. Though I do not
> > know the status of it's development activity...
>
> I'm not sure about MS SQL bindings but IIRC they use ODBC and hence are only
> present on Windows builts. If so, integrating http://www.freetds.org then
> would be a good idea.

MS SQL uses ODBC or ADO.
There *is* an ODBC for *nix. No clue on it's reliability.

--
Gerardo Santana
"Between individuals, as between nations, respect for the rights of
others is peace" - Don Benito Juárez

Quoting Eric Hodel <drbrain@segment7.net>:

> You don't need an extension for that. You've already got
> Ruby-GTK and RMagick. Just glue them together with Ruby.

He's probably wondering specifically how to get from an RMagick
image to a GdkPixbuf or similar (a question I don't know the answer
to offhand), in pure Ruby.

Its very easy:

my_pixbuf = Gdk::Pixbuf.new(rmagic_image.to_blob,
Gdk::Pixbuf::ColorSpace::RGB, false, 8, image_width, image_height,
image.width * 3)

the API reference for the gdk-pixbuf call is:
Gdk::Pixbuf.new(data, colorspace, has_alpha, bit_per_sample, width,
height, rowstride)

rmagic_image.to_blob returns the pixel data

cheers
detlef

···

Am Mittwoch, den 11.01.2006, 04:44 +0900 schrieb mental@rydia.net:

-mental

Detlef Reichl wrote:

Its very easy:

Absolutely *magick*. Thanks all.

Clifford.

Hello, I'm trying to load an 8x8 GIF file and embed it directly into some HTML but the image pixels are out of order and the dimensions are not correct. I assume the problem is with the byte order during the read. Can any of you suggest a better way to do this?

···

#########################################
require 'base64'

gif_path = 'C:\work\gifTest\gifTest.gif'
html_path = 'C:\work\gifTest\gifTest.html'

f = File.open( gif_path, "rb" )
data = f.read
f.close

encoded = Base64.encode64( data )

f = File.open( html_path, 'w' )

# links work perfectly
f.puts( "<IMG SRC=file:///C:/work/gifTest/gifTest.gif>" )
f.puts( "<IMG SRC=file:///#{gif_path}>" )

# something appears, but out-of-order and wrong dimension
f.puts( "<IMG SRC=\"javascript:'#{data}'\">" )

# these produce the "missing image" placeholder
f.puts( "<IMG SRC=\"data:image/gif;base64,#{data}\">" )
f.puts( "<IMG SRC=data:image/gif;base64,#{data}>" )
f.puts( "<IMG SRC=javascript:'#{data}'>" )

f.close
#########################################