gimppaths_pdb.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  1. /* LIBGIMP - The GIMP Library
  2. * Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
  3. *
  4. * gimppaths_pdb.c
  5. *
  6. * This library is free software: you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 3 of the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with this library. If not, see
  18. * <http://www.gnu.org/licenses/>.
  19. */
  20. /* NOTE: This file is auto-generated by pdbgen.pl */
  21. #include "config.h"
  22. #include <string.h>
  23. #include "gimp.h"
  24. /**
  25. * SECTION: gimppaths
  26. * @title: gimppaths
  27. * @short_description: Deprecated operations related to paths.
  28. *
  29. * Deprecated operations related to paths.
  30. **/
  31. /**
  32. * gimp_path_list:
  33. * @image_ID: The image to list the paths from.
  34. * @num_paths: The number of paths returned.
  35. *
  36. * Deprecated: Use gimp_image_get_vectors() instead.
  37. *
  38. * Returns: List of the paths belonging to this image.
  39. **/
  40. gchar **
  41. gimp_path_list (gint32 image_ID,
  42. gint *num_paths)
  43. {
  44. GimpParam *return_vals;
  45. gint nreturn_vals;
  46. gchar **path_list = NULL;
  47. gint i;
  48. return_vals = gimp_run_procedure ("gimp-path-list",
  49. &nreturn_vals,
  50. GIMP_PDB_IMAGE, image_ID,
  51. GIMP_PDB_END);
  52. *num_paths = 0;
  53. if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  54. {
  55. *num_paths = return_vals[1].data.d_int32;
  56. path_list = g_new (gchar *, *num_paths);
  57. for (i = 0; i < *num_paths; i++)
  58. path_list[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
  59. }
  60. gimp_destroy_params (return_vals, nreturn_vals);
  61. return path_list;
  62. }
  63. /**
  64. * gimp_path_get_current:
  65. * @image_ID: The image to get the current path from.
  66. *
  67. * Deprecated: Use gimp_image_get_active_vectors() instead.
  68. *
  69. * Returns: The name of the current path.
  70. **/
  71. gchar *
  72. gimp_path_get_current (gint32 image_ID)
  73. {
  74. GimpParam *return_vals;
  75. gint nreturn_vals;
  76. gchar *name = NULL;
  77. return_vals = gimp_run_procedure ("gimp-path-get-current",
  78. &nreturn_vals,
  79. GIMP_PDB_IMAGE, image_ID,
  80. GIMP_PDB_END);
  81. if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  82. name = g_strdup (return_vals[1].data.d_string);
  83. gimp_destroy_params (return_vals, nreturn_vals);
  84. return name;
  85. }
  86. /**
  87. * gimp_path_set_current:
  88. * @image_ID: The image in which a path will become current.
  89. * @name: The name of the path to make current.
  90. *
  91. * Deprecated: Use gimp_image_set_active_vectors() instead.
  92. *
  93. * Returns: TRUE on success.
  94. **/
  95. gboolean
  96. gimp_path_set_current (gint32 image_ID,
  97. const gchar *name)
  98. {
  99. GimpParam *return_vals;
  100. gint nreturn_vals;
  101. gboolean success = TRUE;
  102. return_vals = gimp_run_procedure ("gimp-path-set-current",
  103. &nreturn_vals,
  104. GIMP_PDB_IMAGE, image_ID,
  105. GIMP_PDB_STRING, name,
  106. GIMP_PDB_END);
  107. success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  108. gimp_destroy_params (return_vals, nreturn_vals);
  109. return success;
  110. }
  111. /**
  112. * gimp_path_delete:
  113. * @image_ID: The image to delete the path from.
  114. * @name: The name of the path to delete.
  115. *
  116. * Deprecated: Use gimp_image_remove_vectors() instead.
  117. *
  118. * Returns: TRUE on success.
  119. **/
  120. gboolean
  121. gimp_path_delete (gint32 image_ID,
  122. const gchar *name)
  123. {
  124. GimpParam *return_vals;
  125. gint nreturn_vals;
  126. gboolean success = TRUE;
  127. return_vals = gimp_run_procedure ("gimp-path-delete",
  128. &nreturn_vals,
  129. GIMP_PDB_IMAGE, image_ID,
  130. GIMP_PDB_STRING, name,
  131. GIMP_PDB_END);
  132. success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  133. gimp_destroy_params (return_vals, nreturn_vals);
  134. return success;
  135. }
  136. /**
  137. * gimp_path_get_points:
  138. * @image_ID: The image to list the paths from.
  139. * @name: The name of the path whose points should be listed.
  140. * @path_closed: Return if the path is closed. (0 = path open, 1 = path closed).
  141. * @num_path_point_details: The number of points returned. Each point is made up of (x, y, pnt_type) of floats.
  142. * @points_pairs: The points in the path represented as 3 floats. The first is the x pos, next is the y pos, last is the type of the pnt. The type field is dependant on the path type. For beziers (type 1 paths) the type can either be (1.0 = BEZIER_ANCHOR, 2.0 = BEZIER_CONTROL, 3.0 = BEZIER_MOVE). Note all points are returned in pixel resolution.
  143. *
  144. * Deprecated: Use gimp_vectors_stroke_get_points() instead.
  145. *
  146. * Returns: The type of the path. Currently only one type (1 = Bezier) is supported.
  147. **/
  148. gint
  149. gimp_path_get_points (gint32 image_ID,
  150. const gchar *name,
  151. gint *path_closed,
  152. gint *num_path_point_details,
  153. gdouble **points_pairs)
  154. {
  155. GimpParam *return_vals;
  156. gint nreturn_vals;
  157. gint path_type = 0;
  158. return_vals = gimp_run_procedure ("gimp-path-get-points",
  159. &nreturn_vals,
  160. GIMP_PDB_IMAGE, image_ID,
  161. GIMP_PDB_STRING, name,
  162. GIMP_PDB_END);
  163. *num_path_point_details = 0;
  164. if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  165. {
  166. path_type = return_vals[1].data.d_int32;
  167. *path_closed = return_vals[2].data.d_int32;
  168. *num_path_point_details = return_vals[3].data.d_int32;
  169. *points_pairs = g_new (gdouble, *num_path_point_details);
  170. memcpy (*points_pairs,
  171. return_vals[4].data.d_floatarray,
  172. *num_path_point_details * sizeof (gdouble));
  173. }
  174. gimp_destroy_params (return_vals, nreturn_vals);
  175. return path_type;
  176. }
  177. /**
  178. * gimp_path_set_points:
  179. * @image_ID: The image to set the paths in.
  180. * @name: The name of the path to create. If it exists then a unique name will be created - query the list of paths if you want to make sure that the name of the path you create is unique. This will be set as the current path.
  181. * @ptype: The type of the path. Currently only one type (1 = Bezier) is supported.
  182. * @num_path_points: The number of elements in the array, i.e. the number of points in the path * 3. Each point is made up of (x, y, type) of floats. Currently only the creation of bezier curves is allowed. The type parameter must be set to (1) to indicate a BEZIER type curve. Note that for BEZIER curves, points must be given in the following order: ACCACCAC... If the path is not closed the last control point is missed off. Points consist of three control points (control/anchor/control) so for a curve that is not closed there must be at least two points passed (2 x,y pairs). If (num_path_points/3) % 3 = 0 then the path is assumed to be closed and the points are ACCACCACCACC.
  183. * @points_pairs: The points in the path represented as 3 floats. The first is the x pos, next is the y pos, last is the type of the pnt. The type field is dependant on the path type. For beziers (type 1 paths) the type can either be (1.0 = BEZIER_ANCHOR, 2.0 = BEZIER_CONTROL, 3.0= BEZIER_MOVE). Note all points are returned in pixel resolution.
  184. *
  185. * Deprecated: Use gimp_vectors_stroke_new_from_points() instead.
  186. *
  187. * Returns: TRUE on success.
  188. **/
  189. gboolean
  190. gimp_path_set_points (gint32 image_ID,
  191. const gchar *name,
  192. gint ptype,
  193. gint num_path_points,
  194. const gdouble *points_pairs)
  195. {
  196. GimpParam *return_vals;
  197. gint nreturn_vals;
  198. gboolean success = TRUE;
  199. return_vals = gimp_run_procedure ("gimp-path-set-points",
  200. &nreturn_vals,
  201. GIMP_PDB_IMAGE, image_ID,
  202. GIMP_PDB_STRING, name,
  203. GIMP_PDB_INT32, ptype,
  204. GIMP_PDB_INT32, num_path_points,
  205. GIMP_PDB_FLOATARRAY, points_pairs,
  206. GIMP_PDB_END);
  207. success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  208. gimp_destroy_params (return_vals, nreturn_vals);
  209. return success;
  210. }
  211. /**
  212. * gimp_path_stroke_current:
  213. * @image_ID: The image which contains the path to stroke.
  214. *
  215. * Deprecated: Use gimp_edit_stroke_vectors() instead.
  216. *
  217. * Returns: TRUE on success.
  218. **/
  219. gboolean
  220. gimp_path_stroke_current (gint32 image_ID)
  221. {
  222. GimpParam *return_vals;
  223. gint nreturn_vals;
  224. gboolean success = TRUE;
  225. return_vals = gimp_run_procedure ("gimp-path-stroke-current",
  226. &nreturn_vals,
  227. GIMP_PDB_IMAGE, image_ID,
  228. GIMP_PDB_END);
  229. success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  230. gimp_destroy_params (return_vals, nreturn_vals);
  231. return success;
  232. }
  233. /**
  234. * gimp_path_get_point_at_dist:
  235. * @image_ID: The image the paths belongs to.
  236. * @distance: The distance along the path.
  237. * @y_point: The y position of the point.
  238. * @slope: The slope (dy / dx) at the specified point.
  239. *
  240. * Deprecated: Use gimp_vectors_stroke_get_point_at_dist() instead.
  241. *
  242. * Returns: The x position of the point.
  243. **/
  244. gint
  245. gimp_path_get_point_at_dist (gint32 image_ID,
  246. gdouble distance,
  247. gint *y_point,
  248. gdouble *slope)
  249. {
  250. GimpParam *return_vals;
  251. gint nreturn_vals;
  252. gint x_point = 0;
  253. return_vals = gimp_run_procedure ("gimp-path-get-point-at-dist",
  254. &nreturn_vals,
  255. GIMP_PDB_IMAGE, image_ID,
  256. GIMP_PDB_FLOAT, distance,
  257. GIMP_PDB_END);
  258. if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  259. {
  260. x_point = return_vals[1].data.d_int32;
  261. *y_point = return_vals[2].data.d_int32;
  262. *slope = return_vals[3].data.d_float;
  263. }
  264. gimp_destroy_params (return_vals, nreturn_vals);
  265. return x_point;
  266. }
  267. /**
  268. * gimp_path_get_tattoo:
  269. * @image_ID: The image.
  270. * @name: The name of the path whose tattoo should be obtained.
  271. *
  272. * Deprecated: Use gimp_vectors_get_tattoo() instead.
  273. *
  274. * Returns: The tattoo associated with the named path.
  275. **/
  276. gint
  277. gimp_path_get_tattoo (gint32 image_ID,
  278. const gchar *name)
  279. {
  280. GimpParam *return_vals;
  281. gint nreturn_vals;
  282. gint tattoo = 0;
  283. return_vals = gimp_run_procedure ("gimp-path-get-tattoo",
  284. &nreturn_vals,
  285. GIMP_PDB_IMAGE, image_ID,
  286. GIMP_PDB_STRING, name,
  287. GIMP_PDB_END);
  288. if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  289. tattoo = return_vals[1].data.d_int32;
  290. gimp_destroy_params (return_vals, nreturn_vals);
  291. return tattoo;
  292. }
  293. /**
  294. * gimp_path_set_tattoo:
  295. * @image_ID: The image.
  296. * @name: the name of the path whose tattoo should be set.
  297. * @tattovalue: The tattoo associated with the name path. Only values returned from 'path_get_tattoo' should be used here.
  298. *
  299. * Deprecated: Use gimp_vectors_set_tattoo() instead.
  300. *
  301. * Returns: TRUE on success.
  302. **/
  303. gboolean
  304. gimp_path_set_tattoo (gint32 image_ID,
  305. const gchar *name,
  306. gint tattovalue)
  307. {
  308. GimpParam *return_vals;
  309. gint nreturn_vals;
  310. gboolean success = TRUE;
  311. return_vals = gimp_run_procedure ("gimp-path-set-tattoo",
  312. &nreturn_vals,
  313. GIMP_PDB_IMAGE, image_ID,
  314. GIMP_PDB_STRING, name,
  315. GIMP_PDB_INT32, tattovalue,
  316. GIMP_PDB_END);
  317. success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  318. gimp_destroy_params (return_vals, nreturn_vals);
  319. return success;
  320. }
  321. /**
  322. * gimp_get_path_by_tattoo:
  323. * @image_ID: The image.
  324. * @tattoo: The tattoo of the required path.
  325. *
  326. * Deprecated: Use gimp_image_get_vectors_by_tattoo() instead.
  327. *
  328. * Returns: The name of the path with the specified tattoo.
  329. **/
  330. gchar *
  331. gimp_get_path_by_tattoo (gint32 image_ID,
  332. gint tattoo)
  333. {
  334. GimpParam *return_vals;
  335. gint nreturn_vals;
  336. gchar *name = NULL;
  337. return_vals = gimp_run_procedure ("gimp-get-path-by-tattoo",
  338. &nreturn_vals,
  339. GIMP_PDB_IMAGE, image_ID,
  340. GIMP_PDB_INT32, tattoo,
  341. GIMP_PDB_END);
  342. if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  343. name = g_strdup (return_vals[1].data.d_string);
  344. gimp_destroy_params (return_vals, nreturn_vals);
  345. return name;
  346. }
  347. /**
  348. * gimp_path_get_locked:
  349. * @image_ID: The image.
  350. * @name: The name of the path whose locked status should be obtained.
  351. *
  352. * Deprecated: Use gimp_vectors_get_linked() instead.
  353. *
  354. * Returns: TRUE if the path is locked, FALSE otherwise.
  355. **/
  356. gboolean
  357. gimp_path_get_locked (gint32 image_ID,
  358. const gchar *name)
  359. {
  360. GimpParam *return_vals;
  361. gint nreturn_vals;
  362. gboolean locked = FALSE;
  363. return_vals = gimp_run_procedure ("gimp-path-get-locked",
  364. &nreturn_vals,
  365. GIMP_PDB_IMAGE, image_ID,
  366. GIMP_PDB_STRING, name,
  367. GIMP_PDB_END);
  368. if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  369. locked = return_vals[1].data.d_int32;
  370. gimp_destroy_params (return_vals, nreturn_vals);
  371. return locked;
  372. }
  373. /**
  374. * gimp_path_set_locked:
  375. * @image_ID: The image.
  376. * @name: the name of the path whose locked status should be set.
  377. * @locked: Whether the path is locked.
  378. *
  379. * Deprecated: Use gimp_vectors_set_linked() instead.
  380. *
  381. * Returns: TRUE on success.
  382. **/
  383. gboolean
  384. gimp_path_set_locked (gint32 image_ID,
  385. const gchar *name,
  386. gboolean locked)
  387. {
  388. GimpParam *return_vals;
  389. gint nreturn_vals;
  390. gboolean success = TRUE;
  391. return_vals = gimp_run_procedure ("gimp-path-set-locked",
  392. &nreturn_vals,
  393. GIMP_PDB_IMAGE, image_ID,
  394. GIMP_PDB_STRING, name,
  395. GIMP_PDB_INT32, locked,
  396. GIMP_PDB_END);
  397. success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  398. gimp_destroy_params (return_vals, nreturn_vals);
  399. return success;
  400. }
  401. /**
  402. * gimp_path_to_selection:
  403. * @image_ID: The image.
  404. * @name: The name of the path which should be made into selection.
  405. * @op: The desired operation with current selection.
  406. * @antialias: Antialias selection.
  407. * @feather: Feather selection.
  408. * @feather_radius_x: Feather radius x.
  409. * @feather_radius_y: Feather radius y.
  410. *
  411. * Deprecated: Use gimp_vectors_to_selection() instead.
  412. *
  413. * Returns: TRUE on success.
  414. **/
  415. gboolean
  416. gimp_path_to_selection (gint32 image_ID,
  417. const gchar *name,
  418. GimpChannelOps op,
  419. gboolean antialias,
  420. gboolean feather,
  421. gdouble feather_radius_x,
  422. gdouble feather_radius_y)
  423. {
  424. GimpParam *return_vals;
  425. gint nreturn_vals;
  426. gboolean success = TRUE;
  427. return_vals = gimp_run_procedure ("gimp-path-to-selection",
  428. &nreturn_vals,
  429. GIMP_PDB_IMAGE, image_ID,
  430. GIMP_PDB_STRING, name,
  431. GIMP_PDB_INT32, op,
  432. GIMP_PDB_INT32, antialias,
  433. GIMP_PDB_INT32, feather,
  434. GIMP_PDB_FLOAT, feather_radius_x,
  435. GIMP_PDB_FLOAT, feather_radius_y,
  436. GIMP_PDB_END);
  437. success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  438. gimp_destroy_params (return_vals, nreturn_vals);
  439. return success;
  440. }
  441. /**
  442. * gimp_path_import:
  443. * @image_ID: The image.
  444. * @filename: The name of the SVG file to import.
  445. * @merge: Merge paths into a single vectors object.
  446. * @scale: Scale the SVG to image dimensions.
  447. *
  448. * Deprecated: Use gimp_vectors_import_from_file() instead.
  449. *
  450. * Returns: TRUE on success.
  451. **/
  452. gboolean
  453. gimp_path_import (gint32 image_ID,
  454. const gchar *filename,
  455. gboolean merge,
  456. gboolean scale)
  457. {
  458. GimpParam *return_vals;
  459. gint nreturn_vals;
  460. gboolean success = TRUE;
  461. return_vals = gimp_run_procedure ("gimp-path-import",
  462. &nreturn_vals,
  463. GIMP_PDB_IMAGE, image_ID,
  464. GIMP_PDB_STRING, filename,
  465. GIMP_PDB_INT32, merge,
  466. GIMP_PDB_INT32, scale,
  467. GIMP_PDB_END);
  468. success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  469. gimp_destroy_params (return_vals, nreturn_vals);
  470. return success;
  471. }