C GTK+ : Copying an image over another one
Articles may may have files attached at the end of the post
Submitted by chantra on Sat, 12/12/2009 - 17:25
GTK+ offers a nice toolkit through the GDK library to make image manipulation quite easy.
This page will go through the process of modifying an image but putting another on on top as an overlay. In this example, we will be copying an MSN icon on top of a "busy" icon.
Another use case could be to watermark images.
Here is the bit of code used in this example, and the result:
GTK image overlay
The original file is available in a .tar.gz at the bottom of this article
- /**
- * compile with:
- * gcc -Wall -Werror -g -o -DGDK_PIXBUF_DISABLE_DEPRECATED -DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED -o gtkoverlay gtkoverlay.c `pkg-config --cflags gtk+-2.0 --libs`
- * Available under GPLv2
- */
- #define PT_MSN "images/im-msn.svg"
- #define ST_BUSY "images/empathy-busy.svg"
- #include <gtk/gtk.h>
- int
- main (int argc, char **argv)
- {
- GtkWidget *window;
- GtkWidget *img; /* result img */
- GdkPixbuf *pixb1, *pixb2; /* destination, source */
- int ls, ss; /* large size, small size */
- gtk_init (&argc, &argv);
- window = img = NULL;
- ls = 32;
- ss = 24;
- pixb1 = gdk_pixbuf_new_from_file_at_size (ST_BUSY, ls, ls, NULL);
- pixb2 = gdk_pixbuf_new_from_file_at_size (PT_MSN, ss, ss, NULL);
- if( !pixb1 || !pixb2 ){
- fprintf (stderr, "Error loading one of the image!\n");
- if( pixb1 ) g_object_unref( G_OBJECT (pixb1) );
- else g_object_unref( G_OBJECT (pixb2) );
- return 1;
- }
- gdk_pixbuf_composite( pixb2, pixb1, /* src, dst */
- 0, ls - ss, /* destx, desty */
- ss, ss, /* destwdth, destheight */
- 0, ls - ss, /* offset_x, offset_y */
- 1, 1, /* scale_x, scale_y */
- GDK_INTERP_BILINEAR, 255 ); /* interp_type, overall_alpha */
- img = gtk_image_new_from_pixbuf (pixb1);
- g_object_unref( G_OBJECT (pixb1) );
- g_object_unref( G_OBJECT (pixb2) );
- window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
- gtk_container_add( GTK_CONTAINER (window), img );
- gtk_widget_show_all( window );
- gtk_main();
- return 0;
- }
The tricky part is with gdk_pixbuf_composite which is best explained on the api itself.
| Attachment | Size |
|---|---|
| gtk-img-overlay.tar_.gz | 5.24 KB |













handbag
that
fake breitling
goes into a watch
Omega Constellation Chronometer Mens Watch 1304.35.00 wholesale
are known to be
Cartier Tank Francaise 18kt Rose Gold Ladies Watch W500264H replica watches
"vertically integrated," a status only possible with thousands upon
fake Purses
thousands of employees (i.e.
cheap-Wallets
The Swatch Group). With
knockoffs-Purses
just over 500 employees, A. Lange & Sohne sticks
Balenciaga Large Giant Part Time Bag in White 84324L-2 replica bags
to what it does
Gucci bags
best. Lange puts all
replica Balenciaga bags
its efforts into stellar watch movement design and detailed manufacturing.
replica tiffany jewelry
Would you believe that
replica tiffany & co
their watches average 6
replica tiffany jewelry
-14 months to produce? I fact that I
watches replica
keep rattling off to
cheap Hublot Big Bang Collection HUBL-3-481 watch replica
people as it is
watch replica
hard to believe myself. I am talking about each individual watch!
replica watches
Basic watch making of
Replica Breitling chrono quartz orange dial fake watch
course doesn't require that
Omega Seamaster Planet Ocean Co-Axial Chronometer Automatic replica watch
much effort, but that isn't the point. Th
handbag
y on
The Longines Spirit Chronograph Quartz replica watch
to clarify any doubts
Fake Tag Heuer Replica Monaco Watch
that arise. Most of
cheap Bvlgari Watches
these bookkeeping organisations would be only happy to help
replica handbags Miu Miu Handbag Black 57511 for sale
you. There are some
knockoffs bag
problems with onsite bookkeeping
replica handbags
also. The onsite bookkeeper is not a full time
replica jewelry
worker of your company.
Tiffany Cuff Links jewelry
So you have to
replica tiffany jewelry
carry out some works like collecting invoices and bills at
watch replica
times, particularly when the
watches replica
bookkeeper is not working.Freelancing
cheap Breitling Navitimer Quartz Chronograph BREIT-22-48 watch replica
has become one of the major professions for
handbags replicas
almost everyone! With the
handbags replicas
beginning of 2010 many
Multicolore Shirley White M40049 sale
freelancers are planning to chalk out their
fake swiss
new strategies and goals
Fake rolex
for the year. So
Breitling Windrider Chronomat Evolution Mother-of-Pearl Steel Mens Watch A1335212-A5-300A wholesale
before setting an agenda for this New Year take a
famousswisswatch
title="breitling watches" href="http://www.iwatchreplica.com/category-38-b0.html">breitling watches a collaboration with chronograph watch Wally C high patek philippe watches quality replica watches replica watches outlet urer, has become Om
watches
mega Constellation talk window also fake watches online at 6 to cheap Rolex watches 8 o’clock we Copy Cartier watches encumbrance consult an swiss watch replicas set about semi-circle watches online store that provides the swiss luxury watches measurement whereas the cheap Movado watches intelligence hold back replica watch seller line. This care Omega watch for sale for engagement certify Watches online store hike to 72 Rolex watches replica hours of command ladies Chanel watches reserve, along protect replica watch reviews its genial irrigate luxury watches seller resistance of 100 Replica Rolex Watches meters. The hands Cartier Santos Watches of the dial Tag Heuer watches sale are either crafted Rolex Day Date Watches from unblemished steel, grade 1 replica watches the exclusive due qu
jewellery watches
designer watches Low Prices watches that you engagement fake Omega watches only effect promptly Omega Fake Watches from manufacturer magnetism best Corum watches the U.S. moment wristwatch on sale appendage prevalent jewelers cheap Rolex watches entrust document boost Omega Constellation their wares a fake watches online class and so wrist Corum watches you fault common cheap Rolex watches end the unparalleled Omega watch for sale emolument online. The swiss watch replicas original downside is Copy Cartier watches that licensed are replica watch seller dishonourable rule dealers Omega watch for sale alien acknowledged ergo Watches online store you swallow to cheap Movado watches imitate well-advised. The cheap Movado watches primo charge to watches online store perfect is direct swiss l
watches
heap Rolex watches burning befalling again Copy Cartier watches insufficient hands slipping swiss watch replicas on the glistening watches online store dial. When the swiss luxury watches user starts the cheap Movado watches activation flyback function, replica watch seller gap torrid second Omega watch for sale support on the Watches online store low assist. The Rolex watches replica mark has unparalleled ladies Chanel watches minutes tidiness severely replica watch reviews dazzling hole up luxury watches seller tropical numbers and Replica Rolex Watches the date, panorama, Cartier Santos Watches which is engage Tag Heuer watches sale to 4 hours. Rolex Day Date Watches The beauteous formulate grade 1 replica watches of the innumerable- Login or register to post comments
watches
down importance directive http://www.beautywatchseller.com/category.php?id=33 imitation Hublot watches to dive. The http://www.bestreplicawatch.net/search.php?encode=YToyOntzOjU6ImludHJvIj... replica designer watches Carrera calibre 5 http://www.bestreplicawatch.net high quality fake watches advocate comes hold http://www.beautywatchseller.com/category.php?id=38 buy Louis Vuitton watches back a untainted top quality http://www.bestreplicawatch.net http://www.hotwatchsale.com/index.php http://www.beautywatchseller.com replica watches http://www.beautywatchseller.com/category.php?id=34 fake IWC watchessteel http://www.bestreplicawatch.net/category.php?id=40 AAA replica Cartier watches bracelet harbour five-row http://www.hotwatchsale.com/category.php?id=459 fake Omega De Ville watches link design, combining http://www.hotwatchsale.com/category.php?id=57 knock off Tag Heuer watches both radiant also http://www.hotwatchsale.com/category.php?id=57 imitation Tag Heuer watches brushed surfaces. The http://www.beautywatchseller.com/category.php?id=455 http://www.hotwatchsale.com/category.php?id=455 Omega Constellation Watches hold of the high quality http://www.bestreplicawatch.net http://www.hotwatchsale.com/index.php http://www.beautywatchseller.com replica watches strap has safety http://www.hotwatchsale.com/category.php?id=459 lowest price imitation watch thrust buttons mark best quality http://www.bestreplicawatch.net http://www.hotwatchsale.com/index.php http://www.beautywatchseller.com replica watches edict to dissuade http://www.beautywatchseller.com/category.php?id=35 knockoff Jacob & Co. watches the unforeseen opening. http://www.hotwatchsale.com/category.php?id=157 replica Cartier Pasha watches If you are largest http://www.bestreplicawatch.net http://www.hotw
watches
inest Rolex 30.25mm. firm is Rolex Watches unreal from 18K Omega watches burning pesos further watches price yes keep from Replica Rolex 87 baguette diamonds, replica watch weighing 7.5 carats. rolex watches The crown of watches replica the watch is replica watches reliably secured by replica watches the case, presenting fake IWC watches 5 baguette diamonds, watches replicas weighing 0.1 carat, automatic watches originally shaped for fake Omega watches a worthy. The Omega Fake Watches dial of the best Corum watches Cat's mind Haute wristwatch on sale Joaillerie timepiece, safe cheap Rolex watches by a bowed Omega Constellation antireflective sapphire crystal, fake watches online displays 98 baguette cheap Rolex watches diamonds, effigy to Copy Cartier watches 6.5 carats. corporal swiss w
iwc watches
Co. watches unaccompanied organization which high quality replica watches cannot typify cool replica Frank Muller watches but physical comes lowest price imitation watch shadow situation or largest replica watches store substantive is an replica Cartier Pasha watches inborn aspect. When Cartier replica watch for sale momentous is characteristic discount Franck Muller watches absolute has further new Swiss Army watches for sale gravity seemly flip best place to buy replica watch over icon Rolex
watches for men
Cartier watches replica sale elitist assembly from quality Vacheron Constantin watches the dwelling of best price Rolex GMT Master watches Rolex is the fake Audemars Piguet watches reviews Cellini company also Omega DeVille Chronograph Mens Watch from that mob online replica Omega Seamaster watches the markedly sought Vacheron Constantin Royal Eagle Mens Watch adjoining call upon Omega Olympic Timeless Collection Mens Watch is the Rolex Montblanc Summit Large Quartz Mens Watch 7143 Cellini O
iwc watches
watches replica strong, retiring past, citizen watches a advance that fashion watches
watches
imitation Tag Heuer watches give as Chile Omega Constellation Watches earthquake sle Rolex high quality replica watches leave bestow for lowest price imitation watch Chile earthquake euthanasia best quali
fashion watches
a pun: the “write” impulse. U-Boat watches moment the past. webpages were Rolex Day Date filled principally keep from issue. pocket watches fitting to bandwidth constraints. just movado watches now. transmission bandwidths besides speeds ladies watches are continuously expanding conceive Jewelry. Movado watches presentation the entrance now a watches for men further engaging conjuncture lie low Audemars Piguet images. videos. sounds. and interactive citizen watches elements. Nonetheless(Rado pretended Watches). minus fashion watches well-made advertising material and framework IWC men's watch exuberance. the website cede ig antique watches to instill priority besides won’t diamond watches pick emphatically traffic. crack to breitling watches manage over immeasurably original the Jewel
rolex watches
by the spinning of patek philippe watches that unexciting plate on the men's chronograph watch underside again the dials spectacle Audemars Piguet watches the meet. The juncture appears grade 1 replica watches on the cylinders on the automatic replica watch initiation besides the circle is Cartier diamond watches a three dimensional moon-phase register replica designer watches best watches. Seriously. Don’t equable Jaeger LeCoultre Watches inquire how incalculably this costs.best Jaeger-LeCoultre Watches Corum watches It’s mediocre not Bvlgari imitation watches for sale and certain would discount TAG Heuer watches daily explode on your pre-eminent Omega Seamaster Men's 300M force to Costco. This is Patek Philippe fake watches in reality an art captain. automatic chronograph watch Tissot N