1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591
|
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* gimppalette_pdb.c
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#include "config.h"
#include <string.h>
#include "gimp.h"
/**
* SECTION: gimppalette
* @title: gimppalette
* @short_description: Functions operating on a single palette.
*
* Functions operating on a single palette.
**/
/**
* gimp_palette_new:
* @name: The requested name of the new palette.
*
* Creates a new palette
*
* This procedure creates a new, uninitialized palette
*
* Returns: The actual new palette name.
*
* Since: 2.2
**/
gchar *
gimp_palette_new (const gchar *name)
{
GimpParam *return_vals;
gint nreturn_vals;
gchar *actual_name = NULL;
return_vals = gimp_run_procedure ("gimp-palette-new",
&nreturn_vals,
GIMP_PDB_STRING, name,
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
actual_name = g_strdup (return_vals[1].data.d_string);
gimp_destroy_params (return_vals, nreturn_vals);
return actual_name;
}
/**
* gimp_palette_duplicate:
* @name: The palette name.
*
* Duplicates a palette
*
* This procedure creates an identical palette by a different name
*
* Returns: The name of the palette's copy.
*
* Since: 2.2
**/
gchar *
gimp_palette_duplicate (const gchar *name)
{
GimpParam *return_vals;
gint nreturn_vals;
gchar *copy_name = NULL;
return_vals = gimp_run_procedure ("gimp-palette-duplicate",
&nreturn_vals,
GIMP_PDB_STRING, name,
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
copy_name = g_strdup (return_vals[1].data.d_string);
gimp_destroy_params (return_vals, nreturn_vals);
return copy_name;
}
/**
* gimp_palette_rename:
* @name: The palette name.
* @new_name: The new name of the palette.
*
* Rename a palette
*
* This procedure renames a palette
*
* Returns: The actual new name of the palette.
*
* Since: 2.2
**/
gchar *
gimp_palette_rename (const gchar *name,
const gchar *new_name)
{
GimpParam *return_vals;
gint nreturn_vals;
gchar *actual_name = NULL;
return_vals = gimp_run_procedure ("gimp-palette-rename",
&nreturn_vals,
GIMP_PDB_STRING, name,
GIMP_PDB_STRING, new_name,
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
actual_name = g_strdup (return_vals[1].data.d_string);
gimp_destroy_params (return_vals, nreturn_vals);
return actual_name;
}
/**
* gimp_palette_delete:
* @name: The palette name.
*
* Deletes a palette
*
* This procedure deletes a palette
*
* Returns: TRUE on success.
*
* Since: 2.2
**/
gboolean
gimp_palette_delete (const gchar *name)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-palette-delete",
&nreturn_vals,
GIMP_PDB_STRING, name,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_palette_is_editable:
* @name: The palette name.
*
* Tests if palette can be edited
*
* Returns TRUE if you have permission to change the palette
*
* Returns: TRUE if the palette can be edited.
*
* Since: 2.4
**/
gboolean
gimp_palette_is_editable (const gchar *name)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean editable = FALSE;
return_vals = gimp_run_procedure ("gimp-palette-is-editable",
&nreturn_vals,
GIMP_PDB_STRING, name,
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
editable = return_vals[1].data.d_int32;
gimp_destroy_params (return_vals, nreturn_vals);
return editable;
}
/**
* gimp_palette_get_info:
* @name: The palette name.
* @num_colors: The number of colors in the palette.
*
* Retrieve information about the specified palette.
*
* This procedure retrieves information about the specified palette.
* This includes the name, and the number of colors.
*
* Returns: TRUE on success.
*
* Since: 2.2
**/
gboolean
gimp_palette_get_info (const gchar *name,
gint *num_colors)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-palette-get-info",
&nreturn_vals,
GIMP_PDB_STRING, name,
GIMP_PDB_END);
*num_colors = 0;
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
if (success)
*num_colors = return_vals[1].data.d_int32;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_palette_get_colors:
* @name: The palette name.
* @num_colors: Length of the colors array.
*
* Gets all colors from the specified palette.
*
* This procedure retrieves all color entries of the specified palette.
*
* Returns: The colors in the palette.
*
* Since: 2.6
**/
GimpRGB *
gimp_palette_get_colors (const gchar *name,
gint *num_colors)
{
GimpParam *return_vals;
gint nreturn_vals;
GimpRGB *colors = NULL;
return_vals = gimp_run_procedure ("gimp-palette-get-colors",
&nreturn_vals,
GIMP_PDB_STRING, name,
GIMP_PDB_END);
*num_colors = 0;
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
{
*num_colors = return_vals[1].data.d_int32;
colors = g_new (GimpRGB, *num_colors);
memcpy (colors,
return_vals[2].data.d_colorarray,
*num_colors * sizeof (GimpRGB));
}
gimp_destroy_params (return_vals, nreturn_vals);
return colors;
}
/**
* gimp_palette_get_columns:
* @name: The palette name.
*
* Retrieves the number of columns to use to display this palette
*
* This procedures retrieves the preferred number of columns to use
* when the palette is being displayed.
*
* Returns: The number of columns used to display this palette.
*
* Since: 2.4
**/
gint
gimp_palette_get_columns (const gchar *name)
{
GimpParam *return_vals;
gint nreturn_vals;
gint num_columns = 0;
return_vals = gimp_run_procedure ("gimp-palette-get-columns",
&nreturn_vals,
GIMP_PDB_STRING, name,
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
num_columns = return_vals[1].data.d_int32;
gimp_destroy_params (return_vals, nreturn_vals);
return num_columns;
}
/**
* gimp_palette_set_columns:
* @name: The palette name.
* @columns: The new number of columns.
*
* Sets the number of columns to use when displaying the palette
*
* This procedures controls how many colors are shown per row when the
* palette is being displayed. This value can only be changed if the
* palette is writable. The maximum allowed value is 64.
*
* Returns: TRUE on success.
*
* Since: 2.4
**/
gboolean
gimp_palette_set_columns (const gchar *name,
gint columns)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-palette-set-columns",
&nreturn_vals,
GIMP_PDB_STRING, name,
GIMP_PDB_INT32, columns,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_palette_add_entry:
* @name: The palette name.
* @entry_name: The name of the entry.
* @color: The new entry's color color.
* @entry_num: The index of the added entry.
*
* Adds a palette entry to the specified palette.
*
* This procedure adds an entry to the specified palette. It returns an
* error if the entry palette does not exist.
*
* Returns: TRUE on success.
*
* Since: 2.2
**/
gboolean
gimp_palette_add_entry (const gchar *name,
const gchar *entry_name,
const GimpRGB *color,
gint *entry_num)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-palette-add-entry",
&nreturn_vals,
GIMP_PDB_STRING, name,
GIMP_PDB_STRING, entry_name,
GIMP_PDB_COLOR, color,
GIMP_PDB_END);
*entry_num = 0;
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
if (success)
*entry_num = return_vals[1].data.d_int32;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_palette_delete_entry:
* @name: The palette name.
* @entry_num: The index of the added entry.
*
* Deletes a palette entry from the specified palette.
*
* This procedure deletes an entry from the specified palette. It
* returns an error if the entry palette does not exist.
*
* Returns: TRUE on success.
*
* Since: 2.2
**/
gboolean
gimp_palette_delete_entry (const gchar *name,
gint entry_num)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-palette-delete-entry",
&nreturn_vals,
GIMP_PDB_STRING, name,
GIMP_PDB_INT32, entry_num,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_palette_entry_get_color:
* @name: The palette name.
* @entry_num: The entry to retrieve.
* @color: The color requested.
*
* Gets the specified palette entry from the specified palette.
*
* This procedure retrieves the color of the zero-based entry specified
* for the specified palette. It returns an error if the entry does not
* exist.
*
* Returns: TRUE on success.
*
* Since: 2.2
**/
gboolean
gimp_palette_entry_get_color (const gchar *name,
gint entry_num,
GimpRGB *color)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-palette-entry-get-color",
&nreturn_vals,
GIMP_PDB_STRING, name,
GIMP_PDB_INT32, entry_num,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
if (success)
*color = return_vals[1].data.d_color;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_palette_entry_set_color:
* @name: The palette name.
* @entry_num: The entry to retrieve.
* @color: The new color.
*
* Sets the specified palette entry in the specified palette.
*
* This procedure sets the color of the zero-based entry specified for
* the specified palette. It returns an error if the entry does not
* exist.
*
* Returns: TRUE on success.
*
* Since: 2.2
**/
gboolean
gimp_palette_entry_set_color (const gchar *name,
gint entry_num,
const GimpRGB *color)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-palette-entry-set-color",
&nreturn_vals,
GIMP_PDB_STRING, name,
GIMP_PDB_INT32, entry_num,
GIMP_PDB_COLOR, color,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_palette_entry_get_name:
* @name: The palette name.
* @entry_num: The entry to retrieve.
* @entry_name: The name requested.
*
* Gets the specified palette entry from the specified palette.
*
* This procedure retrieves the name of the zero-based entry specified
* for the specified palette. It returns an error if the entry does not
* exist.
*
* Returns: TRUE on success.
*
* Since: 2.2
**/
gboolean
gimp_palette_entry_get_name (const gchar *name,
gint entry_num,
gchar **entry_name)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-palette-entry-get-name",
&nreturn_vals,
GIMP_PDB_STRING, name,
GIMP_PDB_INT32, entry_num,
GIMP_PDB_END);
*entry_name = NULL;
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
if (success)
*entry_name = g_strdup (return_vals[1].data.d_string);
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_palette_entry_set_name:
* @name: The palette name.
* @entry_num: The entry to retrieve.
* @entry_name: The new name.
*
* Sets the specified palette entry in the specified palette.
*
* This procedure sets the name of the zero-based entry specified for
* the specified palette. It returns an error if the entry does not
* exist.
*
* Returns: TRUE on success.
*
* Since: 2.2
**/
gboolean
gimp_palette_entry_set_name (const gchar *name,
gint entry_num,
const gchar *entry_name)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-palette-entry-set-name",
&nreturn_vals,
GIMP_PDB_STRING, name,
GIMP_PDB_INT32, entry_num,
GIMP_PDB_STRING, entry_name,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
|