GNOME Bugzilla – Bug 721249
pdb.gimp_context_set_brush_size() dont't work
Last modified: 2014-11-10 23:23:10 UTC
Created attachment 265057 [details] Illustration of unproper line A Python-Fu function "pdb.gimp_context_set_brush_size()" do not sets the brush size. The size stays on default value. How to reproduce: 1. Open GIMP, create a new image with white layer 2. Make sure foreground color is black. 3. Open python console (Filters/Python-Fu/Console) 4. Enter these commands: image = gimp.image_list()[0] drawable = image.layers[0] ctrlpoints = [0,0,100,100] pdb.gimp_context_set_brush_size(1.00) pdb.gimp_paintbrush(drawable, 0, len(ctrlpoints), ctrlpoints, 0, 0) And you'll see the line from picture from attachment instead of line with 1 pixel thickness. Similar result with pdb.gimp_pencil() and pdb.gimp_paintbrush_default(). OS Linux Mint 15 MATE x86_64 GIMP version is 2.8.10, the build from PPA (https://launchpad.net/~otto-kesselgulasch/+archive/gimp). However, that bug was in distribution's original GIMP 2.8.4 too.
Hm... the size changes, but the stroke uses the non-scaled sized.
This is caused by commit 5d5430e110e1deb376e6bef09eeee7975dcc4fc6 which resets the brush size on each paint stroke. I have no clue why this was done. Alexia?
This does NOT fix this bug, it cleans up the "reset brush size" code which is involved here. commit b4477d8e01e4b03121a9b834d35b69d0d8374638 Author: Michael Natterer <mitch@gimp.org> Date: Sat Jan 4 15:45:25 2014 +0100 app: add gimp_paint_options_set_default_brush_size() and use it globally instead of two different methods, one of which was forgotten to be ported to the new aspect ratio range where 0.0 means 1:1. Add a FIXME comment in paint_tools.pdb where I think setting the default size is a bug, see #721249. (cherry picked from commit ef858453724f6d4ca105fc9daec038fdff358f30) app/core/gimpstrokeoptions.c | 19 ++----------------- app/paint/gimppaintoptions.c | 24 ++++++++++++++++++++++++ app/paint/gimppaintoptions.h | 3 +++ app/pdb/context-cmds.c | 8 ++------ app/pdb/paint-tools-cmds.c | 14 +++----------- app/tools/gimppaintoptions-gui.c | 10 +--------- tools/pdbgen/pdb/context.pdb | 10 +++------- tools/pdbgen/pdb/paint_tools.pdb | 14 +++----------- 8 files changed, 41 insertions(+), 61 deletions(-)
Probably related: this breaks plug-ins that call gimp-paintbrush or gimp-paintbrush-default expecting a wide stroke. Instead they get a narrow stroke the size of the base brush before scaling.
Fixed in master and gimp-2-8, let's see what painting stuff breaks next... commit 6cb5fcafb04c515f8773f81d6867efcedd95688e Author: Michael Natterer <mitch@gimp.org> Date: Mon Feb 3 23:05:56 2014 +0100 Bug 721249 - pdb.gimp_context_set_brush_size() dont't work Don't reset the brush size before each PDB paint stroke. (cherry picked from commit 9fe869236bbf178ac9699e0e789f78aa085e5ef6) app/pdb/paint-tools-cmds.c | 4 ---- tools/pdbgen/pdb/paint_tools.pdb | 4 ---- 2 files changed, 8 deletions(-)
Nice, thanks! There are still some differences for plug-in compatibility. The endpoints when using pdb.gimp_paintbrush to draw a line between two points seem to be drawn differently than they used to be (square instead of round, by default) and they extend farther out, past the endpoint specified. Also, gimp_edit_stroke still doesn't use the line width. I'll attach a little python plug-in that illustrates the differences, and examples of its output in 2.6 vs. the just-fixed 2.9 (I'm assuming 2.8 will be the same). I thought I'd seen the old 2.6-style behavior in earlier 2.8 builds as well, but currently the oldest 2.8 I have handy is acting just like git master was before you fixed this bug (all thin lines, ignoring line width). I could rewrite my plug-in (arrow designer, not linetest :-) to work with the new behavior, but I thought you'd want to know about the differences since some plug-ins might not get updated.
Created attachment 268118 [details] Test plug-in to demonstrate the differences Here's a python plug-in to test a line drawn with gimp_paintbrush. Set the paintbrush size first, then open a new image and run Filters->Line test.
Created attachment 268119 [details] linetest run in GIMP 2.6, using the circle 19 brush linetest run in GIMP 2.6, using the circle 19 brush. And I forgot to mention that you should make a rect selection before running linetest -- it strokes the selection first so you can see how the line endpoints compare with the coordinates passed in.
Created attachment 268120 [details] linetest in git master linetest in git master, using the pixel brush set to a size of 20. Note the stroke ignores the line width, that the endpoints are square now, and extend outside the selection -- though I didn't use the measure tool, and it's hard to tell how they vary since the stroke widths aren't comparable. Restoring the old selection would be a better test, but gimp_image_select_item (which I use in 2.8+) doesn't work in 2.6 and I ran out of time before finding a 2.6-compatible way.
OMG, stroking needs quite some love I'm afraid...
This fixes stroking, master and gimp-2-8: commit c15d7bcc8083533fa360c49eafcb48aeb119ce38 Author: Michael Natterer <mitch@gimp.org> Date: Thu Feb 6 23:20:39 2014 +0100 Bug 721249 - pdb.gimp_context_set_brush_size() dont't work Port selection/path stroking to using the PDB-controllable paint options that live in GimpPDBContext. Change gimp_item_stroke()'s "use_default_values" boolean which was introduced at a time where we had no better way by a GimpPaintOptions parameter. If a non-NULL paint_options is passed (when called from the PDB), use it for stroking; if NULL is passed, use the actual paint tool options from the GUI (when called from the menus or the stroke dialog). In the PDB wrappers, get the right paint options object from the PDB context associated with the calling plug-in. (cherry picked from commit 4d6640ff79ff13ae6d031da477a21c85119b2f15) app/actions/select-commands.c | 3 ++- app/actions/vectors-commands.c | 3 ++- app/core/gimpitem.c | 8 ++++++-- app/core/gimpitem.h | 2 +- app/core/gimpstrokeoptions.c | 14 ++++++-------- app/core/gimpstrokeoptions.h | 2 +- app/dialogs/stroke-dialog.c | 4 ++-- app/pdb/edit-cmds.c | 29 +++++++++++++++++++++++------ app/pdb/gimppdbcontext.c | 4 +++- app/pdb/paths-cmds.c | 15 ++++++++++++--- tools/pdbgen/pdb/edit.pdb | 28 ++++++++++++++++++++++------ tools/pdbgen/pdb/paths.pdb | 15 ++++++++++++--- 12 files changed, 92 insertions(+), 35 deletions(-)
Created attachment 284922 [details] [review] faulty unreferencing paint_options.patch In gimpstrokeoptions.c/gimp_stroke_options_prepare the paint_options are erroneously unref'd. Gimp for windows crashes, gimp for linux reports a critical error.
Comment on attachment 284922 [details] [review] faulty unreferencing paint_options.patch Indeed, please push to master and gimp-2-8.
fixed in master and 2.8 author Hartmut Kuhse <hk_priv@gmx.de> Date 2014-08-31 13:27:12 (GMT) commit ed42899041eb4948e492563bccdb5d44f07eb87f (patch) app: erroneously dereferencing paint_optionsgimp-2-8 fixing commit 4d6640ff79ff13ae6d031da477a21c85119b2f15 (cherry picked from commit 50463d8d5ab6e15c4d5345769bae795e7becdff7) app/core/gimpstrokeoptions.c
*** Bug 739919 has been marked as a duplicate of this bug. ***