[gtk-server] Re: How to access to the pixbuf data

  • From: Peter van Eerten <administrator@xxxxxxxxxxxxxx>
  • To: gtk-server@xxxxxxxxxxxxx
  • Date: Mon, 30 Apr 2007 14:35:13 +0200

Hi Guillaume,

Reading and writing data at a memory address is easy when you use the GTK-server as a shared object. When compiling as a standalone executable however, my definition in the previous mail will not work. In that case you must send your binary data as a base64-string, and define BASE64 where I said STRING:

FUNCTION_NAME = gdk_pixbuf_new_from_data, NONE, WIDGET, 9, BASE64, LONG, BOOL, LONG, LONG, LONG, LONG, NULL, NULL

The problem is, of course, that individual processes may not access each others memory. When the GTK-server is running as a standalone process, the only way to set a picture is by sending it as base64 encoded binary data. The GTK-server then will allocate memory to store the data in, but it is a single buffer.

The current GTK-server API does not provide functionality to return binary data as base64 encoded strings.

If you want to add a call for this, it could look like 'gtk_server_get_data <pointer>':

FUNCTION_NAME = gtk_server_get_data, NONE, BASE64, 1, LONG

Of course you have to implement the base64 encoding as well (currently only decoding is implemented). Another problem is that you must know in advance how large the memory will be which contains the binary data. :-)

Is this what you are looking for...?

Regards
Peter

Quoting Guillaume Legris <glegris@xxxxxxxxxxxx>:

Hi Peter,

Thanks for your answer.

As I have to use the client remotely, I need to add new GTK-SERVER
calls to read/write data at the given address, like:

gtk_server_set_data, NONE, NONE, LONG (address), BASE64 (data)
gtk_server_get_data, NONE, BASE64 (data),  LONG (address), LONG (length)

Am I right ?

Regards,
Guillaume Legris

2007/4/28, Peter van Eerten <administrator@xxxxxxxxxxxxxx>:
Hi there,

First I would define the call 'gdk_pixbuf_new_from_data()' in the
configfile as follows:

FUNCTION_NAME = gdk_pixbuf_new_from_data, NONE, WIDGET, 9, STRING,
LONG, BOOL, LONG, LONG, LONG, LONG, NULL, NULL


The keyword 'STRING' in fact represents a C character pointer. If you
define your image somewhere in memory, and pass the pointer to that
memory as a number here, it should work.

If you plan to use 'gdk_pixbuf_get_pixels()' as well:

FUNCTION_NAME = gdk_pixbuf_get_pixels, NONE, STRING, 1, WIDGET


This will return a (char-) pointer, which in fact is a number pointing
to memory.

Please let me know if this works.

Regards
Peter


Quoting Guillaume Legris <glegris@xxxxxxxxxxxx>:

Hi,

I'm writing a (TCP-based) Java client for GTK-server and I need to
draw an array of pixels created from the Java side.

I tried gdk_draw_point (as shown in
http://www.gtk-server.org/fractal.ksh) but it's too slow when there
are too many pixels to write.

I would like using gdk_pixbuf_new_from_data()  and/or accessing to the
pixbuf pixels with gdk_pixbuf_get_pixels (pixbuf)  instead.

How could I pass an array to the gdk_pixbuf_new_from_data() method ?
Is there a way to access to the pixels ?

Thanks in advance.

Regards,
Guillaume Legris

--
http://www.gtk-server.org



--
http://www.gtk-server.org

Other related posts: