[Gtk-sharp-list] Pixbuf API observations.

Miguel de Icaza miguel@ximian.com
17 Feb 2003 20:41:44 -0500


    Today I documented the Pixbuf class for Gtk# (changes are on CVS),
and I noticed a few problems with the API.  I do not know yet how the
API generator works, so I will not attempt to fix those (but I can fix
things that can be manually exposed).

    I can fill bugs if people think it is appropriate once I get a
go/no-go on the following changes:

* Problems

	* Constructor based on: gdk_pixbuf_new_from_data
	  	The first argument should be a "byte *data", but instead
	 	the generator picks `byte data'.

	* Constructor based on gdk_pixbuf_new_from_inline
		The first argument should be a "byte *data", but instead
	 	the geneator picks "byte data".

	* Pixels property return value.
		The return value for this is `byte' instead of `byte *'

	* GdkRGB seems to be missing from the generated bindings.

* Handling failure in constructors

	* A few C constructors return null, should we probe for this,
	  and throw a no-memory exception in those cases?

* API Improvements.

	* GetFromImage and GetFromDrawable both allow the first argument
	  to be NULL (ie, they are really factories for Pixbufs, but
	  we are exposing them as instance methods).

	  If nobody minds, I can add the .custom changes to have Factory
	  versions of them.  The only problem is that the API would be
	  the same between instance and static versions of the method. 
	  So maybe they will need new names.

	  I can do this if Mike does not mind.

	* Pixbuf.Copy should probably be Pixbuf.Clone, and we could have
	  Pixbuf implement the IClonable interface.

	* Overloads for methods taking color argumnets.

	  Currently colors are specified with uint32 colors in a few
	  places.  We could make the API more C#-ish, if we used the
	  System.Drawing Colors as arguments.  We could have overloads
	  for this.

* Wish items:

	I can do this if Mike does not mind:

	Constructor based on gdk_pixbuf_new_subpixbuf 
		Currently the API requires a Pixbuf to be
		created first, and then this function can be invoked.

		It is not entirely obvious, I would like to have
		a Subpixbuf method that would achieve the same.