Academic Tutorials



English | French | Portugese | German | Italian
Home Advertise Payments Recommended Websites Interview Questions FAQs
News Source Codes E-Books Downloads Jobs Web Hosting
Chats

Gimp Tutorial
Gimp Introduction
Gimp Background
GIMP PDB
Gimp Object Oriented Syntax
Gimp Painting Areas
Gimp Creating Text
Gimp Floating Selections
Gimp Perl Server

HTML Tutorials
HTML Tutorial
XHTML Tutorial
CSS Tutorial
TCP/IP Tutorial
CSS 1.0
CSS 2.0
HLML
XML Tutorials
XML Tutorial
XSL Tutorial
XSLT Tutorial
DTD Tutorial
Schema Tutorial
XForms Tutorial
XSL-FO Tutorial
XML DOM Tutorial
XLink Tutorial
XQuery Tutorial
XPath Tutorial
XPointer Tutorial
RDF Tutorial
SOAP Tutorial
WSDL Tutorial
RSS Tutorial
WAP Tutorial
Web Services Tutorial
Browser Scripting
JavaScript Tutorial
VBScript Tutorial
DHTML Tutorial
HTML DOM Tutorial
WMLScript Tutorial
E4X Tutorial
Server Scripting
ASP Tutorial
PERL Tutorial
SQL Tutorial
ADO Tutorial
CVS
Python
Apple Script
PL/SQL Tutorial
SQL Server
PHP
.NET (dotnet)
Microsoft.Net
ASP.Net
.Net Mobile
C# : C Sharp
ADO.NET
VB.NET
VC++
Multimedia
SVG Tutorial
Flash Tutorial
Media Tutorial
SMIL Tutorial
Photoshop Tutorial
Gimp Tutorial
Matlab
Gnuplot Programming
GIF Animation Tutorial
Scientific Visualization Tutorial
Graphics
Web Building
Web Browsers
Web Hosting
W3C Tutorial
Web Building
Web Quality
Web Semantic
Web Careers
Weblogic Tutorial
SEO
Web Site Hosting
Domain Name
Java Tutorials
Java Tutorial
JSP Tutorial
Servlets Tutorial
Struts Tutorial
EJB Tutorial
JMS Tutorial
JMX Tutorial
Eclipse
J2ME
JBOSS
Programming Langauges
C Tutorial
C++ Tutorial
Visual Basic Tutorial
Data Structures Using C
Cobol
Assembly Language
Mainframe
Forth Programming
Lisp Programming
Pascal
Delphi
Fortran
OOPs
Data Warehousing
CGI Programming
Emacs Tutorial
Gnome
ILU
Soft Skills
Communication Skills
Time Management
Project Management
Team Work
Leadership Skills
Corporate Communication
Negotiation Skills
Database Tutorials
Oracle
MySQL
Operating System
BSD
Symbian
Unix
Internet
IP-Masquerading
IPC
MIDI
Software Testing
Testing
Firewalls
SAP Module
ERP
ABAP
Business Warehousing
SAP Basis
Material Management
Sales & Distribution
Human Resource
Netweaver
Customer Relationship Management
Production and Planning
Networking Programming
Corba Tutorial
Networking Tutorial
Microsoft Office
Microsoft Word
Microsoft Outlook
Microsoft PowerPoint
Microsoft Publisher
Microsoft Excel
Microsoft Front Page
Microsoft InfoPath
Microsoft Access
Accounting
Financial Accounting
Managerial Accounting
Network Sites


Painting areas with selections


Previoushome Next






6. Painting areas with selections


In the uni script the function gimp_edit_fill was called to fill the whole image. Looking at the info for gimp_edit_fill in the DB browser we find the following:

A D V E R T I S E M E N T

 

Name: gimp_edit_fill
Blurb: Fill selected area of drawable
In: DRAWABLE drawable The drawable to fill from
  INT32 fill_type The type of fill: FG_IMAGE_FILL (0), BG_IMAGE_FILL (1), WHITE_IMAGE_FILL (2), TRANS_IMAGE_FILL (3), NO_IMAGE_FILL (4)
Help: This procedure fills the specified drawable with the fill mode. If the fill mode is foreground, the current foreground color is used. If the fill mode is background, the current background color is used. Other fill modes should not be used. This procedure only affects regions within a selection if there is a selection active.

 

Thus, if a selection is active when gimp_edit_fill is called only the selection is painted. There are lots of ways of choosing a selection as can be seen when searching for a ``select'' in the PDB. The example below uses gimp_rect_select, whose entry in the PDB looks as follows:

 

Name: gimp_rect_select
Blurb: Create a rectangular selection over the specified image
In: IMAGE image The image
  FLOAT x x coordinate of upper-left corner of rectangle
  FLOAT y y coordinate of upper-left corner of rectangle
  FLOAT width the width of the rectangle: width > 0
  FLOAT height the height of the rectangle: width > 0
  INT32 operation the selection operation: {ADD (0), SUB(1), REPLACE (2), INTERSECT (3) }
  INT32 feather feather option for selections
  FLOAT feather_radius radius for feather operation
Help: This tool creates a rectangular selection over the specified image. The rectangular region can be either added to, subtracted from, or replace the contents of the previous selection mask. If the feather option is enabled, the resulting selection is blurred before combining. The blur is a gaussian blur with the specified feather radius.

A simple use of this function which selects a rectangle in the middle of an image and paints that rectangle with a user defined color. This example also introduces a couple of new features we haven't seen before:

  • The script is associated with an image since its menu path starts with "<Image>/...". Note that as a result of this the callback sub in line 13 receives two additional parameters, the active image and the seleced drawable.
  • The use of a subroutine without a name as a parameter to register
  • The use of the PDB functions gimp_undo_push_group_start and gimp_undo_push_group_end. These functions declare an undo group. When an undo is done on the image, instead of having the individual operators undo, all the actions between the undo start and the undo group calls will be undone at once.
  • The return type of the register function defines what new images should be displayed by gimp. In this case we don't want to display any new images and therefore return an empty array.

paint-select
  1:  #!/usr/local/bin/perl -w 
  2:   
  3:  use Gimp ":auto"; 
  4:  use Gimp::Fu; 
  5:   
  6:  register 
  7:      "img_paint_select", 
  8:      "Paints the selection", "Paints the selection", 
  9:      "Dov Grobgeld", "Dov Grobgeld", "1999-05-14",  
 10:      "<Image>/Perl-Fu/Tutorial/Paint Select",  
 11:      "*",  
 12:      [ 
 13:       [PF_COLOR, "color", "Rectangle color", [0,0,255]] ], 
 14:      sub { 
 15:          my($img, $layer, $color) = @_; 
 16:          my($width, $height) = (gimp_image_width($img), 
 17:                                 gimp_image_height($img)); 
 18:   
 19:          # Select a rectangle inside the image and paint it with color 
 20:          gimp_undo_push_group_start($img); 
 21:          gimp_rect_select($img, 
 22:                           $width/4, $height/4, $width/2, $height/2, 
 23:                           REPLACE, 0,0); 
 24:          gimp_palette_set_background($color); 
 25:          gimp_edit_fill($layer, BG_IMAGE_FILL); 
 26:          gimp_selection_none($img); 
 27:          gimp_displays_flush(); 
 28:          gimp_undo_push_group_end($img); 
 29:   
 30:  	# Tell gimp not to display a new image 
 31:  	return (); 
 32:      }; 
 33:   
 34:  exit main(); 


The result when run on our previous image:


6.1. Complex selections


Besides rectangular selections elliptical selections may also be created through the PDB functions gimp_ellipse_select() and gimp_free_select() which allows the selection of ellipses and polygons.

More complex selections may be created through the channel mechanism. The PDB gimp_channel_new() creates a new channel. The channel is a drawable that may be painted into, just like any other drawable, but with the difference that it is always a grey level image. Once the channel is finished, the channel may be loaded into the selection through the PDB function gimp_selection_load().

Search for ``select'' in the DB Browser to see a list of all the selection related functions.


6.2. Loops


