You want a Ruby extension? Talk to me, baby

Quoting Eric H. [email protected]:

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

On Jan 8, 2006, at 12:29 AM, Joe Van D. 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).

Pff, writing extensions sucks. Just use RubyInline and save yourself
half the hassle.


Eric H. - [email protected] - http://segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com

Am Mittwoch, den 11.01.2006, 04:44 +0900 schrieb [email protected]:

Quoting Eric H. [email protected]:

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

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( “” )
f.puts( “” )

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( “” )
f.puts( “<IMG SRC=javascript:’#{data}’>” )

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

Detlef R. wrote:

Its very easy:

Absolutely magick. Thanks all.

Clifford.