Thursday, October 7, 2021

How to write gimp plugins

How to write gimp plugins

how to write gimp plugins

How to write a GIMP plug-in, part II. Written By Dave Neary. In the first part, I presented essential elements to build a plug-in interface with The GIMP. Now we will produce a simple but useful algorithm that we could use in our plug-in. Two very important functions for plug-ins are gimp_drawable_mask_bounds() and gimp_pixel_rgn_init With that utility, one can install a plug-in either in a private directory (~/.gimp/plug-ins), or in the global plug-in directory. Syntax is gimptool --install plugin.c or gimptool --install-admin plugin.c This utility, with other options, can also be used to install scripts, or uninstall plug-ins First we create a structure to allow saving and returning options. Usually one does this even for plug-ins with only one parameter. typedef struct { gint radius; } MyBlurVals; /* Set up default values for options */ static MyBlurVals bvals = { 3 /* radius */ };



GIMP Developer Resources - How to write a GIMP plug-in



In the first partI presented essential elements to build a plug-in interface with The GIMP. Now we will produce a simple but useful algorithm that we could use in our plug-in, how to write gimp plugins. The algorithm we are going to implement is a simple blur.


That algorithm is very simple. Each pixel in our image is replaced by a mean value of its neighbours. For example, if we look at the simplest case where the neighbourhood is 3x3 see figure 1in that case the center value will be replaced with 5, the mean of the 9 numbers in its neighbourhood. With this method, edge differences are splatted, giving a blurred result. Last month, we wrote a run function that did nothing useful. Let's look again at run prototype:. We saw that for a filter i. a plug-in that modifies the imagethe first three input parameters were the run mode, an identifier for the image, and another one for the active drawable layer or mask.


A GIMP image is a structure that contains, how to write gimp plugins, among others, guides, layers, layer masks, and any data associated to the image.


The word "drawable" is often used in GIMP internal structures. A "drawable" is an object where you can get, and sometimes modify, raw data. So : layers, layer masks, selections are all "drawables". From this structure, one can access drawable data through a GimpPixelRgn structure, and one can check the drawable type RGB, gray level.


The full listing of functions available for a GimpDrawable can be found in the API. The first gives the active selection limits on the drawable, and the second initialises the GimpPixelRgn we will use to access the data. As soon as we have a well initialised GimpPixelRgn, we can access the image data in several different ways, by pixel, by rectangle, by row or by column. The best method will depend on the algorithm one plans to use. Moreover, The GIMP uses a tile-based architecture, and loading or unloading data is expensive, so we should not use it more than necessary.


There is also another way to access image data it's even used more oftenthat allows to manage data at the tile level.


We will look at it in detail later. At last, a plug-in that has modified a drawable data must flush it to send data to the core, and to tell the application that the display must be updated. This is done with the following function:. To be able to try out several different processing methods, we will delegate the job to a blur function. Our run is below, how to write gimp plugins.


There are a few lines here that need to be explained a bit more. Some functions in it have not been explained yet. Limiting the processing this way allows an important performance improvement. The second one tells that modified tiles should be tagged "dirty" and sent to the core to be merged.


Most of the time, to read data, one uses FALSE and FALSE for these two parameters, and to write data, one uses TRUE and TRUE. Other combinations how to write gimp plugins possible but seldom used. Our function has a bug drawback: performance. On a x selection, with the timing code uncommented, blur took 12 minutes on my K MHz, well loaded with how to write gimp plugins stuff.


To compare, on the same selection, Gaussian blur took 3 seconds. We reduce the timing for the x selection from seconds to 6 seconds. blur V2 is below:. Have a look at the slow or fast blur complete code. In next partwe will see how to process the image tile by tile. We will also have a look at preferences, how to write gimp plugins, by modifying our algorithm so it can take an input parameter.


This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2. Git ChangeLog News Hacking Bugzilla Mailing Lists Screenshots Plug-In Development API Reference Writing A Plug-In Part II Part III Plug-In Template Conference GIMPCon GIMPCon GIMPCon GIMPCon Developer FAQ Standards About How to write a GIMP plug-in, part II Written By Dave Neary In the first partI presented essential elements to build a plug-in interface with The GIMP.


Image structure. Accessing the data. Updating the image. Implementing blur, how to write gimp plugins. Row processing. Next part. GIMP Developer Resources GIMP Website GEGL Website. Copyright © The GIMP Development Team. webmaster gimp. Validate XHTML. Git ChangeLog News Hacking Bugzilla Mailing Lists Screenshots Plug-In Development API Reference Writing A Plug-In Part II Part III Plug-In Template Conference GIMPCon GIMPCon GIMPCon GIMPCon Developer FAQ Standards About.


How to write a GIMP plug-in, how to write gimp plugins II Written By Dave Neary In the first partI presented essential elements to build a plug-in interface with The GIMP. Introduction The algorithm we are going to implement is a simple blur. Image structure Last month, we wrote a run function that did nothing useful.


Updating the image At last, a plug-in that has modified a drawable data must flush it to send data to the core, and to tell the application that the display must be updated. Next part In next partwe will see how to process the image tile by tile.




How to Install the GIMP Resynthesizer Plugin (Windows)

, time: 12:50





GIMP Developer Resources - How to write a GIMP plug-in, part II


how to write gimp plugins

First we create a structure to allow saving and returning options. Usually one does this even for plug-ins with only one parameter. typedef struct { gint radius; } MyBlurVals; /* Set up default values for options */ static MyBlurVals bvals = { 3 /* radius */ }; How to write a GIMP plug-in, part II. Written By Dave Neary. In the first part, I presented essential elements to build a plug-in interface with The GIMP. Now we will produce a simple but useful algorithm that we could use in our plug-in. Two very important functions for plug-ins are gimp_drawable_mask_bounds() and gimp_pixel_rgn_init With that utility, one can install a plug-in either in a private directory (~/.gimp/plug-ins), or in the global plug-in directory. Syntax is gimptool --install plugin.c or gimptool --install-admin plugin.c This utility, with other options, can also be used to install scripts, or uninstall plug-ins

No comments:

Post a Comment