In perl it is trivial to write loops that together with the various selecton tools gives powerful creative possibilities. Here is an example that mixes colors in circles. There is nothing really new here, but it shows the power of the what we have described above.
circles
  1:  #!/usr/local/bin/perl 
  2:   
  3:  use Gimp ":auto"; 
  4:  use Gimp::Fu; 
  5:   
  6:  sub circles { 
  7:      my ($size, $bgcolor, $radius) = @_; 
  8:      
  9:      # Create the background 
 10:      $img = gimp_image_new($size, $size, RGB); 
 11:      $layer = gimp_layer_new($img, $size, $size, RGB, 
 12:                              "Layer 1", 100, NORMAL_MODE); 
 13:      gimp_image_add_layer($layer, -1); 
 14:      gimp_palette_set_background($bgcolor); 
 15:      gimp_edit_fill($layer, BG_IMAGE_FILL); 
 16:   
 17:      my $ncircles = int($size/$radius/2); 
 18:       
 19:      for ($i=0; $i<$ncircles; $i++) { 
 20:          for ($j=0; $j<$ncircles; $j++) { 
 21:              # Be creative and mix colors 
 22:              $color = [$i*30, ($ncircles-$j)*25, ($i+$j)*15]; 
 23:   
 24:              # Select a circle 
 25:              gimp_ellipse_select($img, 
 26:                                  $i*$radius*2, $j*$radius*2, 
 27:                                  $radius*2, $radius*2, 
 28:                                  REPLACE, 1, 0, 0); 
 29:   
 30:              # Paint the color in the circle 
 31:              gimp_palette_set_background($color); 
 32:              gimp_edit_fill($layer, BG_IMAGE_FILL); 
 33:              gimp_selection_none($img); 
 34:          } 
 35:      } 
 36:   
 37:      return $img; 
 38:  } 
 39:   
 40:  # register the script 
 41:  register "circles", "a loop", "a loop", "Dov", "Dov", "1999-05-14", 
 42:      "<Toolbox>/Xtns/Perl-Fu/Tutorial/Circles",  
 43:      "*", 
 44:      [ 
 45:       [PF_INT32, "size", "Img size", 100], 
 46:       [PF_COLOR, "bg", "Background color", [40,180,60]], 
 47:       [PF_INT32, "radius", "Circle radius", 10] 
 48:      ], 
 49:      \&circles; 
 50:   
 51:  exit main(); 


The result:




Be the first one to comment on this page.




  Gimp Tutorial eBooks

No eBooks on Gimp could be found as of now.

 
 Gimp Tutorial FAQs
More Links » »
 
 Gimp Tutorial Interview Questions

No Gimp Interview Questions could be found as of now.

 
 Gimp Tutorial Articles

No Gimp Articles could be found as of now.

 
 Gimp Tutorial News

No News on Gimp could be found as of now.

 
 Gimp Tutorial Jobs

No Gimp Articles could be found as of now.


Share And Enjoy:These icons link to social bookmarking sites where readers can share and discover new web pages.
  • blinkbits
  • BlinkList
  • blogmarks
  • co.mments
  • connotea
  • del.icio.us
  • De.lirio.us
  • digg
  • Fark
  • feedmelinks
  • Furl
  • LinkaGoGo
  • Ma.gnolia
  • NewsVine
  • Netvouz
  • RawSugar
  • Reddit
  • scuttle
  • Shadows
  • Simpy
  • Smarking
  • Spurl
  • TailRank
  • Wists
  • YahooMyWeb

Previoushome Next

Keywords: Painting areas with selections, GIMP Tutorial, GIMP tutorial pdf, history of GIMP, basic GIMP, syntax use in GIMP, GIMP training courses, GIMP Download.

