Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Porting C plugin (xsane) to GIMP 3
#1
Hi,
I am engaged in porting the xsane GIMP plugin code to the new GIMP 3 API. So far it has been a bit of a struggle since the doc is still pretty sparse. So I am looking for some hints.

xsane doesn't have a very complex relationship with GIMP, so I don't believe that there is much left to do. However, I do have some specific questions that I hope I can get some help with.

What I have so far is the infrastructure and new boilerplate to register the menu items. All of that works fine. 

Now I am looking at image creation.

I have the following sequence to get a new image with an attached layer:

gimp_image_new()
gimp_layer_new()
gimp_image_insert_layer()

Now, in order to get a buffer onto which to draw the scanned image, the GIMP 2 code used:

buffer = gimp_drawable_get_buffer(layer_ID);

However, this function does not take a layer in GIMP 3. It takes a GimpDrawable. What do I need to do to draw to a layer or is there a different method not recommended? There doesn't seem to be a function to get a drawable from a layer.

Cheers, and thanks in advance.
skelband
Reply
#2
(Yesterday, 05:27 AM)skelband Wrote: Hi,
I am engaged in porting the xsane GIMP plugin code to the new GIMP 3 API. So far it has been a bit of a struggle since the doc is still pretty sparse. So I am looking for some hints.

xsane doesn't have a very complex relationship with GIMP, so I don't believe that there is much left to do. However, I do have some specific questions that I hope I can get some help with.

What I have so far is the infrastructure and new boilerplate to register the menu items. All of that works fine. 

Now I am looking at image creation.

I have the following sequence to get a new image with an attached layer:

gimp_image_new()
gimp_layer_new()
gimp_image_insert_layer()

Now, in order to get a buffer onto which to draw the scanned image, the GIMP 2 code used:

buffer = gimp_drawable_get_buffer(layer_ID);

However, this function does not take a layer in GIMP 3. It takes a GimpDrawable. What do I need to do to draw to a layer or is there a different method not recommended? There doesn't seem to be a function to get a drawable from a layer.

Cheers, and thanks in advance.
skelband

A layer is a "drawable" (*) so you can always use the layer object directly where Gimp wants a drawable.

(*) A drawable is either a layer, a layer mask or a channel (including the selection). GroupLayers are also drawables even though you can't draw on them  Big Grin
Reply
#3
Hi,
OK, I figured it out thanks. Yes you are right. Since layer is derived from a drawable, I can "cast" it to the right type with GIMP_DRAWABLE(layer). It all works now actually with some other little tweaks to the code. Wasn't as big a task as I anticipated.
Reply


Forum Jump: