image_cmds.c 89 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751
  1. /* The GIMP -- an image manipulation program
  2. * Copyright (C) 1995-2000 Spencer Kimball and Peter Mattis
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17. */
  18. /* NOTE: This file is autogenerated by pdbgen.pl. */
  19. #include "config.h"
  20. #include "procedural_db.h"
  21. #include <string.h>
  22. #include "apptypes.h"
  23. #include "channel.h"
  24. #include "cursorutil.h"
  25. #include "drawable.h"
  26. #include "gdisplay.h"
  27. #include "gimage.h"
  28. #include "gimpimage.h"
  29. #include "layer.h"
  30. #include "layer_pvt.h"
  31. #include "libgimp/gimpintl.h"
  32. #include "libgimp/gimplimits.h"
  33. #include "libgimp/gimpmath.h"
  34. static ProcRecord image_list_proc;
  35. static ProcRecord image_new_proc;
  36. static ProcRecord image_resize_proc;
  37. static ProcRecord image_scale_proc;
  38. static ProcRecord image_delete_proc;
  39. static ProcRecord image_free_shadow_proc;
  40. static ProcRecord image_get_layers_proc;
  41. static ProcRecord image_get_channels_proc;
  42. static ProcRecord image_unset_active_channel_proc;
  43. static ProcRecord image_pick_correlate_layer_proc;
  44. static ProcRecord image_raise_layer_proc;
  45. static ProcRecord image_lower_layer_proc;
  46. static ProcRecord image_raise_layer_to_top_proc;
  47. static ProcRecord image_lower_layer_to_bottom_proc;
  48. static ProcRecord image_merge_visible_layers_proc;
  49. static ProcRecord image_merge_down_proc;
  50. static ProcRecord image_flatten_proc;
  51. static ProcRecord image_add_layer_proc;
  52. static ProcRecord image_remove_layer_proc;
  53. static ProcRecord image_add_layer_mask_proc;
  54. static ProcRecord image_remove_layer_mask_proc;
  55. static ProcRecord image_raise_channel_proc;
  56. static ProcRecord image_lower_channel_proc;
  57. static ProcRecord image_add_channel_proc;
  58. static ProcRecord image_remove_channel_proc;
  59. static ProcRecord image_active_drawable_proc;
  60. static ProcRecord image_base_type_proc;
  61. static ProcRecord image_get_cmap_proc;
  62. static ProcRecord image_set_cmap_proc;
  63. static ProcRecord image_undo_is_enabled_proc;
  64. static ProcRecord image_undo_enable_proc;
  65. static ProcRecord image_undo_disable_proc;
  66. static ProcRecord image_undo_freeze_proc;
  67. static ProcRecord image_undo_thaw_proc;
  68. static ProcRecord image_clean_all_proc;
  69. static ProcRecord image_floating_selection_proc;
  70. static ProcRecord image_floating_sel_attached_to_proc;
  71. static ProcRecord image_thumbnail_proc;
  72. static ProcRecord image_set_tattoo_state_proc;
  73. static ProcRecord image_get_tattoo_state_proc;
  74. static ProcRecord image_width_proc;
  75. static ProcRecord image_height_proc;
  76. static ProcRecord image_get_active_layer_proc;
  77. static ProcRecord image_set_active_layer_proc;
  78. static ProcRecord image_get_active_channel_proc;
  79. static ProcRecord image_set_active_channel_proc;
  80. static ProcRecord image_get_selection_proc;
  81. static ProcRecord image_get_component_active_proc;
  82. static ProcRecord image_set_component_active_proc;
  83. static ProcRecord image_get_component_visible_proc;
  84. static ProcRecord image_set_component_visible_proc;
  85. static ProcRecord image_get_filename_proc;
  86. static ProcRecord image_set_filename_proc;
  87. static ProcRecord image_get_resolution_proc;
  88. static ProcRecord image_set_resolution_proc;
  89. static ProcRecord image_get_unit_proc;
  90. static ProcRecord image_set_unit_proc;
  91. static ProcRecord image_get_layer_by_tattoo_proc;
  92. static ProcRecord image_get_channel_by_tattoo_proc;
  93. void
  94. register_image_procs (void)
  95. {
  96. procedural_db_register (&image_list_proc);
  97. procedural_db_register (&image_new_proc);
  98. procedural_db_register (&image_resize_proc);
  99. procedural_db_register (&image_scale_proc);
  100. procedural_db_register (&image_delete_proc);
  101. procedural_db_register (&image_free_shadow_proc);
  102. procedural_db_register (&image_get_layers_proc);
  103. procedural_db_register (&image_get_channels_proc);
  104. procedural_db_register (&image_unset_active_channel_proc);
  105. procedural_db_register (&image_pick_correlate_layer_proc);
  106. procedural_db_register (&image_raise_layer_proc);
  107. procedural_db_register (&image_lower_layer_proc);
  108. procedural_db_register (&image_raise_layer_to_top_proc);
  109. procedural_db_register (&image_lower_layer_to_bottom_proc);
  110. procedural_db_register (&image_merge_visible_layers_proc);
  111. procedural_db_register (&image_merge_down_proc);
  112. procedural_db_register (&image_flatten_proc);
  113. procedural_db_register (&image_add_layer_proc);
  114. procedural_db_register (&image_remove_layer_proc);
  115. procedural_db_register (&image_add_layer_mask_proc);
  116. procedural_db_register (&image_remove_layer_mask_proc);
  117. procedural_db_register (&image_raise_channel_proc);
  118. procedural_db_register (&image_lower_channel_proc);
  119. procedural_db_register (&image_add_channel_proc);
  120. procedural_db_register (&image_remove_channel_proc);
  121. procedural_db_register (&image_active_drawable_proc);
  122. procedural_db_register (&image_base_type_proc);
  123. procedural_db_register (&image_get_cmap_proc);
  124. procedural_db_register (&image_set_cmap_proc);
  125. procedural_db_register (&image_undo_is_enabled_proc);
  126. procedural_db_register (&image_undo_enable_proc);
  127. procedural_db_register (&image_undo_disable_proc);
  128. procedural_db_register (&image_undo_freeze_proc);
  129. procedural_db_register (&image_undo_thaw_proc);
  130. procedural_db_register (&image_clean_all_proc);
  131. procedural_db_register (&image_floating_selection_proc);
  132. procedural_db_register (&image_floating_sel_attached_to_proc);
  133. procedural_db_register (&image_thumbnail_proc);
  134. procedural_db_register (&image_set_tattoo_state_proc);
  135. procedural_db_register (&image_get_tattoo_state_proc);
  136. procedural_db_register (&image_width_proc);
  137. procedural_db_register (&image_height_proc);
  138. procedural_db_register (&image_get_active_layer_proc);
  139. procedural_db_register (&image_set_active_layer_proc);
  140. procedural_db_register (&image_get_active_channel_proc);
  141. procedural_db_register (&image_set_active_channel_proc);
  142. procedural_db_register (&image_get_selection_proc);
  143. procedural_db_register (&image_get_component_active_proc);
  144. procedural_db_register (&image_set_component_active_proc);
  145. procedural_db_register (&image_get_component_visible_proc);
  146. procedural_db_register (&image_set_component_visible_proc);
  147. procedural_db_register (&image_get_filename_proc);
  148. procedural_db_register (&image_set_filename_proc);
  149. procedural_db_register (&image_get_resolution_proc);
  150. procedural_db_register (&image_set_resolution_proc);
  151. procedural_db_register (&image_get_unit_proc);
  152. procedural_db_register (&image_set_unit_proc);
  153. procedural_db_register (&image_get_layer_by_tattoo_proc);
  154. procedural_db_register (&image_get_channel_by_tattoo_proc);
  155. }
  156. /* Yuup, this is somewhat unsmooth, to say the least */
  157. static void
  158. gimlist_cb (gpointer im,
  159. gpointer data)
  160. {
  161. GSList **l = (GSList **) data;
  162. *l = g_slist_prepend (*l, im);
  163. }
  164. static Argument *
  165. image_list_invoker (Argument *args)
  166. {
  167. Argument *return_args;
  168. gint32 num_images = 0;
  169. gint32 *image_ids = NULL;
  170. GSList *list = NULL;
  171. int i;
  172. gimage_foreach (gimlist_cb, &list);
  173. num_images = g_slist_length (list);
  174. if (num_images)
  175. {
  176. image_ids = g_new (gint32, num_images);
  177. for (i = 0; i < num_images; i++, list = list->next)
  178. image_ids[i] = pdb_image_to_id (GIMP_IMAGE (list->data));
  179. }
  180. return_args = procedural_db_return_args (&image_list_proc, TRUE);
  181. return_args[1].value.pdb_int = num_images;
  182. return_args[2].value.pdb_pointer = image_ids;
  183. return return_args;
  184. }
  185. static ProcArg image_list_outargs[] =
  186. {
  187. {
  188. PDB_INT32,
  189. "num_images",
  190. "The number of images currently open"
  191. },
  192. {
  193. PDB_INT32ARRAY,
  194. "image_ids",
  195. "The list of images currently open"
  196. }
  197. };
  198. static ProcRecord image_list_proc =
  199. {
  200. "gimp_image_list",
  201. "Returns the list of images currently open.",
  202. "This procedure returns the list of images currently open in the GIMP.",
  203. "Spencer Kimball & Peter Mattis",
  204. "Spencer Kimball & Peter Mattis",
  205. "1995-1996",
  206. PDB_INTERNAL,
  207. 0,
  208. NULL,
  209. 2,
  210. image_list_outargs,
  211. { { image_list_invoker } }
  212. };
  213. static Argument *
  214. image_new_invoker (Argument *args)
  215. {
  216. gboolean success = TRUE;
  217. Argument *return_args;
  218. gint32 width;
  219. gint32 height;
  220. gint32 type;
  221. GimpImage *gimage = NULL;
  222. width = args[0].value.pdb_int;
  223. if (width <= 0)
  224. success = FALSE;
  225. height = args[1].value.pdb_int;
  226. if (height <= 0)
  227. success = FALSE;
  228. type = args[2].value.pdb_int;
  229. if (type < RGB || type > INDEXED)
  230. success = FALSE;
  231. if (success)
  232. success = (gimage = gimage_new (width, height, type)) != NULL;
  233. return_args = procedural_db_return_args (&image_new_proc, success);
  234. if (success)
  235. return_args[1].value.pdb_int = pdb_image_to_id (gimage);
  236. return return_args;
  237. }
  238. static ProcArg image_new_inargs[] =
  239. {
  240. {
  241. PDB_INT32,
  242. "width",
  243. "The width of the image"
  244. },
  245. {
  246. PDB_INT32,
  247. "height",
  248. "The height of the image"
  249. },
  250. {
  251. PDB_INT32,
  252. "type",
  253. "The type of image: { RGB (0), GRAY (1), INDEXED (2) }"
  254. }
  255. };
  256. static ProcArg image_new_outargs[] =
  257. {
  258. {
  259. PDB_IMAGE,
  260. "image",
  261. "The ID of the newly created image"
  262. }
  263. };
  264. static ProcRecord image_new_proc =
  265. {
  266. "gimp_image_new",
  267. "Creates a new image with the specified width, height, and type.",
  268. "Creates a new image, undisplayed with the specified extents and type. A layer should be created and added before this image is displayed, or subsequent calls to 'gimp_display_new' with this image as an argument will fail. Layers can be created using the 'gimp_layer_new' commands. They can be added to an image using the 'gimp_image_add_layer' command.",
  269. "Spencer Kimball & Peter Mattis",
  270. "Spencer Kimball & Peter Mattis",
  271. "1995-1996",
  272. PDB_INTERNAL,
  273. 3,
  274. image_new_inargs,
  275. 1,
  276. image_new_outargs,
  277. { { image_new_invoker } }
  278. };
  279. static Argument *
  280. image_resize_invoker (Argument *args)
  281. {
  282. gboolean success = TRUE;
  283. GimpImage *gimage;
  284. gint32 new_width;
  285. gint32 new_height;
  286. gint32 offx;
  287. gint32 offy;
  288. gimage = pdb_id_to_image (args[0].value.pdb_int);
  289. if (gimage == NULL)
  290. success = FALSE;
  291. new_width = args[1].value.pdb_int;
  292. if (new_width <= 0)
  293. success = FALSE;
  294. new_height = args[2].value.pdb_int;
  295. if (new_height <= 0)
  296. success = FALSE;
  297. offx = args[3].value.pdb_int;
  298. offy = args[4].value.pdb_int;
  299. if (success)
  300. {
  301. gimp_add_busy_cursors_until_idle ();
  302. gimage_resize (gimage, new_width, new_height, offx, offy);
  303. }
  304. return procedural_db_return_args (&image_resize_proc, success);
  305. }
  306. static ProcArg image_resize_inargs[] =
  307. {
  308. {
  309. PDB_IMAGE,
  310. "image",
  311. "The image"
  312. },
  313. {
  314. PDB_INT32,
  315. "new_width",
  316. "New image width: 0 < new_width"
  317. },
  318. {
  319. PDB_INT32,
  320. "new_height",
  321. "New image height: 0 < new_height"
  322. },
  323. {
  324. PDB_INT32,
  325. "offx",
  326. "x offset between upper left corner of old and new images: (new - old)"
  327. },
  328. {
  329. PDB_INT32,
  330. "offy",
  331. "y offset between upper left corner of old and new images: (new - old)"
  332. }
  333. };
  334. static ProcRecord image_resize_proc =
  335. {
  336. "gimp_image_resize",
  337. "Resize the image to the specified extents.",
  338. "This procedure resizes the image so that it's new width and height are equal to the supplied parameters. Offsets are also provided which describe the position of the previous image's content. No bounds checking is currently provided, so don't supply parameters that are out of bounds. All channels within the image are resized according to the specified parameters; this includes the image selection mask. All layers within the image are repositioned according to the specified offsets.",
  339. "Spencer Kimball & Peter Mattis",
  340. "Spencer Kimball & Peter Mattis",
  341. "1995-1996",
  342. PDB_INTERNAL,
  343. 5,
  344. image_resize_inargs,
  345. 0,
  346. NULL,
  347. { { image_resize_invoker } }
  348. };
  349. static Argument *
  350. image_scale_invoker (Argument *args)
  351. {
  352. gboolean success = TRUE;
  353. GimpImage *gimage;
  354. gint32 new_width;
  355. gint32 new_height;
  356. gimage = pdb_id_to_image (args[0].value.pdb_int);
  357. if (gimage == NULL)
  358. success = FALSE;
  359. new_width = args[1].value.pdb_int;
  360. if (new_width <= 0)
  361. success = FALSE;
  362. new_height = args[2].value.pdb_int;
  363. if (new_height <= 0)
  364. success = FALSE;
  365. if (success)
  366. {
  367. gimp_add_busy_cursors_until_idle ();
  368. gimage_scale (gimage, new_width, new_height);
  369. }
  370. return procedural_db_return_args (&image_scale_proc, success);
  371. }
  372. static ProcArg image_scale_inargs[] =
  373. {
  374. {
  375. PDB_IMAGE,
  376. "image",
  377. "The image"
  378. },
  379. {
  380. PDB_INT32,
  381. "new_width",
  382. "New image width: 0 < new_width"
  383. },
  384. {
  385. PDB_INT32,
  386. "new_height",
  387. "New image height: 0 < new_height"
  388. }
  389. };
  390. static ProcRecord image_scale_proc =
  391. {
  392. "gimp_image_scale",
  393. "Scale the image to the specified extents.",
  394. "This procedure scales the image so that it's new width and height are equal to the supplied parameters. Offsets are also provided which describe the position of the previous image's content. No bounds checking is currently provided, so don't supply parameters that are out of bounds. All channels within the image are scaled according to the specified parameters; this includes the image selection mask. All layers within the image are repositioned according to the specified offsets.",
  395. "Spencer Kimball & Peter Mattis",
  396. "Spencer Kimball & Peter Mattis",
  397. "1995-1996",
  398. PDB_INTERNAL,
  399. 3,
  400. image_scale_inargs,
  401. 0,
  402. NULL,
  403. { { image_scale_invoker } }
  404. };
  405. static Argument *
  406. image_delete_invoker (Argument *args)
  407. {
  408. gboolean success = TRUE;
  409. GimpImage *gimage;
  410. gimage = pdb_id_to_image (args[0].value.pdb_int);
  411. if (gimage == NULL)
  412. success = FALSE;
  413. if (success)
  414. gimage_delete (gimage);
  415. return procedural_db_return_args (&image_delete_proc, success);
  416. }
  417. static ProcArg image_delete_inargs[] =
  418. {
  419. {
  420. PDB_IMAGE,
  421. "image",
  422. "The image"
  423. }
  424. };
  425. static ProcRecord image_delete_proc =
  426. {
  427. "gimp_image_delete",
  428. "Delete the specified image.",
  429. "If there are no displays associated with this image it will be deleted. This means that you can not delete an image through the PDB that was created by the user. If the associated display was however created through the PDB and you know the display ID, you may delete the display. Removal of the last associated display will then delete the image.",
  430. "Spencer Kimball & Peter Mattis",
  431. "Spencer Kimball & Peter Mattis",
  432. "1995-1996",
  433. PDB_INTERNAL,
  434. 1,
  435. image_delete_inargs,
  436. 0,
  437. NULL,
  438. { { image_delete_invoker } }
  439. };
  440. static Argument *
  441. image_free_shadow_invoker (Argument *args)
  442. {
  443. gboolean success = TRUE;
  444. GimpImage *gimage;
  445. gimage = pdb_id_to_image (args[0].value.pdb_int);
  446. if (gimage == NULL)
  447. success = FALSE;
  448. if (success)
  449. gimage_free_shadow (gimage);
  450. return procedural_db_return_args (&image_free_shadow_proc, success);
  451. }
  452. static ProcArg image_free_shadow_inargs[] =
  453. {
  454. {
  455. PDB_IMAGE,
  456. "image",
  457. "The image"
  458. }
  459. };
  460. static ProcRecord image_free_shadow_proc =
  461. {
  462. "gimp_image_free_shadow",
  463. "Free the specified image's shadow data (if it exists).",
  464. "This procedure is intended as a memory saving device. If any shadow memory has been allocated, it will be freed automatically on a call to 'gimp_image_delete'.",
  465. "Spencer Kimball & Peter Mattis",
  466. "Spencer Kimball & Peter Mattis",
  467. "1995-1996",
  468. PDB_INTERNAL,
  469. 1,
  470. image_free_shadow_inargs,
  471. 0,
  472. NULL,
  473. { { image_free_shadow_invoker } }
  474. };
  475. static Argument *
  476. image_get_layers_invoker (Argument *args)
  477. {
  478. gboolean success = TRUE;
  479. Argument *return_args;
  480. GimpImage *gimage;
  481. gint32 num_layers = 0;
  482. gint32 *layer_ids = NULL;
  483. GSList *list = NULL;
  484. int i;
  485. gimage = pdb_id_to_image (args[0].value.pdb_int);
  486. if (gimage == NULL)
  487. success = FALSE;
  488. if (success)
  489. {
  490. list = gimage->layers;
  491. num_layers = g_slist_length (list);
  492. if (num_layers)
  493. {
  494. layer_ids = g_new (gint32, num_layers);
  495. for (i = 0; i < num_layers; i++, list = list->next)
  496. layer_ids[i] = drawable_ID (GIMP_DRAWABLE (list->data));
  497. }
  498. }
  499. return_args = procedural_db_return_args (&image_get_layers_proc, success);
  500. if (success)
  501. {
  502. return_args[1].value.pdb_int = num_layers;
  503. return_args[2].value.pdb_pointer = layer_ids;
  504. }
  505. return return_args;
  506. }
  507. static ProcArg image_get_layers_inargs[] =
  508. {
  509. {
  510. PDB_IMAGE,
  511. "image",
  512. "The image"
  513. }
  514. };
  515. static ProcArg image_get_layers_outargs[] =
  516. {
  517. {
  518. PDB_INT32,
  519. "num_layers",
  520. "The number of layers contained in the image"
  521. },
  522. {
  523. PDB_INT32ARRAY,
  524. "layer_ids",
  525. "The list of layers contained in the image"
  526. }
  527. };
  528. static ProcRecord image_get_layers_proc =
  529. {
  530. "gimp_image_get_layers",
  531. "Returns the list of layers contained in the specified image.",
  532. "This procedure returns the list of layers contained in the specified image. The order of layers is from topmost to bottommost.",
  533. "Spencer Kimball & Peter Mattis",
  534. "Spencer Kimball & Peter Mattis",
  535. "1995-1996",
  536. PDB_INTERNAL,
  537. 1,
  538. image_get_layers_inargs,
  539. 2,
  540. image_get_layers_outargs,
  541. { { image_get_layers_invoker } }
  542. };
  543. static Argument *
  544. image_get_channels_invoker (Argument *args)
  545. {
  546. gboolean success = TRUE;
  547. Argument *return_args;
  548. GimpImage *gimage;
  549. gint32 num_channels = 0;
  550. gint32 *channel_ids = NULL;
  551. GSList *list = NULL;
  552. int i;
  553. gimage = pdb_id_to_image (args[0].value.pdb_int);
  554. if (gimage == NULL)
  555. success = FALSE;
  556. if (success)
  557. {
  558. list = gimage->channels;
  559. num_channels = g_slist_length (list);
  560. if (num_channels)
  561. {
  562. channel_ids = g_new (gint32, num_channels);
  563. for (i = 0; i < num_channels; i++, list = list->next)
  564. channel_ids[i] = drawable_ID (GIMP_DRAWABLE (list->data));
  565. }
  566. }
  567. return_args = procedural_db_return_args (&image_get_channels_proc, success);
  568. if (success)
  569. {
  570. return_args[1].value.pdb_int = num_channels;
  571. return_args[2].value.pdb_pointer = channel_ids;
  572. }
  573. return return_args;
  574. }
  575. static ProcArg image_get_channels_inargs[] =
  576. {
  577. {
  578. PDB_IMAGE,
  579. "image",
  580. "The image"
  581. }
  582. };
  583. static ProcArg image_get_channels_outargs[] =
  584. {
  585. {
  586. PDB_INT32,
  587. "num_channels",
  588. "The number of channels contained in the image"
  589. },
  590. {
  591. PDB_INT32ARRAY,
  592. "channel_ids",
  593. "The list of channels contained in the image"
  594. }
  595. };
  596. static ProcRecord image_get_channels_proc =
  597. {
  598. "gimp_image_get_channels",
  599. "Returns the list of channels contained in the specified image.",
  600. "This procedure returns the list of channels contained in the specified image. This does not include the selection mask, or layer masks. The order is from topmost to bottommost.",
  601. "Spencer Kimball & Peter Mattis",
  602. "Spencer Kimball & Peter Mattis",
  603. "1995-1996",
  604. PDB_INTERNAL,
  605. 1,
  606. image_get_channels_inargs,
  607. 2,
  608. image_get_channels_outargs,
  609. { { image_get_channels_invoker } }
  610. };
  611. static Argument *
  612. image_unset_active_channel_invoker (Argument *args)
  613. {
  614. gboolean success = TRUE;
  615. GimpImage *gimage;
  616. gimage = pdb_id_to_image (args[0].value.pdb_int);
  617. if (gimage == NULL)
  618. success = FALSE;
  619. if (success)
  620. gimage_unset_active_channel (gimage);
  621. return procedural_db_return_args (&image_unset_active_channel_proc, success);
  622. }
  623. static ProcArg image_unset_active_channel_inargs[] =
  624. {
  625. {
  626. PDB_IMAGE,
  627. "image",
  628. "The image"
  629. }
  630. };
  631. static ProcRecord image_unset_active_channel_proc =
  632. {
  633. "gimp_image_unset_active_channel",
  634. "Unsets the active channel in the specified image.",
  635. "If an active channel exists, it is unset. There then exists no active channel, and if desired, one can be set through a call to 'Set Active Channel'. No error is returned in the case of no existing active channel.",
  636. "Spencer Kimball & Peter Mattis",
  637. "Spencer Kimball & Peter Mattis",
  638. "1995-1996",
  639. PDB_INTERNAL,
  640. 1,
  641. image_unset_active_channel_inargs,
  642. 0,
  643. NULL,
  644. { { image_unset_active_channel_invoker } }
  645. };
  646. static Argument *
  647. image_pick_correlate_layer_invoker (Argument *args)
  648. {
  649. gboolean success = TRUE;
  650. Argument *return_args;
  651. GimpImage *gimage;
  652. gint32 x;
  653. gint32 y;
  654. GimpLayer *layer = NULL;
  655. gimage = pdb_id_to_image (args[0].value.pdb_int);
  656. if (gimage == NULL)
  657. success = FALSE;
  658. x = args[1].value.pdb_int;
  659. y = args[2].value.pdb_int;
  660. if (success)
  661. layer = gimage_pick_correlate_layer (gimage, x, y);
  662. return_args = procedural_db_return_args (&image_pick_correlate_layer_proc, success);
  663. if (success)
  664. return_args[1].value.pdb_int = drawable_ID (GIMP_DRAWABLE (layer));
  665. return return_args;
  666. }
  667. static ProcArg image_pick_correlate_layer_inargs[] =
  668. {
  669. {
  670. PDB_IMAGE,
  671. "image",
  672. "The image"
  673. },
  674. {
  675. PDB_INT32,
  676. "x",
  677. "The x coordinate for the pick"
  678. },
  679. {
  680. PDB_INT32,
  681. "y",
  682. "The y coordinate for the pick"
  683. }
  684. };
  685. static ProcArg image_pick_correlate_layer_outargs[] =
  686. {
  687. {
  688. PDB_LAYER,
  689. "layer",
  690. "The layer found at the specified coordinates"
  691. }
  692. };
  693. static ProcRecord image_pick_correlate_layer_proc =
  694. {
  695. "gimp_image_pick_correlate_layer",
  696. "Find the layer visible at the specified coordinates.",
  697. "This procedure finds the layer which is visible at the specified coordinates. Layers which do not qualify are those whose extents do not pass within the specified coordinates, or which are transparent at the specified coordinates. This procedure will return -1 if no layer is found.",
  698. "Spencer Kimball & Peter Mattis",
  699. "Spencer Kimball & Peter Mattis",
  700. "1995-1996",
  701. PDB_INTERNAL,
  702. 3,
  703. image_pick_correlate_layer_inargs,
  704. 1,
  705. image_pick_correlate_layer_outargs,
  706. { { image_pick_correlate_layer_invoker } }
  707. };
  708. static Argument *
  709. image_raise_layer_invoker (Argument *args)
  710. {
  711. gboolean success = TRUE;
  712. GimpImage *gimage;
  713. GimpLayer *layer;
  714. gimage = pdb_id_to_image (args[0].value.pdb_int);
  715. if (gimage == NULL)
  716. success = FALSE;
  717. layer = layer_get_ID (args[1].value.pdb_int);
  718. if (layer == NULL)
  719. success = FALSE;
  720. if (success)
  721. success = gimage_raise_layer (gimage, layer) != NULL;
  722. return procedural_db_return_args (&image_raise_layer_proc, success);
  723. }
  724. static ProcArg image_raise_layer_inargs[] =
  725. {
  726. {
  727. PDB_IMAGE,
  728. "image",
  729. "The image"
  730. },
  731. {
  732. PDB_LAYER,
  733. "layer",
  734. "The layer to raise"
  735. }
  736. };
  737. static ProcRecord image_raise_layer_proc =
  738. {
  739. "gimp_image_raise_layer",
  740. "Raise the specified layer in the image's layer stack",
  741. "This procedure raises the specified layer one step in the existing layer stack. It will not move the layer if there is no layer above it, or the layer has no alpha channel.",
  742. "Spencer Kimball & Peter Mattis",
  743. "Spencer Kimball & Peter Mattis",
  744. "1995-1996",
  745. PDB_INTERNAL,
  746. 2,
  747. image_raise_layer_inargs,
  748. 0,
  749. NULL,
  750. { { image_raise_layer_invoker } }
  751. };
  752. static Argument *
  753. image_lower_layer_invoker (Argument *args)
  754. {
  755. gboolean success = TRUE;
  756. GimpImage *gimage;
  757. GimpLayer *layer;
  758. gimage = pdb_id_to_image (args[0].value.pdb_int);
  759. if (gimage == NULL)
  760. success = FALSE;
  761. layer = layer_get_ID (args[1].value.pdb_int);
  762. if (layer == NULL)
  763. success = FALSE;
  764. if (success)
  765. success = gimage_lower_layer (gimage, layer) != NULL;
  766. return procedural_db_return_args (&image_lower_layer_proc, success);
  767. }
  768. static ProcArg image_lower_layer_inargs[] =
  769. {
  770. {
  771. PDB_IMAGE,
  772. "image",
  773. "The image"
  774. },
  775. {
  776. PDB_LAYER,
  777. "layer",
  778. "The layer to lower"
  779. }
  780. };
  781. static ProcRecord image_lower_layer_proc =
  782. {
  783. "gimp_image_lower_layer",
  784. "Lower the specified layer in the image's layer stack",
  785. "This procedure lowers the specified layer one step in the existing layer stack. It will not move the layer if there is no layer below it, or the layer has no alpha channel.",
  786. "Spencer Kimball & Peter Mattis",
  787. "Spencer Kimball & Peter Mattis",
  788. "1995-1996",
  789. PDB_INTERNAL,
  790. 2,
  791. image_lower_layer_inargs,
  792. 0,
  793. NULL,
  794. { { image_lower_layer_invoker } }
  795. };
  796. static Argument *
  797. image_raise_layer_to_top_invoker (Argument *args)
  798. {
  799. gboolean success = TRUE;
  800. GimpImage *gimage;
  801. GimpLayer *layer;
  802. gimage = pdb_id_to_image (args[0].value.pdb_int);
  803. if (gimage == NULL)
  804. success = FALSE;
  805. layer = layer_get_ID (args[1].value.pdb_int);
  806. if (layer == NULL)
  807. success = FALSE;
  808. if (success)
  809. success = gimage_raise_layer_to_top (gimage, layer) != NULL;
  810. return procedural_db_return_args (&image_raise_layer_to_top_proc, success);
  811. }
  812. static ProcArg image_raise_layer_to_top_inargs[] =
  813. {
  814. {
  815. PDB_IMAGE,
  816. "image",
  817. "The image"
  818. },
  819. {
  820. PDB_LAYER,
  821. "layer",
  822. "The layer to raise to top"
  823. }
  824. };
  825. static ProcRecord image_raise_layer_to_top_proc =
  826. {
  827. "gimp_image_raise_layer_to_top",
  828. "Raise the specified layer in the image's layer stack to top of stack",
  829. "This procedure raises the specified layer to top of the existing layer stack. It will not move the layer if there is no layer above it, or the layer has no alpha channel.",
  830. "Wolfgang Hofer, Sven Neumann",
  831. "Wolfgang Hofer",
  832. "1998",
  833. PDB_INTERNAL,
  834. 2,
  835. image_raise_layer_to_top_inargs,
  836. 0,
  837. NULL,
  838. { { image_raise_layer_to_top_invoker } }
  839. };
  840. static Argument *
  841. image_lower_layer_to_bottom_invoker (Argument *args)
  842. {
  843. gboolean success = TRUE;
  844. GimpImage *gimage;
  845. GimpLayer *layer;
  846. gimage = pdb_id_to_image (args[0].value.pdb_int);
  847. if (gimage == NULL)
  848. success = FALSE;
  849. layer = layer_get_ID (args[1].value.pdb_int);
  850. if (layer == NULL)
  851. success = FALSE;
  852. if (success)
  853. success = gimage_lower_layer_to_bottom (gimage, layer) != NULL;
  854. return procedural_db_return_args (&image_lower_layer_to_bottom_proc, success);
  855. }
  856. static ProcArg image_lower_layer_to_bottom_inargs[] =
  857. {
  858. {
  859. PDB_IMAGE,
  860. "image",
  861. "The image"
  862. },
  863. {
  864. PDB_LAYER,
  865. "layer",
  866. "The layer to lower to bottom"
  867. }
  868. };
  869. static ProcRecord image_lower_layer_to_bottom_proc =
  870. {
  871. "gimp_image_lower_layer_to_bottom",
  872. "Lower the specified layer in the image's layer stack to bottom of stack",
  873. "This procedure lowers the specified layer to bottom of the existing layer stack. It will not move the layer if there is no layer below it, or the layer has no alpha channel.",
  874. "Wolfgang Hofer, Sven Neumann",
  875. "Wolfgang Hofer",
  876. "1998",
  877. PDB_INTERNAL,
  878. 2,
  879. image_lower_layer_to_bottom_inargs,
  880. 0,
  881. NULL,
  882. { { image_lower_layer_to_bottom_invoker } }
  883. };
  884. static Argument *
  885. image_merge_visible_layers_invoker (Argument *args)
  886. {
  887. gboolean success = TRUE;
  888. Argument *return_args;
  889. GimpImage *gimage;
  890. gint32 merge_type;
  891. GimpLayer *layer = NULL;
  892. gimage = pdb_id_to_image (args[0].value.pdb_int);
  893. if (gimage == NULL)
  894. success = FALSE;
  895. merge_type = args[1].value.pdb_int;
  896. if (merge_type < EXPAND_AS_NECESSARY || merge_type > CLIP_TO_BOTTOM_LAYER)
  897. success = FALSE;
  898. if (success)
  899. {
  900. layer = gimage_merge_visible_layers (gimage, merge_type);
  901. success = layer != NULL;
  902. }
  903. return_args = procedural_db_return_args (&image_merge_visible_layers_proc, success);
  904. if (success)
  905. return_args[1].value.pdb_int = drawable_ID (GIMP_DRAWABLE (layer));
  906. return return_args;
  907. }
  908. static ProcArg image_merge_visible_layers_inargs[] =
  909. {
  910. {
  911. PDB_IMAGE,
  912. "image",
  913. "The image"
  914. },
  915. {
  916. PDB_INT32,
  917. "merge_type",
  918. "The type of merge: { EXPAND_AS_NECESSARY (0), CLIP_TO_IMAGE (1), CLIP_TO_BOTTOM_LAYER (2) }"
  919. }
  920. };
  921. static ProcArg image_merge_visible_layers_outargs[] =
  922. {
  923. {
  924. PDB_LAYER,
  925. "layer",
  926. "The resulting layer"
  927. }
  928. };
  929. static ProcRecord image_merge_visible_layers_proc =
  930. {
  931. "gimp_image_merge_visible_layers",
  932. "Merge the visible image layers into one.",
  933. "This procedure combines the visible layers into a single layer using the specified merge type. A merge type of EXPAND_AS_NECESSARY expands the final layer to encompass the areas of the visible layers. A merge type of CLIP_TO_IMAGE clips the final layer to the extents of the image. A merge type of CLIP_TO_BOTTOM_LAYER clips the final layer to the size of the bottommost layer.",
  934. "Spencer Kimball & Peter Mattis",
  935. "Spencer Kimball & Peter Mattis",
  936. "1995-1996",
  937. PDB_INTERNAL,
  938. 2,
  939. image_merge_visible_layers_inargs,
  940. 1,
  941. image_merge_visible_layers_outargs,
  942. { { image_merge_visible_layers_invoker } }
  943. };
  944. static Argument *
  945. image_merge_down_invoker (Argument *args)
  946. {
  947. gboolean success = TRUE;
  948. Argument *return_args;
  949. GimpImage *gimage;
  950. GimpLayer *merge_layer;
  951. gint32 merge_type;
  952. GimpLayer *layer = NULL;
  953. gimage = pdb_id_to_image (args[0].value.pdb_int);
  954. if (gimage == NULL)
  955. success = FALSE;
  956. merge_layer = layer_get_ID (args[1].value.pdb_int);
  957. if (merge_layer == NULL)
  958. success = FALSE;
  959. merge_type = args[2].value.pdb_int;
  960. if (merge_type < EXPAND_AS_NECESSARY || merge_type > CLIP_TO_BOTTOM_LAYER)
  961. success = FALSE;
  962. if (success)
  963. {
  964. layer = gimp_image_merge_down (gimage, merge_layer, merge_type);
  965. success = layer != NULL;
  966. }
  967. return_args = procedural_db_return_args (&image_merge_down_proc, success);
  968. if (success)
  969. return_args[1].value.pdb_int = drawable_ID (GIMP_DRAWABLE (layer));
  970. return return_args;
  971. }
  972. static ProcArg image_merge_down_inargs[] =
  973. {
  974. {
  975. PDB_IMAGE,
  976. "image",
  977. "The image"
  978. },
  979. {
  980. PDB_LAYER,
  981. "merge_layer",
  982. "The layer to merge down from"
  983. },
  984. {
  985. PDB_INT32,
  986. "merge_type",
  987. "The type of merge: { EXPAND_AS_NECESSARY (0), CLIP_TO_IMAGE (1), CLIP_TO_BOTTOM_LAYER (2) }"
  988. }
  989. };
  990. static ProcArg image_merge_down_outargs[] =
  991. {
  992. {
  993. PDB_LAYER,
  994. "layer",
  995. "The resulting layer"
  996. }
  997. };
  998. static ProcRecord image_merge_down_proc =
  999. {
  1000. "gimp_image_merge_down",
  1001. "Merge the layer passed and the first visible layer below.",
  1002. "This procedure combines the passed layer and the first visible layer below it using the specified merge type. A merge type of EXPAND_AS_NECESSARY expands the final layer to encompass the areas of the visible layers. A merge type of CLIP_TO_IMAGE clips the final layer to the extents of the image. A merge type of CLIP_TO_BOTTOM_LAYER clips the final layer to the size of the bottommost layer.",
  1003. "Larry Ewing",
  1004. "Larry Ewing",
  1005. "1998",
  1006. PDB_INTERNAL,
  1007. 3,
  1008. image_merge_down_inargs,
  1009. 1,
  1010. image_merge_down_outargs,
  1011. { { image_merge_down_invoker } }
  1012. };
  1013. static Argument *
  1014. image_flatten_invoker (Argument *args)
  1015. {
  1016. gboolean success = TRUE;
  1017. Argument *return_args;
  1018. GimpImage *gimage;
  1019. GimpLayer *layer = NULL;
  1020. gimage = pdb_id_to_image (args[0].value.pdb_int);
  1021. if (gimage == NULL)
  1022. success = FALSE;
  1023. if (success)
  1024. success = (layer = gimage_flatten (gimage)) != NULL;
  1025. return_args = procedural_db_return_args (&image_flatten_proc, success);
  1026. if (success)
  1027. return_args[1].value.pdb_int = drawable_ID (GIMP_DRAWABLE (layer));
  1028. return return_args;
  1029. }
  1030. static ProcArg image_flatten_inargs[] =
  1031. {
  1032. {
  1033. PDB_IMAGE,
  1034. "image",
  1035. "The image"
  1036. }
  1037. };
  1038. static ProcArg image_flatten_outargs[] =
  1039. {
  1040. {
  1041. PDB_LAYER,
  1042. "layer",
  1043. "The resulting layer"
  1044. }
  1045. };
  1046. static ProcRecord image_flatten_proc =
  1047. {
  1048. "gimp_image_flatten",
  1049. "Flatten all visible layers into a single layer. Discard all invisible layers.",
  1050. "This procedure combines the visible layers in a manner analogous to merging with the CLIP_TO_IMAGE merge type. Non-visible layers are discarded, and the resulting image is stripped of its alpha channel.",
  1051. "Spencer Kimball & Peter Mattis",
  1052. "Spencer Kimball & Peter Mattis",
  1053. "1995-1996",
  1054. PDB_INTERNAL,
  1055. 1,
  1056. image_flatten_inargs,
  1057. 1,
  1058. image_flatten_outargs,
  1059. { { image_flatten_invoker } }
  1060. };
  1061. static Argument *
  1062. image_add_layer_invoker (Argument *args)
  1063. {
  1064. gboolean success = TRUE;
  1065. GimpImage *gimage;
  1066. GimpLayer *layer;
  1067. gint32 position;
  1068. gimage = pdb_id_to_image (args[0].value.pdb_int);
  1069. if (gimage == NULL)
  1070. success = FALSE;
  1071. layer = layer_get_ID (args[1].value.pdb_int);
  1072. if (layer == NULL)
  1073. success = FALSE;
  1074. position = args[2].value.pdb_int;
  1075. if (success)
  1076. {
  1077. if ((drawable_color (GIMP_DRAWABLE (layer)) && gimage_base_type (gimage) != RGB) ||
  1078. (drawable_gray (GIMP_DRAWABLE (layer)) && gimage_base_type (gimage) != GRAY) ||
  1079. (drawable_indexed (GIMP_DRAWABLE (layer)) && gimage_base_type (gimage) != INDEXED))
  1080. success = FALSE;
  1081. else
  1082. success = gimage_add_layer (gimage, layer, MAX (position, -1)) != NULL;
  1083. }
  1084. return procedural_db_return_args (&image_add_layer_proc, success);
  1085. }
  1086. static ProcArg image_add_layer_inargs[] =
  1087. {
  1088. {
  1089. PDB_IMAGE,
  1090. "image",
  1091. "The image"
  1092. },
  1093. {
  1094. PDB_LAYER,
  1095. "layer",
  1096. "The layer"
  1097. },
  1098. {
  1099. PDB_INT32,
  1100. "position",
  1101. "The layer position"
  1102. }
  1103. };
  1104. static ProcRecord image_add_layer_proc =
  1105. {
  1106. "gimp_image_add_layer",
  1107. "Add the specified layer to the image.",
  1108. "This procedure adds the specified layer to the gimage at the given position. If the position is specified as -1, then the layer is inserted at the top of the layer stack. If the layer to be added has no alpha channel, it must be added at position 0. The layer type must be compatible with the image base type.",
  1109. "Spencer Kimball & Peter Mattis",
  1110. "Spencer Kimball & Peter Mattis",
  1111. "1995-1996",
  1112. PDB_INTERNAL,
  1113. 3,
  1114. image_add_layer_inargs,
  1115. 0,
  1116. NULL,
  1117. { { image_add_layer_invoker } }
  1118. };
  1119. static Argument *
  1120. image_remove_layer_invoker (Argument *args)
  1121. {
  1122. gboolean success = TRUE;
  1123. GimpImage *gimage;
  1124. GimpLayer *layer;
  1125. gimage = pdb_id_to_image (args[0].value.pdb_int);
  1126. if (gimage == NULL)
  1127. success = FALSE;
  1128. layer = layer_get_ID (args[1].value.pdb_int);
  1129. if (layer == NULL)
  1130. success = FALSE;
  1131. if (success)
  1132. gimage_remove_layer (gimage, layer);
  1133. return procedural_db_return_args (&image_remove_layer_proc, success);
  1134. }
  1135. static ProcArg image_remove_layer_inargs[] =
  1136. {
  1137. {
  1138. PDB_IMAGE,
  1139. "image",
  1140. "The image"
  1141. },
  1142. {
  1143. PDB_LAYER,
  1144. "layer",
  1145. "The layer"
  1146. }
  1147. };
  1148. static ProcRecord image_remove_layer_proc =
  1149. {
  1150. "gimp_image_remove_layer",
  1151. "Remove the specified layer from the image.",
  1152. "This procedure removes the specified layer from the image. If the layer doesn't exist, an error is returned. If there are no layers left in the image, this call will fail. If this layer is the last layer remaining, the image will become empty and have no active layer.",
  1153. "Spencer Kimball & Peter Mattis",
  1154. "Spencer Kimball & Peter Mattis",
  1155. "1995-1996",
  1156. PDB_INTERNAL,
  1157. 2,
  1158. image_remove_layer_inargs,
  1159. 0,
  1160. NULL,
  1161. { { image_remove_layer_invoker } }
  1162. };
  1163. static Argument *
  1164. image_add_layer_mask_invoker (Argument *args)
  1165. {
  1166. gboolean success = TRUE;
  1167. GimpImage *gimage;
  1168. GimpLayer *layer;
  1169. LayerMask *mask;
  1170. gimage = pdb_id_to_image (args[0].value.pdb_int);
  1171. if (gimage == NULL)
  1172. success = FALSE;
  1173. layer = layer_get_ID (args[1].value.pdb_int);
  1174. if (layer == NULL)
  1175. success = FALSE;
  1176. mask = layer_mask_get_ID (args[2].value.pdb_int);
  1177. if (mask == NULL)
  1178. success = FALSE;
  1179. if (success)
  1180. success = gimage_add_layer_mask (gimage, layer, mask) != NULL;
  1181. return procedural_db_return_args (&image_add_layer_mask_proc, success);
  1182. }
  1183. static ProcArg image_add_layer_mask_inargs[] =
  1184. {
  1185. {
  1186. PDB_IMAGE,
  1187. "image",
  1188. "The image"
  1189. },
  1190. {
  1191. PDB_LAYER,
  1192. "layer",
  1193. "The layer to receive the mask"
  1194. },
  1195. {
  1196. PDB_CHANNEL,
  1197. "mask",
  1198. "The mask to add to the layer"
  1199. }
  1200. };
  1201. static ProcRecord image_add_layer_mask_proc =
  1202. {
  1203. "gimp_image_add_layer_mask",
  1204. "Add a layer mask to the specified layer.",
  1205. "This procedure adds a layer mask to the specified layer. Layer masks serve as an additional alpha channel for a layer. This procedure will fail if a number of prerequisites aren't met. The layer cannot already have a layer mask. The specified mask must exist and have the same dimensions as the layer. Both the mask and the layer must have been created for use with the specified image.",
  1206. "Spencer Kimball & Peter Mattis",
  1207. "Spencer Kimball & Peter Mattis",
  1208. "1995-1996",
  1209. PDB_INTERNAL,
  1210. 3,
  1211. image_add_layer_mask_inargs,
  1212. 0,
  1213. NULL,
  1214. { { image_add_layer_mask_invoker } }
  1215. };
  1216. static Argument *
  1217. image_remove_layer_mask_invoker (Argument *args)
  1218. {
  1219. gboolean success = TRUE;
  1220. GimpImage *gimage;
  1221. GimpLayer *layer;
  1222. gint32 mode;
  1223. gimage = pdb_id_to_image (args[0].value.pdb_int);
  1224. if (gimage == NULL)
  1225. success = FALSE;
  1226. layer = layer_get_ID (args[1].value.pdb_int);
  1227. if (layer == NULL)
  1228. success = FALSE;
  1229. mode = args[2].value.pdb_int;
  1230. if (mode < APPLY || mode > DISCARD)
  1231. success = FALSE;
  1232. if (success)
  1233. gimage_remove_layer_mask (gimage, layer, mode);
  1234. return procedural_db_return_args (&image_remove_layer_mask_proc, success);
  1235. }
  1236. static ProcArg image_remove_layer_mask_inargs[] =
  1237. {
  1238. {
  1239. PDB_IMAGE,
  1240. "image",
  1241. "The image"
  1242. },
  1243. {
  1244. PDB_LAYER,
  1245. "layer",
  1246. "The layer from which to remove mask"
  1247. },
  1248. {
  1249. PDB_INT32,
  1250. "mode",
  1251. "Removal mode: { APPLY (0), DISCARD (1) }"
  1252. }
  1253. };
  1254. static ProcRecord image_remove_layer_mask_proc =
  1255. {
  1256. "gimp_image_remove_layer_mask",
  1257. "Remove the specified layer mask from the layer.",
  1258. "This procedure removes the specified layer mask from the layer. If the mask doesn't exist, an error is returned.",
  1259. "Spencer Kimball & Peter Mattis",
  1260. "Spencer Kimball & Peter Mattis",
  1261. "1995-1996",
  1262. PDB_INTERNAL,
  1263. 3,
  1264. image_remove_layer_mask_inargs,
  1265. 0,
  1266. NULL,
  1267. { { image_remove_layer_mask_invoker } }
  1268. };
  1269. static Argument *
  1270. image_raise_channel_invoker (Argument *args)
  1271. {
  1272. gboolean success = TRUE;
  1273. GimpImage *gimage;
  1274. Channel *channel;
  1275. gimage = pdb_id_to_image (args[0].value.pdb_int);
  1276. if (gimage == NULL)
  1277. success = FALSE;
  1278. channel = channel_get_ID (args[1].value.pdb_int);
  1279. if (channel == NULL)
  1280. success = FALSE;
  1281. if (success)
  1282. success = gimage_raise_channel (gimage, channel) != NULL;
  1283. return procedural_db_return_args (&image_raise_channel_proc, success);
  1284. }
  1285. static ProcArg image_raise_channel_inargs[] =
  1286. {
  1287. {
  1288. PDB_IMAGE,
  1289. "image",
  1290. "The image"
  1291. },
  1292. {
  1293. PDB_CHANNEL,
  1294. "channel",
  1295. "The channel to raise"
  1296. }
  1297. };
  1298. static ProcRecord image_raise_channel_proc =
  1299. {
  1300. "gimp_image_raise_channel",
  1301. "Raise the specified channel in the image's channel stack",
  1302. "This procedure raises the specified channel one step in the existing channel stack. It will not move the channel if there is no channel above it.",
  1303. "Spencer Kimball & Peter Mattis",
  1304. "Spencer Kimball & Peter Mattis",
  1305. "1995-1996",
  1306. PDB_INTERNAL,
  1307. 2,
  1308. image_raise_channel_inargs,
  1309. 0,
  1310. NULL,
  1311. { { image_raise_channel_invoker } }
  1312. };
  1313. static Argument *
  1314. image_lower_channel_invoker (Argument *args)
  1315. {
  1316. gboolean success = TRUE;
  1317. GimpImage *gimage;
  1318. GimpLayer *layer;
  1319. gimage = pdb_id_to_image (args[0].value.pdb_int);
  1320. if (gimage == NULL)
  1321. success = FALSE;
  1322. layer = layer_get_ID (args[1].value.pdb_int);
  1323. if (layer == NULL)
  1324. success = FALSE;
  1325. if (success)
  1326. success = gimage_lower_layer (gimage, layer) != NULL;
  1327. return procedural_db_return_args (&image_lower_channel_proc, success);
  1328. }
  1329. static ProcArg image_lower_channel_inargs[] =
  1330. {
  1331. {
  1332. PDB_IMAGE,
  1333. "image",
  1334. "The image"
  1335. },
  1336. {
  1337. PDB_LAYER,
  1338. "layer",
  1339. "The layer to lower"
  1340. }
  1341. };
  1342. static ProcRecord image_lower_channel_proc =
  1343. {
  1344. "gimp_image_lower_channel",
  1345. "Lower the specified layer in the image's layer stack",
  1346. "This procedure lowers the specified layer one step in the existing layer stack. It will not move the layer if there is no layer below it, or the layer has no alpha channel.",
  1347. "Spencer Kimball & Peter Mattis",
  1348. "Spencer Kimball & Peter Mattis",
  1349. "1995-1996",
  1350. PDB_INTERNAL,
  1351. 2,
  1352. image_lower_channel_inargs,
  1353. 0,
  1354. NULL,
  1355. { { image_lower_channel_invoker } }
  1356. };
  1357. static Argument *
  1358. image_add_channel_invoker (Argument *args)
  1359. {
  1360. gboolean success = TRUE;
  1361. GimpImage *gimage;
  1362. Channel *channel;
  1363. gint32 position;
  1364. gimage = pdb_id_to_image (args[0].value.pdb_int);
  1365. if (gimage == NULL)
  1366. success = FALSE;
  1367. channel = channel_get_ID (args[1].value.pdb_int);
  1368. if (channel == NULL)
  1369. success = FALSE;
  1370. position = args[2].value.pdb_int;
  1371. if (success)
  1372. success = gimage_add_channel (gimage, channel, MAX (position, -1)) != NULL;
  1373. return procedural_db_return_args (&image_add_channel_proc, success);
  1374. }
  1375. static ProcArg image_add_channel_inargs[] =
  1376. {
  1377. {
  1378. PDB_IMAGE,
  1379. "image",
  1380. "The image"
  1381. },
  1382. {
  1383. PDB_CHANNEL,
  1384. "channel",
  1385. "The channel"
  1386. },
  1387. {
  1388. PDB_INT32,
  1389. "position",
  1390. "The channel position"
  1391. }
  1392. };
  1393. static ProcRecord image_add_channel_proc =
  1394. {
  1395. "gimp_image_add_channel",
  1396. "Add the specified channel to the image.",
  1397. "This procedure adds the specified channel to the image. The position channel is not currently used, so the channel is always inserted at the top of the channel stack.",
  1398. "Spencer Kimball & Peter Mattis",
  1399. "Spencer Kimball & Peter Mattis",
  1400. "1995-1996",
  1401. PDB_INTERNAL,
  1402. 3,
  1403. image_add_channel_inargs,
  1404. 0,
  1405. NULL,
  1406. { { image_add_channel_invoker } }
  1407. };
  1408. static Argument *
  1409. image_remove_channel_invoker (Argument *args)
  1410. {
  1411. gboolean success = TRUE;
  1412. GimpImage *gimage;
  1413. Channel *channel;
  1414. gimage = pdb_id_to_image (args[0].value.pdb_int);
  1415. if (gimage == NULL)
  1416. success = FALSE;
  1417. channel = channel_get_ID (args[1].value.pdb_int);
  1418. if (channel == NULL)
  1419. success = FALSE;
  1420. if (success)
  1421. gimage_remove_channel (gimage, channel);
  1422. return procedural_db_return_args (&image_remove_channel_proc, success);
  1423. }
  1424. static ProcArg image_remove_channel_inargs[] =
  1425. {
  1426. {
  1427. PDB_IMAGE,
  1428. "image",
  1429. "The image"
  1430. },
  1431. {
  1432. PDB_CHANNEL,
  1433. "channel",
  1434. "The channel"
  1435. }
  1436. };
  1437. static ProcRecord image_remove_channel_proc =
  1438. {
  1439. "gimp_image_remove_channel",
  1440. "Remove the specified channel from the image.",
  1441. "This procedure removes the specified channel from the image. If the channel doesn't exist, an error is returned.",
  1442. "Spencer Kimball & Peter Mattis",
  1443. "Spencer Kimball & Peter Mattis",
  1444. "1995-1996",
  1445. PDB_INTERNAL,
  1446. 2,
  1447. image_remove_channel_inargs,
  1448. 0,
  1449. NULL,
  1450. { { image_remove_channel_invoker } }
  1451. };
  1452. static Argument *
  1453. image_active_drawable_invoker (Argument *args)
  1454. {
  1455. gboolean success = TRUE;
  1456. Argument *return_args;
  1457. GimpImage *gimage;
  1458. GimpDrawable *drawable = NULL;
  1459. gimage = pdb_id_to_image (args[0].value.pdb_int);
  1460. if (gimage == NULL)
  1461. success = FALSE;
  1462. if (success)
  1463. success = (drawable = gimage_active_drawable (gimage)) != NULL;
  1464. return_args = procedural_db_return_args (&image_active_drawable_proc, success);
  1465. if (success)
  1466. return_args[1].value.pdb_int = drawable_ID (GIMP_DRAWABLE (drawable));
  1467. return return_args;
  1468. }
  1469. static ProcArg image_active_drawable_inargs[] =
  1470. {
  1471. {
  1472. PDB_IMAGE,
  1473. "image",
  1474. "The image"
  1475. }
  1476. };
  1477. static ProcArg image_active_drawable_outargs[] =
  1478. {
  1479. {
  1480. PDB_DRAWABLE,
  1481. "drawable",
  1482. "The active drawable"
  1483. }
  1484. };
  1485. static ProcRecord image_active_drawable_proc =
  1486. {
  1487. "gimp_image_active_drawable",
  1488. "Get the image's active drawable",
  1489. "This procedure returns the ID of the image's active drawable. This can be either a layer, a channel, or a layer mask. The active drawable is specified by the active image channel. If that is -1, then by the active image layer. If the active image layer has a layer mask and the layer mask is in edit mode, then the layer mask is the active drawable.",
  1490. "Spencer Kimball & Peter Mattis",
  1491. "Spencer Kimball & Peter Mattis",
  1492. "1995-1996",
  1493. PDB_INTERNAL,
  1494. 1,
  1495. image_active_drawable_inargs,
  1496. 1,
  1497. image_active_drawable_outargs,
  1498. { { image_active_drawable_invoker } }
  1499. };
  1500. static Argument *
  1501. image_base_type_invoker (Argument *args)
  1502. {
  1503. gboolean success = TRUE;
  1504. Argument *return_args;
  1505. GimpImage *gimage;
  1506. gint32 base_type = 0;
  1507. gimage = pdb_id_to_image (args[0].value.pdb_int);
  1508. if (gimage == NULL)
  1509. success = FALSE;
  1510. if (success)
  1511. base_type = gimage_base_type (gimage);
  1512. return_args = procedural_db_return_args (&image_base_type_proc, success);
  1513. if (success)
  1514. return_args[1].value.pdb_int = base_type;
  1515. return return_args;
  1516. }
  1517. static ProcArg image_base_type_inargs[] =
  1518. {
  1519. {
  1520. PDB_IMAGE,
  1521. "image",
  1522. "The image"
  1523. }
  1524. };
  1525. static ProcArg image_base_type_outargs[] =
  1526. {
  1527. {
  1528. PDB_INT32,
  1529. "base_type",
  1530. "The image's base type: { RGB (0), GRAY (1), INDEXED (2) }"
  1531. }
  1532. };
  1533. static ProcRecord image_base_type_proc =
  1534. {
  1535. "gimp_image_base_type",
  1536. "Get the base type of the image.",
  1537. "This procedure returns the image's base type. Layers in the image must be of this subtype, but can have an optional alpha channel.",
  1538. "Spencer Kimball & Peter Mattis",
  1539. "Spencer Kimball & Peter Mattis",
  1540. "1995-1996",
  1541. PDB_INTERNAL,
  1542. 1,
  1543. image_base_type_inargs,
  1544. 1,
  1545. image_base_type_outargs,
  1546. { { image_base_type_invoker } }
  1547. };
  1548. static Argument *
  1549. image_get_cmap_invoker (Argument *args)
  1550. {
  1551. gboolean success = TRUE;
  1552. Argument *return_args;
  1553. GimpImage *gimage;
  1554. gint32 num_bytes = 0;
  1555. guint8 *cmap = NULL;
  1556. gimage = pdb_id_to_image (args[0].value.pdb_int);
  1557. if (gimage == NULL)
  1558. success = FALSE;
  1559. if (success)
  1560. {
  1561. num_bytes = gimage->num_cols * 3;
  1562. cmap = g_new (guint8, num_bytes);
  1563. memcpy (cmap, gimage_cmap (gimage), num_bytes);
  1564. }
  1565. return_args = procedural_db_return_args (&image_get_cmap_proc, success);
  1566. if (success)
  1567. {
  1568. return_args[1].value.pdb_int = num_bytes;
  1569. return_args[2].value.pdb_pointer = cmap;
  1570. }
  1571. return return_args;
  1572. }
  1573. static ProcArg image_get_cmap_inargs[] =
  1574. {
  1575. {
  1576. PDB_IMAGE,
  1577. "image",
  1578. "The image"
  1579. }
  1580. };
  1581. static ProcArg image_get_cmap_outargs[] =
  1582. {
  1583. {
  1584. PDB_INT32,
  1585. "num_bytes",
  1586. "Number of bytes in the colormap array: 0 < num_bytes"
  1587. },
  1588. {
  1589. PDB_INT8ARRAY,
  1590. "cmap",
  1591. "The image's colormap"
  1592. }
  1593. };
  1594. static ProcRecord image_get_cmap_proc =
  1595. {
  1596. "gimp_image_get_cmap",
  1597. "Returns the image's colormap",
  1598. "This procedure returns an actual pointer to the image's colormap, as well as the number of bytes contained in the colormap. The actual number of colors in the transmitted colormap will be \"num_bytes\" / 3. If the image is not of base type INDEXED, this pointer will be NULL.",
  1599. "Spencer Kimball & Peter Mattis",
  1600. "Spencer Kimball & Peter Mattis",
  1601. "1995-1996",
  1602. PDB_INTERNAL,
  1603. 1,
  1604. image_get_cmap_inargs,
  1605. 2,
  1606. image_get_cmap_outargs,
  1607. { { image_get_cmap_invoker } }
  1608. };
  1609. static Argument *
  1610. image_set_cmap_invoker (Argument *args)
  1611. {
  1612. gboolean success = TRUE;
  1613. GimpImage *gimage;
  1614. gint32 num_bytes;
  1615. guint8 *cmap;
  1616. gimage = pdb_id_to_image (args[0].value.pdb_int);
  1617. if (gimage == NULL)
  1618. success = FALSE;
  1619. num_bytes = args[1].value.pdb_int;
  1620. if (num_bytes < 0 || num_bytes > 768)
  1621. success = FALSE;
  1622. cmap = (guint8 *) args[2].value.pdb_pointer;
  1623. if (success)
  1624. {
  1625. if (gimage->cmap == NULL)
  1626. gimage->cmap = g_new (guchar, COLORMAP_SIZE);
  1627. if (num_bytes)
  1628. memcpy (gimage->cmap, cmap, num_bytes);
  1629. gimage->num_cols = num_bytes / 3;
  1630. /* A colormap alteration affects the whole image */
  1631. gdisplays_update_area (gimage, 0, 0, gimage->width, gimage->height);
  1632. }
  1633. return procedural_db_return_args (&image_set_cmap_proc, success);
  1634. }
  1635. static ProcArg image_set_cmap_inargs[] =
  1636. {
  1637. {
  1638. PDB_IMAGE,
  1639. "image",
  1640. "The image"
  1641. },
  1642. {
  1643. PDB_INT32,
  1644. "num_bytes",
  1645. "Number of bytes in the colormap array: 0 <= num_bytes <= 768"
  1646. },
  1647. {
  1648. PDB_INT8ARRAY,
  1649. "cmap",
  1650. "The new colormap values"
  1651. }
  1652. };
  1653. static ProcRecord image_set_cmap_proc =
  1654. {
  1655. "gimp_image_set_cmap",
  1656. "Sets the entries in the image's colormap.",
  1657. "This procedure sets the entries in the specified image's colormap. The number of entries is specified by the \"num_bytes\" parameter and corresponds to the number of INT8 triples that must be contained in the \"cmap\" array. The actual number of colors in the transmitted colormap is \"num_bytes\" / 3.",
  1658. "Spencer Kimball & Peter Mattis",
  1659. "Spencer Kimball & Peter Mattis",
  1660. "1995-1996",
  1661. PDB_INTERNAL,
  1662. 3,
  1663. image_set_cmap_inargs,
  1664. 0,
  1665. NULL,
  1666. { { image_set_cmap_invoker } }
  1667. };
  1668. static Argument *
  1669. image_undo_is_enabled_invoker (Argument *args)
  1670. {
  1671. gboolean success = TRUE;
  1672. Argument *return_args;
  1673. GimpImage *gimage;
  1674. gboolean enabled = FALSE;
  1675. gimage = pdb_id_to_image (args[0].value.pdb_int);
  1676. if (gimage == NULL)
  1677. success = FALSE;
  1678. if (success)
  1679. enabled = gimp_image_undo_is_enabled (gimage);
  1680. return_args = procedural_db_return_args (&image_undo_is_enabled_proc, success);
  1681. if (success)
  1682. return_args[1].value.pdb_int = enabled;
  1683. return return_args;
  1684. }
  1685. static ProcArg image_undo_is_enabled_inargs[] =
  1686. {
  1687. {
  1688. PDB_IMAGE,
  1689. "image",
  1690. "The image"
  1691. }
  1692. };
  1693. static ProcArg image_undo_is_enabled_outargs[] =
  1694. {
  1695. {
  1696. PDB_INT32,
  1697. "enabled",
  1698. "True if undo is enabled for this image"
  1699. }
  1700. };
  1701. static ProcRecord image_undo_is_enabled_proc =
  1702. {
  1703. "gimp_image_undo_is_enabled",
  1704. "Check if the image's undo stack is enabled.",
  1705. "This procedure checks if the image's undo stack is currently enabled or disabled. This is useful when several plugins or scripts call each other and want to check if their caller has already used 'gimp_image_undo_disable' or 'gimp_image_undo_freeze'.",
  1706. "Raphael Quinet",
  1707. "Raphael Quinet",
  1708. "1999",
  1709. PDB_INTERNAL,
  1710. 1,
  1711. image_undo_is_enabled_inargs,
  1712. 1,
  1713. image_undo_is_enabled_outargs,
  1714. { { image_undo_is_enabled_invoker } }
  1715. };
  1716. static Argument *
  1717. image_undo_enable_invoker (Argument *args)
  1718. {
  1719. gboolean success = TRUE;
  1720. Argument *return_args;
  1721. GimpImage *gimage;
  1722. gimage = pdb_id_to_image (args[0].value.pdb_int);
  1723. if (gimage == NULL)
  1724. success = FALSE;
  1725. if (success)
  1726. success = gimage_enable_undo (gimage);
  1727. return_args = procedural_db_return_args (&image_undo_enable_proc, success);
  1728. if (success)
  1729. return_args[1].value.pdb_int = success ? TRUE : FALSE;
  1730. return return_args;
  1731. }
  1732. static ProcArg image_undo_enable_inargs[] =
  1733. {
  1734. {
  1735. PDB_IMAGE,
  1736. "image",
  1737. "The image"
  1738. }
  1739. };
  1740. static ProcArg image_undo_enable_outargs[] =
  1741. {
  1742. {
  1743. PDB_INT32,
  1744. "enabled",
  1745. "True if the image undo has been enabled"
  1746. }
  1747. };
  1748. static ProcRecord image_undo_enable_proc =
  1749. {
  1750. "gimp_image_undo_enable",
  1751. "Enable the image's undo stack.",
  1752. "This procedure enables the image's undo stack, allowing subsequent operations to store their undo steps. This is generally called in conjunction with 'gimp_image_undo_disable' to temporarily disable an image undo stack.",
  1753. "Spencer Kimball & Peter Mattis",
  1754. "Spencer Kimball & Peter Mattis",
  1755. "1995-1996",
  1756. PDB_INTERNAL,
  1757. 1,
  1758. image_undo_enable_inargs,
  1759. 1,
  1760. image_undo_enable_outargs,
  1761. { { image_undo_enable_invoker } }
  1762. };
  1763. static Argument *
  1764. image_undo_disable_invoker (Argument *args)
  1765. {
  1766. gboolean success = TRUE;
  1767. Argument *return_args;
  1768. GimpImage *gimage;
  1769. gimage = pdb_id_to_image (args[0].value.pdb_int);
  1770. if (gimage == NULL)
  1771. success = FALSE;
  1772. if (success)
  1773. success = gimage_disable_undo (gimage);
  1774. return_args = procedural_db_return_args (&image_undo_disable_proc, success);
  1775. if (success)
  1776. return_args[1].value.pdb_int = success ? TRUE : FALSE;
  1777. return return_args;
  1778. }
  1779. static ProcArg image_undo_disable_inargs[] =
  1780. {
  1781. {
  1782. PDB_IMAGE,
  1783. "image",
  1784. "The image"
  1785. }
  1786. };
  1787. static ProcArg image_undo_disable_outargs[] =
  1788. {
  1789. {
  1790. PDB_INT32,
  1791. "disabled",
  1792. "True if the image undo has been disabled"
  1793. }
  1794. };
  1795. static ProcRecord image_undo_disable_proc =
  1796. {
  1797. "gimp_image_undo_disable",
  1798. "Disable the image's undo stack.",
  1799. "This procedure disables the image's undo stack, allowing subsequent operations to ignore their undo steps. This is generally called in conjunction with 'gimp_image_undo_enable' to temporarily disable an image undo stack. This is advantageous because saving undo steps can be time and memory intensive.",
  1800. "Spencer Kimball & Peter Mattis",
  1801. "Spencer Kimball & Peter Mattis",
  1802. "1995-1996",
  1803. PDB_INTERNAL,
  1804. 1,
  1805. image_undo_disable_inargs,
  1806. 1,
  1807. image_undo_disable_outargs,
  1808. { { image_undo_disable_invoker } }
  1809. };
  1810. static Argument *
  1811. image_undo_freeze_invoker (Argument *args)
  1812. {
  1813. gboolean success = TRUE;
  1814. Argument *return_args;
  1815. GimpImage *gimage;
  1816. gimage = pdb_id_to_image (args[0].value.pdb_int);
  1817. if (gimage == NULL)
  1818. success = FALSE;
  1819. if (success)
  1820. success = gimage_freeze_undo (gimage);
  1821. return_args = procedural_db_return_args (&image_undo_freeze_proc, success);
  1822. if (success)
  1823. return_args[1].value.pdb_int = success ? TRUE : FALSE;
  1824. return return_args;
  1825. }
  1826. static ProcArg image_undo_freeze_inargs[] =
  1827. {
  1828. {
  1829. PDB_IMAGE,
  1830. "image",
  1831. "The image"
  1832. }
  1833. };
  1834. static ProcArg image_undo_freeze_outargs[] =
  1835. {
  1836. {
  1837. PDB_INT32,
  1838. "frozen",
  1839. "True if the image undo has been frozen"
  1840. }
  1841. };
  1842. static ProcRecord image_undo_freeze_proc =
  1843. {
  1844. "gimp_image_undo_freeze",
  1845. "Freeze the image's undo stack.",
  1846. "This procedure freezes the image's undo stack, allowing subsequent operations to ignore their undo steps. This is generally called in conjunction with 'gimp_image_undo_thaw' to temporarily disable an image undo stack. This is advantageous because saving undo steps can be time and memory intensive. 'gimp_image_undo_{freeze,thaw}' and 'gimp_image_undo_{disable,enable}' differ in that the former does not free up all undo steps when undo is thawed, so is more suited to interactive in-situ previews. It is important in this case that the image is back to the same state it was frozen in before thawing, else 'undo' behaviour is undefined.",
  1847. "Adam D. Moss",
  1848. "Adam D. Moss",
  1849. "1999",
  1850. PDB_INTERNAL,
  1851. 1,
  1852. image_undo_freeze_inargs,
  1853. 1,
  1854. image_undo_freeze_outargs,
  1855. { { image_undo_freeze_invoker } }
  1856. };
  1857. static Argument *
  1858. image_undo_thaw_invoker (Argument *args)
  1859. {
  1860. gboolean success = TRUE;
  1861. Argument *return_args;
  1862. GimpImage *gimage;
  1863. gimage = pdb_id_to_image (args[0].value.pdb_int);
  1864. if (gimage == NULL)
  1865. success = FALSE;
  1866. if (success)
  1867. success = gimage_thaw_undo (gimage);
  1868. return_args = procedural_db_return_args (&image_undo_thaw_proc, success);
  1869. if (success)
  1870. return_args[1].value.pdb_int = success ? TRUE : FALSE;
  1871. return return_args;
  1872. }
  1873. static ProcArg image_undo_thaw_inargs[] =
  1874. {
  1875. {
  1876. PDB_IMAGE,
  1877. "image",
  1878. "The image"
  1879. }
  1880. };
  1881. static ProcArg image_undo_thaw_outargs[] =
  1882. {
  1883. {
  1884. PDB_INT32,
  1885. "thawed",
  1886. "True if the image undo has been thawed"
  1887. }
  1888. };
  1889. static ProcRecord image_undo_thaw_proc =
  1890. {
  1891. "gimp_image_undo_thaw",
  1892. "Thaw the image's undo stack.",
  1893. "This procedure thaws the image's undo stack, allowing subsequent operations to store their undo steps. This is generally called in conjunction with 'gimp_image_undo_freeze' to temporarily freeze an image undo stack. 'gimp_image_undo_thaw' does NOT free the undo stack as 'gimp_image_undo_enable' does, so is suited for situations where one wishes to leave the undo stack in the same state in which one found it despite non-destructively playing with the image in the meantime. An example would be in-situ plugin previews. Balancing freezes and thaws and ensuring image consistancy is the responsibility of the caller.",
  1894. "Adam D. Moss",
  1895. "Adam D. Moss",
  1896. "1999",
  1897. PDB_INTERNAL,
  1898. 1,
  1899. image_undo_thaw_inargs,
  1900. 1,
  1901. image_undo_thaw_outargs,
  1902. { { image_undo_thaw_invoker } }
  1903. };
  1904. static Argument *
  1905. image_clean_all_invoker (Argument *args)
  1906. {
  1907. gboolean success = TRUE;
  1908. GimpImage *gimage;
  1909. gimage = pdb_id_to_image (args[0].value.pdb_int);
  1910. if (gimage == NULL)
  1911. success = FALSE;
  1912. if (success)
  1913. gimage_clean_all (gimage);
  1914. return procedural_db_return_args (&image_clean_all_proc, success);
  1915. }
  1916. static ProcArg image_clean_all_inargs[] =
  1917. {
  1918. {
  1919. PDB_IMAGE,
  1920. "image",
  1921. "The image"
  1922. }
  1923. };
  1924. static ProcRecord image_clean_all_proc =
  1925. {
  1926. "gimp_image_clean_all",
  1927. "Set the image dirty count to 0.",
  1928. "This procedure sets the specified image's dirty count to 0, allowing operations to occur without having a 'dirtied' image. This is especially useful for creating and loading images which should not initially be considered dirty, even though layers must be created, filled, and installed in the image.",
  1929. "Spencer Kimball & Peter Mattis",
  1930. "Spencer Kimball & Peter Mattis",
  1931. "1995-1996",
  1932. PDB_INTERNAL,
  1933. 1,
  1934. image_clean_all_inargs,
  1935. 0,
  1936. NULL,
  1937. { { image_clean_all_invoker } }
  1938. };
  1939. static Argument *
  1940. image_floating_selection_invoker (Argument *args)
  1941. {
  1942. gboolean success = TRUE;
  1943. Argument *return_args;
  1944. GimpImage *gimage;
  1945. GimpLayer *floating_sel = NULL;
  1946. gimage = pdb_id_to_image (args[0].value.pdb_int);
  1947. if (gimage == NULL)
  1948. success = FALSE;
  1949. if (success)
  1950. floating_sel = gimage_floating_sel (gimage);
  1951. return_args = procedural_db_return_args (&image_floating_selection_proc, success);
  1952. if (success)
  1953. return_args[1].value.pdb_int = floating_sel ? drawable_ID (GIMP_DRAWABLE (floating_sel)) : -1;
  1954. return return_args;
  1955. }
  1956. static ProcArg image_floating_selection_inargs[] =
  1957. {
  1958. {
  1959. PDB_IMAGE,
  1960. "image",
  1961. "The image"
  1962. }
  1963. };
  1964. static ProcArg image_floating_selection_outargs[] =
  1965. {
  1966. {
  1967. PDB_LAYER,
  1968. "floating_sel",
  1969. "The image's floating selection"
  1970. }
  1971. };
  1972. static ProcRecord image_floating_selection_proc =
  1973. {
  1974. "gimp_image_floating_selection",
  1975. "Return the floating selection of the image.",
  1976. "This procedure returns the image's floating_sel, if it exists. If it doesn't exist, -1 is returned as the layer ID.",
  1977. "Spencer Kimball & Peter Mattis",
  1978. "Spencer Kimball & Peter Mattis",
  1979. "1995-1996",
  1980. PDB_INTERNAL,
  1981. 1,
  1982. image_floating_selection_inargs,
  1983. 1,
  1984. image_floating_selection_outargs,
  1985. { { image_floating_selection_invoker } }
  1986. };
  1987. static Argument *
  1988. image_floating_sel_attached_to_invoker (Argument *args)
  1989. {
  1990. gboolean success = TRUE;
  1991. Argument *return_args;
  1992. GimpImage *gimage;
  1993. GimpDrawable *drawable = NULL;
  1994. Layer *floating_sel;
  1995. gimage = pdb_id_to_image (args[0].value.pdb_int);
  1996. if (gimage == NULL)
  1997. success = FALSE;
  1998. if (success)
  1999. {
  2000. floating_sel = gimage_floating_sel (gimage);
  2001. if (floating_sel)
  2002. drawable = GIMP_DRAWABLE (GIMP_LAYER (floating_sel)->fs.drawable);
  2003. else
  2004. drawable = NULL;
  2005. }
  2006. return_args = procedural_db_return_args (&image_floating_sel_attached_to_proc, success);
  2007. if (success)
  2008. return_args[1].value.pdb_int = drawable ? drawable_ID (GIMP_DRAWABLE (drawable)) : -1;
  2009. return return_args;
  2010. }
  2011. static ProcArg image_floating_sel_attached_to_inargs[] =
  2012. {
  2013. {
  2014. PDB_IMAGE,
  2015. "image",
  2016. "The image"
  2017. }
  2018. };
  2019. static ProcArg image_floating_sel_attached_to_outargs[] =
  2020. {
  2021. {
  2022. PDB_DRAWABLE,
  2023. "drawable",
  2024. "The drawable the floating selection is attached to"
  2025. }
  2026. };
  2027. static ProcRecord image_floating_sel_attached_to_proc =
  2028. {
  2029. "gimp_image_floating_sel_attached_to",
  2030. "Return the drawable the floating selection is attached to.",
  2031. "This procedure returns the drawable the image's floating selection is attached to, if it exists. If it doesn't exist, -1 is returned as the drawable ID.",
  2032. "Wolfgang Hofer",
  2033. "Wolfgang Hofer",
  2034. "1998",
  2035. PDB_INTERNAL,
  2036. 1,
  2037. image_floating_sel_attached_to_inargs,
  2038. 1,
  2039. image_floating_sel_attached_to_outargs,
  2040. { { image_floating_sel_attached_to_invoker } }
  2041. };
  2042. static Argument *
  2043. image_thumbnail_invoker (Argument *args)
  2044. {
  2045. gboolean success = TRUE;
  2046. Argument *return_args;
  2047. GimpImage *gimage;
  2048. gint32 req_width;
  2049. gint32 req_height;
  2050. gint32 width = 0;
  2051. gint32 height = 0;
  2052. gint32 bpp = 0;
  2053. gint32 num_bytes = 0;
  2054. guint8 *thumbnail_data = NULL;
  2055. gimage = pdb_id_to_image (args[0].value.pdb_int);
  2056. if (gimage == NULL)
  2057. success = FALSE;
  2058. req_width = args[1].value.pdb_int;
  2059. if (req_width <= 0)
  2060. success = FALSE;
  2061. req_height = args[2].value.pdb_int;
  2062. if (req_height <= 0)
  2063. success = FALSE;
  2064. if (success)
  2065. {
  2066. TempBuf * buf;
  2067. gint dwidth, dheight;
  2068. if (req_width <= 128 && req_height <= 128)
  2069. {
  2070. /* Adjust the width/height ratio */
  2071. dwidth = gimage->width;
  2072. dheight = gimage->height;
  2073. if (dwidth > dheight)
  2074. req_height = MAX (1, (req_width * dheight) / dwidth);
  2075. else
  2076. req_width = MAX (1, (req_height * dwidth) / dheight);
  2077. buf = gimp_image_construct_composite_preview (gimage,
  2078. req_width,
  2079. req_height);
  2080. num_bytes = buf->height * buf->width * buf->bytes;
  2081. thumbnail_data = g_new (guint8, num_bytes);
  2082. g_memmove (thumbnail_data, temp_buf_data (buf), num_bytes);
  2083. width = buf->width;
  2084. height = buf->height;
  2085. bpp = buf->bytes;
  2086. temp_buf_free (buf);
  2087. }
  2088. }
  2089. return_args = procedural_db_return_args (&image_thumbnail_proc, success);
  2090. if (success)
  2091. {
  2092. return_args[1].value.pdb_int = width;
  2093. return_args[2].value.pdb_int = height;
  2094. return_args[3].value.pdb_int = bpp;
  2095. return_args[4].value.pdb_int = num_bytes;
  2096. return_args[5].value.pdb_pointer = thumbnail_data;
  2097. }
  2098. return return_args;
  2099. }
  2100. static ProcArg image_thumbnail_inargs[] =
  2101. {
  2102. {
  2103. PDB_IMAGE,
  2104. "image",
  2105. "The image"
  2106. },
  2107. {
  2108. PDB_INT32,
  2109. "width",
  2110. "The thumbnail width"
  2111. },
  2112. {
  2113. PDB_INT32,
  2114. "height",
  2115. "The thumbnail height"
  2116. }
  2117. };
  2118. static ProcArg image_thumbnail_outargs[] =
  2119. {
  2120. {
  2121. PDB_INT32,
  2122. "width",
  2123. "The previews width"
  2124. },
  2125. {
  2126. PDB_INT32,
  2127. "height",
  2128. "The previews height"
  2129. },
  2130. {
  2131. PDB_INT32,
  2132. "bpp",
  2133. "The previews bpp"
  2134. },
  2135. {
  2136. PDB_INT32,
  2137. "thumbnail_data_count",
  2138. "The number of bytes in thumbnail data"
  2139. },
  2140. {
  2141. PDB_INT8ARRAY,
  2142. "thumbnail_data",
  2143. "The thumbnail data"
  2144. }
  2145. };
  2146. static ProcRecord image_thumbnail_proc =
  2147. {
  2148. "gimp_image_thumbnail",
  2149. "Get a thumbnail of an image.",
  2150. "This function gets data from which a thumbnail of an image preview can be created. Maximum x or y dimension is 128 pixels. The pixels are returned in the RGB[A] format. The bpp return value gives the number of bits per pixel in the image. If the image has an alpha channel, it is also returned.",
  2151. "Andy Thomas",
  2152. "Andy Thomas",
  2153. "1999",
  2154. PDB_INTERNAL,
  2155. 3,
  2156. image_thumbnail_inargs,
  2157. 5,
  2158. image_thumbnail_outargs,
  2159. { { image_thumbnail_invoker } }
  2160. };
  2161. static Argument *
  2162. image_set_tattoo_state_invoker (Argument *args)
  2163. {
  2164. gboolean success = TRUE;
  2165. GimpImage *gimage;
  2166. gint32 tattoo;
  2167. gimage = pdb_id_to_image (args[0].value.pdb_int);
  2168. if (gimage == NULL)
  2169. success = FALSE;
  2170. tattoo = args[1].value.pdb_int;
  2171. if (success)
  2172. {
  2173. success = gimp_image_set_tattoo_state(gimage,tattoo);
  2174. }
  2175. return procedural_db_return_args (&image_set_tattoo_state_proc, success);
  2176. }
  2177. static ProcArg image_set_tattoo_state_inargs[] =
  2178. {
  2179. {
  2180. PDB_IMAGE,
  2181. "image",
  2182. "The image"
  2183. },
  2184. {
  2185. PDB_INT32,
  2186. "tattoo",
  2187. "The new tattoo state of the image"
  2188. }
  2189. };
  2190. static ProcRecord image_set_tattoo_state_proc =
  2191. {
  2192. "gimp_image_set_tattoo_state",
  2193. "Set the tattoo state associated with the image.",
  2194. "This procedure sets the tattoo state of the image. Use only by save/load plugins that wish to preserve an images tattoo state. Using this function at other times will produce unexpected results. A full check of uniqueness of states in layers, channels and paths will be performed by this procedure and a execution failure will be returned if this fails. A failure will also be returned if the new tattoo state value is less than the maximum tattoo value from all of the tattoos from the paths,layers and channels. After the image data has been loaded and all the tattoos have been set then this is the last procedure that should be called. If effectively does a status check on the tattoo values that have been set to make sure that all is OK.",
  2195. "Andy Thomas",
  2196. "Andy Thomas",
  2197. "2000",
  2198. PDB_INTERNAL,
  2199. 2,
  2200. image_set_tattoo_state_inargs,
  2201. 0,
  2202. NULL,
  2203. { { image_set_tattoo_state_invoker } }
  2204. };
  2205. static Argument *
  2206. image_get_tattoo_state_invoker (Argument *args)
  2207. {
  2208. gboolean success = TRUE;
  2209. Argument *return_args;
  2210. GimpImage *gimage;
  2211. gint32 tattoo = 0;
  2212. gimage = pdb_id_to_image (args[0].value.pdb_int);
  2213. if (gimage == NULL)
  2214. success = FALSE;
  2215. if (success)
  2216. {
  2217. tattoo = gimp_image_get_tattoo_state(gimage);
  2218. }
  2219. return_args = procedural_db_return_args (&image_get_tattoo_state_proc, success);
  2220. if (success)
  2221. return_args[1].value.pdb_int = tattoo;
  2222. return return_args;
  2223. }
  2224. static ProcArg image_get_tattoo_state_inargs[] =
  2225. {
  2226. {
  2227. PDB_IMAGE,
  2228. "image",
  2229. "The image"
  2230. }
  2231. };
  2232. static ProcArg image_get_tattoo_state_outargs[] =
  2233. {
  2234. {
  2235. PDB_INT32,
  2236. "tattoo",
  2237. "The tattoo state associated with the image"
  2238. }
  2239. };
  2240. static ProcRecord image_get_tattoo_state_proc =
  2241. {
  2242. "gimp_image_get_tattoo_state",
  2243. "Returns the tattoo state associated with the image.",
  2244. "This procedure returns the tattoo state of the image. Use only by save/load plugins that wish to preserve an images tattoo state. Using this function at other times will produce unexpected results.",
  2245. "Andy Thomas",
  2246. "Andy Thomas",
  2247. "2000",
  2248. PDB_INTERNAL,
  2249. 1,
  2250. image_get_tattoo_state_inargs,
  2251. 1,
  2252. image_get_tattoo_state_outargs,
  2253. { { image_get_tattoo_state_invoker } }
  2254. };
  2255. static Argument *
  2256. image_width_invoker (Argument *args)
  2257. {
  2258. gboolean success = TRUE;
  2259. Argument *return_args;
  2260. GimpImage *gimage;
  2261. gimage = pdb_id_to_image (args[0].value.pdb_int);
  2262. if (gimage == NULL)
  2263. success = FALSE;
  2264. return_args = procedural_db_return_args (&image_width_proc, success);
  2265. if (success)
  2266. return_args[1].value.pdb_int = gimage->width;
  2267. return return_args;
  2268. }
  2269. static ProcArg image_width_inargs[] =
  2270. {
  2271. {
  2272. PDB_IMAGE,
  2273. "image",
  2274. "The image"
  2275. }
  2276. };
  2277. static ProcArg image_width_outargs[] =
  2278. {
  2279. {
  2280. PDB_INT32,
  2281. "width",
  2282. "The image's width"
  2283. }
  2284. };
  2285. static ProcRecord image_width_proc =
  2286. {
  2287. "gimp_image_width",
  2288. "Return the width of the image",
  2289. "This procedure returns the image's width. This value is independent of any of the layers in this image. This is the \"canvas\" width.",
  2290. "Spencer Kimball & Peter Mattis",
  2291. "Spencer Kimball & Peter Mattis",
  2292. "1995-1996",
  2293. PDB_INTERNAL,
  2294. 1,
  2295. image_width_inargs,
  2296. 1,
  2297. image_width_outargs,
  2298. { { image_width_invoker } }
  2299. };
  2300. static Argument *
  2301. image_height_invoker (Argument *args)
  2302. {
  2303. gboolean success = TRUE;
  2304. Argument *return_args;
  2305. GimpImage *gimage;
  2306. gimage = pdb_id_to_image (args[0].value.pdb_int);
  2307. if (gimage == NULL)
  2308. success = FALSE;
  2309. return_args = procedural_db_return_args (&image_height_proc, success);
  2310. if (success)
  2311. return_args[1].value.pdb_int = gimage->height;
  2312. return return_args;
  2313. }
  2314. static ProcArg image_height_inargs[] =
  2315. {
  2316. {
  2317. PDB_IMAGE,
  2318. "image",
  2319. "The image"
  2320. }
  2321. };
  2322. static ProcArg image_height_outargs[] =
  2323. {
  2324. {
  2325. PDB_INT32,
  2326. "height",
  2327. "The image's height"
  2328. }
  2329. };
  2330. static ProcRecord image_height_proc =
  2331. {
  2332. "gimp_image_height",
  2333. "Return the height of the image",
  2334. "This procedure returns the image's height. This value is independent of any of the layers in this image. This is the \"canvas\" height.",
  2335. "Spencer Kimball & Peter Mattis",
  2336. "Spencer Kimball & Peter Mattis",
  2337. "1995-1996",
  2338. PDB_INTERNAL,
  2339. 1,
  2340. image_height_inargs,
  2341. 1,
  2342. image_height_outargs,
  2343. { { image_height_invoker } }
  2344. };
  2345. static Argument *
  2346. image_get_active_layer_invoker (Argument *args)
  2347. {
  2348. gboolean success = TRUE;
  2349. Argument *return_args;
  2350. GimpImage *gimage;
  2351. GimpLayer *active_layer = NULL;
  2352. gimage = pdb_id_to_image (args[0].value.pdb_int);
  2353. if (gimage == NULL)
  2354. success = FALSE;
  2355. if (success)
  2356. active_layer = gimage_get_active_layer (gimage);
  2357. return_args = procedural_db_return_args (&image_get_active_layer_proc, success);
  2358. if (success)
  2359. return_args[1].value.pdb_int = active_layer ? drawable_ID (GIMP_DRAWABLE (active_layer)) : -1;
  2360. return return_args;
  2361. }
  2362. static ProcArg image_get_active_layer_inargs[] =
  2363. {
  2364. {
  2365. PDB_IMAGE,
  2366. "image",
  2367. "The image"
  2368. }
  2369. };
  2370. static ProcArg image_get_active_layer_outargs[] =
  2371. {
  2372. {
  2373. PDB_LAYER,
  2374. "active_layer",
  2375. "The active layer"
  2376. }
  2377. };
  2378. static ProcRecord image_get_active_layer_proc =
  2379. {
  2380. "gimp_image_get_active_layer",
  2381. "Returns the specified image's active layer.",
  2382. "If there is an active layer, its ID will be returned, otherwise, -1. If a channel is currently active, then no layer will be. If a layer mask is active, then this will return the associated layer.",
  2383. "Spencer Kimball & Peter Mattis",
  2384. "Spencer Kimball & Peter Mattis",
  2385. "1995-1996",
  2386. PDB_INTERNAL,
  2387. 1,
  2388. image_get_active_layer_inargs,
  2389. 1,
  2390. image_get_active_layer_outargs,
  2391. { { image_get_active_layer_invoker } }
  2392. };
  2393. static Argument *
  2394. image_set_active_layer_invoker (Argument *args)
  2395. {
  2396. gboolean success = TRUE;
  2397. GimpImage *gimage;
  2398. GimpLayer *active_layer;
  2399. gimage = pdb_id_to_image (args[0].value.pdb_int);
  2400. if (gimage == NULL)
  2401. success = FALSE;
  2402. active_layer = layer_get_ID (args[1].value.pdb_int);
  2403. if (active_layer == NULL)
  2404. success = FALSE;
  2405. if (success)
  2406. gimage_set_active_layer (gimage, active_layer);
  2407. return procedural_db_return_args (&image_set_active_layer_proc, success);
  2408. }
  2409. static ProcArg image_set_active_layer_inargs[] =
  2410. {
  2411. {
  2412. PDB_IMAGE,
  2413. "image",
  2414. "The image"
  2415. },
  2416. {
  2417. PDB_LAYER,
  2418. "active_layer",
  2419. "The new image active layer"
  2420. }
  2421. };
  2422. static ProcRecord image_set_active_layer_proc =
  2423. {
  2424. "gimp_image_set_active_layer",
  2425. "Sets the specified image's active layer.",
  2426. "If the layer exists, it is set as the active layer in the image. Any previous active layer or channel is set to inactive. An exception is a previously existing floating selection, in which case this procedure will return an execution error.",
  2427. "Spencer Kimball & Peter Mattis",
  2428. "Spencer Kimball & Peter Mattis",
  2429. "1995-1996",
  2430. PDB_INTERNAL,
  2431. 2,
  2432. image_set_active_layer_inargs,
  2433. 0,
  2434. NULL,
  2435. { { image_set_active_layer_invoker } }
  2436. };
  2437. static Argument *
  2438. image_get_active_channel_invoker (Argument *args)
  2439. {
  2440. gboolean success = TRUE;
  2441. Argument *return_args;
  2442. GimpImage *gimage;
  2443. Channel *active_channel = NULL;
  2444. gimage = pdb_id_to_image (args[0].value.pdb_int);
  2445. if (gimage == NULL)
  2446. success = FALSE;
  2447. if (success)
  2448. active_channel = gimage_get_active_channel (gimage);
  2449. return_args = procedural_db_return_args (&image_get_active_channel_proc, success);
  2450. if (success)
  2451. return_args[1].value.pdb_int = active_channel ? drawable_ID (GIMP_DRAWABLE (active_channel)) : -1;
  2452. return return_args;
  2453. }
  2454. static ProcArg image_get_active_channel_inargs[] =
  2455. {
  2456. {
  2457. PDB_IMAGE,
  2458. "image",
  2459. "The image"
  2460. }
  2461. };
  2462. static ProcArg image_get_active_channel_outargs[] =
  2463. {
  2464. {
  2465. PDB_CHANNEL,
  2466. "active_channel",
  2467. "The active channel"
  2468. }
  2469. };
  2470. static ProcRecord image_get_active_channel_proc =
  2471. {
  2472. "gimp_image_get_active_channel",
  2473. "Returns the specified image's active channel.",
  2474. "If there is an active channel, this will return the channel ID, otherwise, -1.",
  2475. "Spencer Kimball & Peter Mattis",
  2476. "Spencer Kimball & Peter Mattis",
  2477. "1995-1996",
  2478. PDB_INTERNAL,
  2479. 1,
  2480. image_get_active_channel_inargs,
  2481. 1,
  2482. image_get_active_channel_outargs,
  2483. { { image_get_active_channel_invoker } }
  2484. };
  2485. static Argument *
  2486. image_set_active_channel_invoker (Argument *args)
  2487. {
  2488. gboolean success = TRUE;
  2489. GimpImage *gimage;
  2490. Channel *active_channel;
  2491. gimage = pdb_id_to_image (args[0].value.pdb_int);
  2492. if (gimage == NULL)
  2493. success = FALSE;
  2494. active_channel = channel_get_ID (args[1].value.pdb_int);
  2495. if (active_channel == NULL)
  2496. success = FALSE;
  2497. if (success)
  2498. gimage_set_active_channel (gimage, active_channel);
  2499. return procedural_db_return_args (&image_set_active_channel_proc, success);
  2500. }
  2501. static ProcArg image_set_active_channel_inargs[] =
  2502. {
  2503. {
  2504. PDB_IMAGE,
  2505. "image",
  2506. "The image"
  2507. },
  2508. {
  2509. PDB_CHANNEL,
  2510. "active_channel",
  2511. "The new image active channel"
  2512. }
  2513. };
  2514. static ProcRecord image_set_active_channel_proc =
  2515. {
  2516. "gimp_image_set_active_channel",
  2517. "Sets the specified image's active channel.",
  2518. "If the channel exists, it is set as the active channel in the image. Any previous active channel or channel is set to inactive. An exception is a previously existing floating selection, in which case this procedure will return an execution error.",
  2519. "Spencer Kimball & Peter Mattis",
  2520. "Spencer Kimball & Peter Mattis",
  2521. "1995-1996",
  2522. PDB_INTERNAL,
  2523. 2,
  2524. image_set_active_channel_inargs,
  2525. 0,
  2526. NULL,
  2527. { { image_set_active_channel_invoker } }
  2528. };
  2529. static Argument *
  2530. image_get_selection_invoker (Argument *args)
  2531. {
  2532. gboolean success = TRUE;
  2533. Argument *return_args;
  2534. GimpImage *gimage;
  2535. Channel *selection = NULL;
  2536. gimage = pdb_id_to_image (args[0].value.pdb_int);
  2537. if (gimage == NULL)
  2538. success = FALSE;
  2539. if (success)
  2540. success = (selection = gimage_get_mask (gimage)) != NULL;
  2541. return_args = procedural_db_return_args (&image_get_selection_proc, success);
  2542. if (success)
  2543. return_args[1].value.pdb_int = drawable_ID (GIMP_DRAWABLE (selection));
  2544. return return_args;
  2545. }
  2546. static ProcArg image_get_selection_inargs[] =
  2547. {
  2548. {
  2549. PDB_IMAGE,
  2550. "image",
  2551. "The image"
  2552. }
  2553. };
  2554. static ProcArg image_get_selection_outargs[] =
  2555. {
  2556. {
  2557. PDB_SELECTION,
  2558. "selection",
  2559. "The selection channel"
  2560. }
  2561. };
  2562. static ProcRecord image_get_selection_proc =
  2563. {
  2564. "gimp_image_get_selection",
  2565. "Returns the specified image's selection.",
  2566. "This will always return a valid ID for a selection -- which is represented as a channel internally.",
  2567. "Spencer Kimball & Peter Mattis",
  2568. "Spencer Kimball & Peter Mattis",
  2569. "1995-1996",
  2570. PDB_INTERNAL,
  2571. 1,
  2572. image_get_selection_inargs,
  2573. 1,
  2574. image_get_selection_outargs,
  2575. { { image_get_selection_invoker } }
  2576. };
  2577. static Argument *
  2578. image_get_component_active_invoker (Argument *args)
  2579. {
  2580. gboolean success = TRUE;
  2581. Argument *return_args;
  2582. GimpImage *gimage;
  2583. gint32 component;
  2584. gimage = pdb_id_to_image (args[0].value.pdb_int);
  2585. if (gimage == NULL)
  2586. success = FALSE;
  2587. component = args[1].value.pdb_int;
  2588. if (component < RED_CHANNEL || component > INDEXED_CHANNEL)
  2589. success = FALSE;
  2590. if (success)
  2591. {
  2592. if (component == GRAY_CHANNEL)
  2593. success = gimage_base_type (gimage) == GRAY;
  2594. else if (component == INDEXED_CHANNEL)
  2595. success = gimage_base_type (gimage) == INDEXED;
  2596. else
  2597. success = gimage_base_type (gimage) == RGB;
  2598. }
  2599. return_args = procedural_db_return_args (&image_get_component_active_proc, success);
  2600. if (success)
  2601. return_args[1].value.pdb_int = gimage_get_component_active (gimage, component);
  2602. return return_args;
  2603. }
  2604. static ProcArg image_get_component_active_inargs[] =
  2605. {
  2606. {
  2607. PDB_IMAGE,
  2608. "image",
  2609. "The image"
  2610. },
  2611. {
  2612. PDB_INT32,
  2613. "component",
  2614. "The image component: { RED_CHANNEL (0), GREEN_CHANNEL (1), BLUE_CHANNEL (2), GRAY_CHANNEL (3), INDEXED_CHANNEL (4) }"
  2615. }
  2616. };
  2617. static ProcArg image_get_component_active_outargs[] =
  2618. {
  2619. {
  2620. PDB_INT32,
  2621. "active",
  2622. "Component is active (TRUE or FALSE)"
  2623. }
  2624. };
  2625. static ProcRecord image_get_component_active_proc =
  2626. {
  2627. "gimp_image_get_component_active",
  2628. "Returns if the specified image's image component is active.",
  2629. "This procedure returns if the specified image's image component (i.e. Red, Green, Blue intensity channels in an RGB image) is active or inactive -- whether or not it can be modified. If the specified component is not valid for the image type, an error is returned.",
  2630. "Spencer Kimball & Peter Mattis",
  2631. "Spencer Kimball & Peter Mattis",
  2632. "1995-1996",
  2633. PDB_INTERNAL,
  2634. 2,
  2635. image_get_component_active_inargs,
  2636. 1,
  2637. image_get_component_active_outargs,
  2638. { { image_get_component_active_invoker } }
  2639. };
  2640. static Argument *
  2641. image_set_component_active_invoker (Argument *args)
  2642. {
  2643. gboolean success = TRUE;
  2644. GimpImage *gimage;
  2645. gint32 component;
  2646. gboolean active;
  2647. gimage = pdb_id_to_image (args[0].value.pdb_int);
  2648. if (gimage == NULL)
  2649. success = FALSE;
  2650. component = args[1].value.pdb_int;
  2651. if (component < RED_CHANNEL || component > INDEXED_CHANNEL)
  2652. success = FALSE;
  2653. active = args[2].value.pdb_int ? TRUE : FALSE;
  2654. if (success)
  2655. {
  2656. if (component == GRAY_CHANNEL)
  2657. success = gimage_base_type (gimage) == GRAY;
  2658. else if (component == INDEXED_CHANNEL)
  2659. success = gimage_base_type (gimage) == INDEXED;
  2660. else
  2661. success = gimage_base_type (gimage) == RGB;
  2662. if (success)
  2663. gimage_set_component_active (gimage, component, active);
  2664. }
  2665. return procedural_db_return_args (&image_set_component_active_proc, success);
  2666. }
  2667. static ProcArg image_set_component_active_inargs[] =
  2668. {
  2669. {
  2670. PDB_IMAGE,
  2671. "image",
  2672. "The image"
  2673. },
  2674. {
  2675. PDB_INT32,
  2676. "component",
  2677. "The image component: { RED_CHANNEL (0), GREEN_CHANNEL (1), BLUE_CHANNEL (2), GRAY_CHANNEL (3), INDEXED_CHANNEL (4) }"
  2678. },
  2679. {
  2680. PDB_INT32,
  2681. "active",
  2682. "Component is active (TRUE or FALSE)"
  2683. }
  2684. };
  2685. static ProcRecord image_set_component_active_proc =
  2686. {
  2687. "gimp_image_set_component_active",
  2688. "Sets if the specified image's image component is active.",
  2689. "This procedure sets if the specified image's image component (i.e. Red, Green, Blue intensity channels in an RGB image) is active or inactive -- whether or not it can be modified. If the specified component is not valid for the image type, an error is returned.",
  2690. "Spencer Kimball & Peter Mattis",
  2691. "Spencer Kimball & Peter Mattis",
  2692. "1995-1996",
  2693. PDB_INTERNAL,
  2694. 3,
  2695. image_set_component_active_inargs,
  2696. 0,
  2697. NULL,
  2698. { { image_set_component_active_invoker } }
  2699. };
  2700. static Argument *
  2701. image_get_component_visible_invoker (Argument *args)
  2702. {
  2703. gboolean success = TRUE;
  2704. Argument *return_args;
  2705. GimpImage *gimage;
  2706. gint32 component;
  2707. gimage = pdb_id_to_image (args[0].value.pdb_int);
  2708. if (gimage == NULL)
  2709. success = FALSE;
  2710. component = args[1].value.pdb_int;
  2711. if (component < RED_CHANNEL || component > INDEXED_CHANNEL)
  2712. success = FALSE;
  2713. if (success)
  2714. {
  2715. if (component == GRAY_CHANNEL)
  2716. success = gimage_base_type (gimage) == GRAY;
  2717. else if (component == INDEXED_CHANNEL)
  2718. success = gimage_base_type (gimage) == INDEXED;
  2719. else
  2720. success = gimage_base_type (gimage) == RGB;
  2721. }
  2722. return_args = procedural_db_return_args (&image_get_component_visible_proc, success);
  2723. if (success)
  2724. return_args[1].value.pdb_int = gimage_get_component_visible (gimage, component);
  2725. return return_args;
  2726. }
  2727. static ProcArg image_get_component_visible_inargs[] =
  2728. {
  2729. {
  2730. PDB_IMAGE,
  2731. "image",
  2732. "The image"
  2733. },
  2734. {
  2735. PDB_INT32,
  2736. "component",
  2737. "The image component: { RED_CHANNEL (0), GREEN_CHANNEL (1), BLUE_CHANNEL (2), GRAY_CHANNEL (3), INDEXED_CHANNEL (4) }"
  2738. }
  2739. };
  2740. static ProcArg image_get_component_visible_outargs[] =
  2741. {
  2742. {
  2743. PDB_INT32,
  2744. "visible",
  2745. "Component is visible (TRUE or FALSE)"
  2746. }
  2747. };
  2748. static ProcRecord image_get_component_visible_proc =
  2749. {
  2750. "gimp_image_get_component_visible",
  2751. "Returns if the specified image's image component is visible.",
  2752. "This procedure returns if the specified image's image component (i.e. Red, Green, Blue intensity channels in an RGB image) is visible or invisible -- whether or not it can be seen. If the specified component is not valid for the image type, an error is returned.",
  2753. "Spencer Kimball & Peter Mattis",
  2754. "Spencer Kimball & Peter Mattis",
  2755. "1995-1996",
  2756. PDB_INTERNAL,
  2757. 2,
  2758. image_get_component_visible_inargs,
  2759. 1,
  2760. image_get_component_visible_outargs,
  2761. { { image_get_component_visible_invoker } }
  2762. };
  2763. static Argument *
  2764. image_set_component_visible_invoker (Argument *args)
  2765. {
  2766. gboolean success = TRUE;
  2767. GimpImage *gimage;
  2768. gint32 component;
  2769. gboolean visible;
  2770. gimage = pdb_id_to_image (args[0].value.pdb_int);
  2771. if (gimage == NULL)
  2772. success = FALSE;
  2773. component = args[1].value.pdb_int;
  2774. if (component < RED_CHANNEL || component > INDEXED_CHANNEL)
  2775. success = FALSE;
  2776. visible = args[2].value.pdb_int ? TRUE : FALSE;
  2777. if (success)
  2778. {
  2779. if (component == GRAY_CHANNEL)
  2780. success = gimage_base_type (gimage) == GRAY;
  2781. else if (component == INDEXED_CHANNEL)
  2782. success = gimage_base_type (gimage) == INDEXED;
  2783. else
  2784. success = gimage_base_type (gimage) == RGB;
  2785. if (success)
  2786. gimage_set_component_visible (gimage, component, visible);
  2787. }
  2788. return procedural_db_return_args (&image_set_component_visible_proc, success);
  2789. }
  2790. static ProcArg image_set_component_visible_inargs[] =
  2791. {
  2792. {
  2793. PDB_IMAGE,
  2794. "image",
  2795. "The image"
  2796. },
  2797. {
  2798. PDB_INT32,
  2799. "component",
  2800. "The image component: { RED_CHANNEL (0), GREEN_CHANNEL (1), BLUE_CHANNEL (2), GRAY_CHANNEL (3), INDEXED_CHANNEL (4) }"
  2801. },
  2802. {
  2803. PDB_INT32,
  2804. "visible",
  2805. "Component is visible (TRUE or FALSE)"
  2806. }
  2807. };
  2808. static ProcRecord image_set_component_visible_proc =
  2809. {
  2810. "gimp_image_set_component_visible",
  2811. "Sets if the specified image's image component is visible.",
  2812. "This procedure sets if the specified image's image component (i.e. Red, Green, Blue intensity channels in an RGB image) is visible or invisible -- whether or not it can be seen. If the specified component is not valid for the image type, an error is returned.",
  2813. "Spencer Kimball & Peter Mattis",
  2814. "Spencer Kimball & Peter Mattis",
  2815. "1995-1996",
  2816. PDB_INTERNAL,
  2817. 3,
  2818. image_set_component_visible_inargs,
  2819. 0,
  2820. NULL,
  2821. { { image_set_component_visible_invoker } }
  2822. };
  2823. static Argument *
  2824. image_get_filename_invoker (Argument *args)
  2825. {
  2826. gboolean success = TRUE;
  2827. Argument *return_args;
  2828. GimpImage *gimage;
  2829. gimage = pdb_id_to_image (args[0].value.pdb_int);
  2830. if (gimage == NULL)
  2831. success = FALSE;
  2832. return_args = procedural_db_return_args (&image_get_filename_proc, success);
  2833. if (success)
  2834. return_args[1].value.pdb_pointer = g_strdup (gimage_filename (gimage));
  2835. return return_args;
  2836. }
  2837. static ProcArg image_get_filename_inargs[] =
  2838. {
  2839. {
  2840. PDB_IMAGE,
  2841. "image",
  2842. "The image"
  2843. }
  2844. };
  2845. static ProcArg image_get_filename_outargs[] =
  2846. {
  2847. {
  2848. PDB_STRING,
  2849. "filename",
  2850. "The filename"
  2851. }
  2852. };
  2853. static ProcRecord image_get_filename_proc =
  2854. {
  2855. "gimp_image_get_filename",
  2856. "Returns the specified image's filename.",
  2857. "This procedure returns the specified image's filename -- if it was loaded or has since been saved. Otherwise, returns NULL.",
  2858. "Spencer Kimball & Peter Mattis",
  2859. "Spencer Kimball & Peter Mattis",
  2860. "1995-1996",
  2861. PDB_INTERNAL,
  2862. 1,
  2863. image_get_filename_inargs,
  2864. 1,
  2865. image_get_filename_outargs,
  2866. { { image_get_filename_invoker } }
  2867. };
  2868. static Argument *
  2869. image_set_filename_invoker (Argument *args)
  2870. {
  2871. gboolean success = TRUE;
  2872. GimpImage *gimage;
  2873. gchar *filename;
  2874. gimage = pdb_id_to_image (args[0].value.pdb_int);
  2875. if (gimage == NULL)
  2876. success = FALSE;
  2877. filename = (gchar *) args[1].value.pdb_pointer;
  2878. if (filename == NULL)
  2879. success = FALSE;
  2880. if (success)
  2881. gimage_set_filename (gimage, filename);
  2882. return procedural_db_return_args (&image_set_filename_proc, success);
  2883. }
  2884. static ProcArg image_set_filename_inargs[] =
  2885. {
  2886. {
  2887. PDB_IMAGE,
  2888. "image",
  2889. "The image"
  2890. },
  2891. {
  2892. PDB_STRING,
  2893. "filename",
  2894. "The new image filename"
  2895. }
  2896. };
  2897. static ProcRecord image_set_filename_proc =
  2898. {
  2899. "gimp_image_set_filename",
  2900. "Sets the specified image's filename.",
  2901. "This procedure sets the specified image's filename.",
  2902. "Spencer Kimball & Peter Mattis",
  2903. "Spencer Kimball & Peter Mattis",
  2904. "1995-1996",
  2905. PDB_INTERNAL,
  2906. 2,
  2907. image_set_filename_inargs,
  2908. 0,
  2909. NULL,
  2910. { { image_set_filename_invoker } }
  2911. };
  2912. static Argument *
  2913. image_get_resolution_invoker (Argument *args)
  2914. {
  2915. gboolean success = TRUE;
  2916. Argument *return_args;
  2917. GimpImage *gimage;
  2918. gimage = pdb_id_to_image (args[0].value.pdb_int);
  2919. if (gimage == NULL)
  2920. success = FALSE;
  2921. return_args = procedural_db_return_args (&image_get_resolution_proc, success);
  2922. if (success)
  2923. {
  2924. return_args[1].value.pdb_float = gimage->xresolution;
  2925. return_args[2].value.pdb_float = gimage->yresolution;
  2926. }
  2927. return return_args;
  2928. }
  2929. static ProcArg image_get_resolution_inargs[] =
  2930. {
  2931. {
  2932. PDB_IMAGE,
  2933. "image",
  2934. "The image"
  2935. }
  2936. };
  2937. static ProcArg image_get_resolution_outargs[] =
  2938. {
  2939. {
  2940. PDB_FLOAT,
  2941. "xresolution",
  2942. "The resolutionin the x-axis, in dots per inch"
  2943. },
  2944. {
  2945. PDB_FLOAT,
  2946. "yresolution",
  2947. "The resolutionin the y-axis, in dots per inch"
  2948. }
  2949. };
  2950. static ProcRecord image_get_resolution_proc =
  2951. {
  2952. "gimp_image_get_resolution",
  2953. "Returns the specified image's resolution.",
  2954. "This procedure returns the specified image's resolution in dots per inch. This value is independent of any of the layers in this image.",
  2955. "Austin Donnelly",
  2956. "Austin Donnelly",
  2957. "1998",
  2958. PDB_INTERNAL,
  2959. 1,
  2960. image_get_resolution_inargs,
  2961. 2,
  2962. image_get_resolution_outargs,
  2963. { { image_get_resolution_invoker } }
  2964. };
  2965. static Argument *
  2966. image_set_resolution_invoker (Argument *args)
  2967. {
  2968. gboolean success = TRUE;
  2969. GimpImage *gimage;
  2970. gdouble xresolution;
  2971. gdouble yresolution;
  2972. gimage = pdb_id_to_image (args[0].value.pdb_int);
  2973. if (gimage == NULL)
  2974. success = FALSE;
  2975. xresolution = args[1].value.pdb_float;
  2976. yresolution = args[2].value.pdb_float;
  2977. if (success)
  2978. {
  2979. if (!FINITE (xresolution) ||
  2980. xresolution < GIMP_MIN_RESOLUTION || xresolution > GIMP_MAX_RESOLUTION ||
  2981. !FINITE (yresolution) ||
  2982. yresolution < GIMP_MIN_RESOLUTION || yresolution > GIMP_MAX_RESOLUTION)
  2983. {
  2984. g_message (_("Image resolution is out of bounds,\n"
  2985. "using the default resolution instead."));
  2986. success = FALSE;
  2987. }
  2988. else
  2989. {
  2990. gimage->xresolution = xresolution;
  2991. gimage->yresolution = yresolution;
  2992. }
  2993. }
  2994. return procedural_db_return_args (&image_set_resolution_proc, success);
  2995. }
  2996. static ProcArg image_set_resolution_inargs[] =
  2997. {
  2998. {
  2999. PDB_IMAGE,
  3000. "image",
  3001. "The image"
  3002. },
  3003. {
  3004. PDB_FLOAT,
  3005. "xresolution",
  3006. "The new image resolution (xresolution)in the x-axis, in dots per inch"
  3007. },
  3008. {
  3009. PDB_FLOAT,
  3010. "yresolution",
  3011. "The new image resolution (yresolution)in the y-axis, in dots per inch"
  3012. }
  3013. };
  3014. static ProcRecord image_set_resolution_proc =
  3015. {
  3016. "gimp_image_set_resolution",
  3017. "Sets the specified image's resolution.",
  3018. "This procedure sets the specified image's resolution in dots per inch. This value is independent of any of the layers in this image. No scaling or resizing is performed.",
  3019. "Austin Donnelly",
  3020. "Austin Donnelly",
  3021. "1998",
  3022. PDB_INTERNAL,
  3023. 3,
  3024. image_set_resolution_inargs,
  3025. 0,
  3026. NULL,
  3027. { { image_set_resolution_invoker } }
  3028. };
  3029. static Argument *
  3030. image_get_unit_invoker (Argument *args)
  3031. {
  3032. gboolean success = TRUE;
  3033. Argument *return_args;
  3034. GimpImage *gimage;
  3035. gimage = pdb_id_to_image (args[0].value.pdb_int);
  3036. if (gimage == NULL)
  3037. success = FALSE;
  3038. return_args = procedural_db_return_args (&image_get_unit_proc, success);
  3039. if (success)
  3040. return_args[1].value.pdb_int = gimage->unit;
  3041. return return_args;
  3042. }
  3043. static ProcArg image_get_unit_inargs[] =
  3044. {
  3045. {
  3046. PDB_IMAGE,
  3047. "image",
  3048. "The image"
  3049. }
  3050. };
  3051. static ProcArg image_get_unit_outargs[] =
  3052. {
  3053. {
  3054. PDB_INT32,
  3055. "unit",
  3056. "The unit"
  3057. }
  3058. };
  3059. static ProcRecord image_get_unit_proc =
  3060. {
  3061. "gimp_image_get_unit",
  3062. "Returns the specified image's unit.",
  3063. "This procedure returns the specified image's unit. This value is independent of any of the layers in this image. See the gimp_unit_* procedure definitions for the valid range of unit IDs and a description of the unit system.",
  3064. "Michael Natterer",
  3065. "Michael Natterer",
  3066. "1998",
  3067. PDB_INTERNAL,
  3068. 1,
  3069. image_get_unit_inargs,
  3070. 1,
  3071. image_get_unit_outargs,
  3072. { { image_get_unit_invoker } }
  3073. };
  3074. static Argument *
  3075. image_set_unit_invoker (Argument *args)
  3076. {
  3077. gboolean success = TRUE;
  3078. GimpImage *gimage;
  3079. GimpUnit unit;
  3080. gimage = pdb_id_to_image (args[0].value.pdb_int);
  3081. if (gimage == NULL)
  3082. success = FALSE;
  3083. unit = args[1].value.pdb_int;
  3084. if (unit < GIMP_UNIT_INCH || unit >= gimp_unit_get_number_of_units ())
  3085. success = FALSE;
  3086. if (success)
  3087. gimage->unit = unit;
  3088. return procedural_db_return_args (&image_set_unit_proc, success);
  3089. }
  3090. static ProcArg image_set_unit_inargs[] =
  3091. {
  3092. {
  3093. PDB_IMAGE,
  3094. "image",
  3095. "The image"
  3096. },
  3097. {
  3098. PDB_INT32,
  3099. "unit",
  3100. "The new image unit"
  3101. }
  3102. };
  3103. static ProcRecord image_set_unit_proc =
  3104. {
  3105. "gimp_image_set_unit",
  3106. "Sets the specified image's unit.",
  3107. "This procedure sets the specified image's unit. No scaling or resizing is performed. This value is independent of any of the layers in this image. See the gimp_unit_* procedure definitions for the valid range of unit IDs and a description of the unit system.",
  3108. "Michael Natterer",
  3109. "Michael Natterer",
  3110. "1998",
  3111. PDB_INTERNAL,
  3112. 2,
  3113. image_set_unit_inargs,
  3114. 0,
  3115. NULL,
  3116. { { image_set_unit_invoker } }
  3117. };
  3118. static Argument *
  3119. image_get_layer_by_tattoo_invoker (Argument *args)
  3120. {
  3121. gboolean success = TRUE;
  3122. Argument *return_args;
  3123. GimpImage *gimage;
  3124. gint32 tattoo;
  3125. GimpLayer *layer = NULL;
  3126. gimage = pdb_id_to_image (args[0].value.pdb_int);
  3127. if (gimage == NULL)
  3128. success = FALSE;
  3129. tattoo = args[1].value.pdb_int;
  3130. if (tattoo == 0)
  3131. success = FALSE;
  3132. if (success)
  3133. {
  3134. layer = gimp_image_get_layer_by_tattoo (gimage, tattoo);
  3135. success = layer != NULL;
  3136. }
  3137. return_args = procedural_db_return_args (&image_get_layer_by_tattoo_proc, success);
  3138. if (success)
  3139. return_args[1].value.pdb_int = drawable_ID (GIMP_DRAWABLE (layer));
  3140. return return_args;
  3141. }
  3142. static ProcArg image_get_layer_by_tattoo_inargs[] =
  3143. {
  3144. {
  3145. PDB_IMAGE,
  3146. "image",
  3147. "The image"
  3148. },
  3149. {
  3150. PDB_INT32,
  3151. "tattoo",
  3152. "The tattoo of the layer to find"
  3153. }
  3154. };
  3155. static ProcArg image_get_layer_by_tattoo_outargs[] =
  3156. {
  3157. {
  3158. PDB_LAYER,
  3159. "layer",
  3160. "The layer with the specified tattoo"
  3161. }
  3162. };
  3163. static ProcRecord image_get_layer_by_tattoo_proc =
  3164. {
  3165. "gimp_image_get_layer_by_tattoo",
  3166. "Find a layer with a given tattoo in an image.",
  3167. "This procedure returns the layer with the given tattoo in the specified image.",
  3168. "Jay Cox",
  3169. "Jay Cox",
  3170. "1998",
  3171. PDB_INTERNAL,
  3172. 2,
  3173. image_get_layer_by_tattoo_inargs,
  3174. 1,
  3175. image_get_layer_by_tattoo_outargs,
  3176. { { image_get_layer_by_tattoo_invoker } }
  3177. };
  3178. static Argument *
  3179. image_get_channel_by_tattoo_invoker (Argument *args)
  3180. {
  3181. gboolean success = TRUE;
  3182. Argument *return_args;
  3183. GimpImage *gimage;
  3184. gint32 tattoo;
  3185. Channel *channel = NULL;
  3186. gimage = pdb_id_to_image (args[0].value.pdb_int);
  3187. if (gimage == NULL)
  3188. success = FALSE;
  3189. tattoo = args[1].value.pdb_int;
  3190. if (tattoo == 0)
  3191. success = FALSE;
  3192. if (success)
  3193. {
  3194. channel = gimp_image_get_channel_by_tattoo (gimage, tattoo);
  3195. success = channel != NULL;
  3196. }
  3197. return_args = procedural_db_return_args (&image_get_channel_by_tattoo_proc, success);
  3198. if (success)
  3199. return_args[1].value.pdb_int = drawable_ID (GIMP_DRAWABLE (channel));
  3200. return return_args;
  3201. }
  3202. static ProcArg image_get_channel_by_tattoo_inargs[] =
  3203. {
  3204. {
  3205. PDB_IMAGE,
  3206. "image",
  3207. "The image"
  3208. },
  3209. {
  3210. PDB_INT32,
  3211. "tattoo",
  3212. "The tattoo of the channel to find"
  3213. }
  3214. };
  3215. static ProcArg image_get_channel_by_tattoo_outargs[] =
  3216. {
  3217. {
  3218. PDB_CHANNEL,
  3219. "channel",
  3220. "The channel with the specified tattoo"
  3221. }
  3222. };
  3223. static ProcRecord image_get_channel_by_tattoo_proc =
  3224. {
  3225. "gimp_image_get_channel_by_tattoo",
  3226. "Find a channel with a given tattoo in an image.",
  3227. "This procedure returns the channel with the given tattoo in the specified image.",
  3228. "Jay Cox",
  3229. "Jay Cox",
  3230. "1998",
  3231. PDB_INTERNAL,
  3232. 2,
  3233. image_get_channel_by_tattoo_inargs,
  3234. 1,
  3235. image_get_channel_by_tattoo_outargs,
  3236. { { image_get_channel_by_tattoo_invoker } }
  3237. };