HTML Quizzes
HTML Quiz
XHTML Quiz
CSS Quiz
TCP/IP Quiz
CSS 1.0 Quiz
CSS 2.0 Quiz
HLML Quiz
XML Quizzes
XML Quiz
XSL Quiz
XSLT Quiz
DTD Quiz
Schema Quiz
XForms Quiz
XSL-FO Quiz
XML DOM Quiz
XLink Quiz
XQuery Quiz
XPath Quiz
XPointer Quiz
RDF Quiz
SOAP Quiz
WSDL Quiz
RSS Quiz
WAP Quiz
Web Services Quiz
Browser Scripting Quizzes
JavaScript Quiz
VBScript Quiz
DHTML Quiz
HTML DOM Quiz
WMLScript Quiz
E4X Quiz
Server Scripting Quizzes
ASP Quiz
PERL Quiz
SQL Quiz
ADO Quiz
CVS Quiz
Python Quiz
Apple Script Quiz
PL/SQL Quiz
SQL Server Quiz
PHP Quiz
.NET (dotnet) Quizzes
Microsoft.Net Quiz
ASP.Net Quiz
.Net Mobile Quiz
C# : C Sharp Quiz
ADO.NET Quiz
VB.NET Quiz
VC++ Quiz
Multimedia Quizzes
SVG Quiz
Flash Quiz
Media Quiz
SMIL Quiz
Photoshop Quiz
Gimp Quiz
Matlab Quiz
Gnuplot Programming Quiz
GIF Animation Quiz
Scientific Visualization Quiz
Graphics Quiz
Web Building Quizzes
Web Browsers Quiz
Web Hosting Quiz
W3C Quiz
Web Building Quiz
Web Quality Quiz
Web Semantic Quiz
Web Careers Quiz
Weblogic Quiz
SEO Quiz
Web Site Hosting Quiz
Domain Name Quiz
Java Quizzes
Java Quiz
JSP Quiz
Servlets Quiz
Struts Quiz
EJB Quiz
JMS Quiz
JMX Quiz
Eclipse Quiz
J2ME Quiz
JBOSS Quiz
Programming Langauges Quizzes
C Quiz
C++ Quiz
Visual Basic Quiz
Data Structures Using C Quiz
Cobol Quiz
Assembly Language Quiz
Mainframe Quiz
Forth Programming Quiz
Lisp Programming Quiz
Pascal Quiz
Delphi Quiz
Fortran Quiz
OOPs Quiz
Data Warehousing Quiz
CGI Programming Quiz
Emacs Quiz
Gnome Quiz
ILU Quiz
Soft Skills Quizzes
Communication Skills Quiz
Time Management Quiz
Project Management Quiz
Team Work Quiz
Leadership Skills Quiz
Corporate Communication Quiz
Negotiation Skills Quiz
Database Quizzes
Oracle Quiz
MySQL Quiz
Operating System Quizzes
BSD Quiz
Symbian Quiz
Unix Quiz
Internet Quiz
IP-Masquerading Quiz
IPC Quiz
MIDI Quiz
Software Testing Quizzes
Testing Quiz
Firewalls Quiz
SAP Module Quizzes
ERP Quiz
ABAP Quiz
Business Warehousing Quiz
SAP Basis Quiz
Material Management Quiz
Sales & Distribution Quiz
Human Resource Quiz
Netweaver Quiz
Customer Relationship Management Quiz
Production and Planning Quiz
Networking Programming Quizzes
Corba Quiz
Networking Quiz
Microsoft Office Quizzes
Microsoft Word Quiz
Microsoft Outlook Quiz
Microsoft PowerPoint Quiz
Microsoft Publisher Quiz
Microsoft Excel Quiz
Microsoft Front Page Quiz
Microsoft InfoPath Quiz
Microsoft Access Quiz
Accounting Quizzes
Financial Accounting Quiz
Managerial Accounting Quiz
Testimonials | Contact Us | Link to Us | Site Map
Copyright 2008. Academic Tutorials.com. All rights reserved Privacy Policies | About Us
Our Portals : Academic Tutorials | Best eBooksworld | Beyond Stats | City Details | Interview Questions | Discussions World | Excellent Mobiles | Free Bangalore | Give Me The Code | Gog Logo | Indian Free Ads | Jobs Assist | New Interview Questions | One Stop FAQs | One Stop GATE | One Stop GRE | One Stop IAS | One Stop MBA | One Stop SAP | One Stop Testing | Webhosting in India | Dedicated Server in India | Sirf Dosti | Source Codes World | Tasty Food | Tech Archive | Testing Interview Questions | Tests World | The Galz | Top Masala | Vyom | Vyom eBooks | Vyom International | Vyom Links | Vyoms | Vyom World
Copyright 2003-2017 Vyom Technosoft Pvt. Ltd., All Rights Reserved.