# More c friendly interface to FXImage

**URL:** <https://www.ruby-forum.com/t/more-c-friendly-interface-to-fximage/86573>\
**Category:** Ruby\
**Created:** [February 23, 2007, 11:21am UTC](https://www.ruby-forum.com/t/more-c-friendly-interface-to-fximage/86573 "2007-02-23T11:21:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![seeweer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e5b9ba/32.png) [@seeweer](https://www.ruby-forum.com/u/seeweer)\
**Post date:** [February 23, 2007, 11:21am UTC](https://www.ruby-forum.com/t/more-c-friendly-interface-to-fximage/86573/1 "2007-02-23T11:21:13Z")

</div>

Hi all,

I’m looking for an efficient way of image manipulation/rerendering  
using fximage from fxruby:

To initialize a FXImage with a persistent pixel buffer one has to:

image = FXImage.new(getApp(), buf, IMAGE\_OWNED|IMAGE\_KEEP, width,  
height)

where buf is an array of FXColor of size=width\*height

after initialization

image.data.data

is a pointer to this buffer.

As image processing is quite computational expensive I would  
appriciate a more c language friendly interface …

so for example

buf= MyPic.new

where MyPic is implemented in c using e.g.

typedef struct {  
int w,h;

//let it be the 4 bytes/ rgba pixel as required by fxruby  
unsiged char \* pixels;  
…  
} MyPic;

This would solve the problem that after changing the MyPic buffer  
pixels the rerendering of the picture requires converting it to an  
array of FXColor first …

[\*  
Other solution would be to access the values of a ruby array in c as  
an  
memory block without copying it (didn’t look into the implementation  
of the ruby array if it’s implemented this way at all …)  
\*]

Any suggestions? Is it already implemented somehow and I just don’t  
see  
it?

Any help would be appreciated

Artur

---

<div class="post-metadata">

**Author:** ![seeweer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e5b9ba/32.png) [@seeweer](https://www.ruby-forum.com/u/seeweer)\
**Post date:** [February 23, 2007, 5:18pm UTC](https://www.ruby-forum.com/t/more-c-friendly-interface-to-fximage/86573/2 "2007-02-23T17:18:15Z")

</div>

On 2/23/07 4:20 AM, in article  
removed\_email\_address@domain.invalid, “Artur M.”  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’m looking for an efficient way of image manipulation/rerendering  
> using fximage from fxruby:

This discussion really, _really_ belongs on the FXRuby mailing list. But  
anyways…

> ```
> int w,h;
> 
> ```
> 
> //let it be the 4 bytes/ rgba pixel as required by fxruby  
> unsiged char \* pixels;  
> …  
> } MyPic;

So instead of (or as alternative to) manipulating an array of FXColor,  
you’d  
manipulate a Ruby string of bytes which has size 4_w_h? OK, I get it.

> This would solve the problem that after changing the MyPic buffer  
> pixels the rerendering of the picture requires converting it to an  
> array of FXColor first …

True, but that pixels “array” (really, a String) would still need to be  
converted to an array of FXColor in the C++ wrapper layer, because the  
FOX  
library expects an array of FXColor values.

> Any suggestions? Is it already implemented somehow and I just don’t  
> see it?

No, you’ve got it right concerning the current approach. I would suggest  
that you file a feature request about this, and we’ll see if it can be  
added  
in a future release of FXRuby:

```
http://rubyforge.org/tracker/?atid=1226&group_id=300&func=browse

```

Thanks,

Lyle
