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 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943
|
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdio.h>
#include <stdlib.h>
#include "appenv.h"
#include "general.h"
#include "gimage.h"
#include "channel.h"
#include "channel_cmds.h"
#include "channel_pvt.h"
static int int_value;
static double fp_value;
static int success;
/*****************/
/* CHANNEL_NEW */
static Argument *
channel_new_invoker (Argument *args)
{
Channel *channel;
int gimage_id;
int width, height;
char *name;
int opacity;
unsigned char color[3];
Argument *return_args;
channel = NULL;
gimage_id = -1;
opacity = 255;
success = TRUE;
if (success)
{
int_value = args[0].value.pdb_int;
if (gimage_get_ID (int_value) != NULL)
gimage_id = int_value;
else
success = FALSE;
}
if (success)
{
width = args[1].value.pdb_int;
height = args[2].value.pdb_int;
success = (width > 0 && height > 0);
}
if (success)
name = (char *) args[3].value.pdb_pointer;
if (success)
{
fp_value = args[4].value.pdb_float;
if (fp_value >= 0 && fp_value <= 100)
opacity = (int) ((fp_value * 255) / 100);
else
success = FALSE;
}
if (success)
{
int i;
unsigned char *color_array;
color_array = (unsigned char *) args[5].value.pdb_pointer;
for (i = 0; i < 3; i++)
color[i] = color_array[i];
}
if (success)
success = ((channel = channel_new (gimage_id, width, height, name, opacity, color)) != NULL);
return_args = procedural_db_return_args (&channel_new_proc, success);
if (success)
return_args[1].value.pdb_int = GIMP_DRAWABLE(channel)->ID;
return return_args;
}
/* The procedure definition */
ProcArg channel_new_args[] =
{
{ PDB_IMAGE,
"image",
"the image to which to add the channel"
},
{ PDB_INT32,
"width",
"the channel width: (width > 0)"
},
{ PDB_INT32,
"height",
"the channel height: (height > 0)"
},
{ PDB_STRING,
"name",
"the channel name"
},
{ PDB_FLOAT,
"opacity",
"the channel opacity: (0 <= opacity <= 100)"
},
{ PDB_COLOR,
"color",
"the channel compositing color"
}
};
ProcArg channel_new_out_args[] =
{
{ PDB_CHANNEL,
"channel",
"the newly created channel"
}
};
ProcRecord channel_new_proc =
{
"gimp_channel_new",
"Create a new channel",
"This procedure creates a new channel with the specified width and height. Name, opacity, and color are also supplied parameters. The new channel still needs to be added to the image, as this is not automatic. Add the new channel with the 'gimp_image_add_channel' command. Other attributes such as channel show masked, should be set with explicit procedure calls. The channel's contents are undefined initially.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
PDB_INTERNAL,
/* Input arguments */
6,
channel_new_args,
/* Output arguments */
1,
channel_new_out_args,
/* Exec method */
{ { channel_new_invoker } },
};
/******************/
/* CHANNEL_COPY */
static Argument *
channel_copy_invoker (Argument *args)
{
Channel *channel;
Channel *copy;
Argument *return_args;
copy = NULL;
success = TRUE;
if (success)
{
int_value = args[0].value.pdb_int;
if ((channel = channel_get_ID (int_value)) == NULL)
success = FALSE;
}
if (success)
success = ((copy = channel_copy (channel)) != NULL);
return_args = procedural_db_return_args (&channel_copy_proc, success);
if (success)
return_args[1].value.pdb_int = GIMP_DRAWABLE(copy)->ID;
return return_args;
}
/* The procedure definition */
ProcArg channel_copy_args[] =
{
{ PDB_CHANNEL,
"channel",
"the channel to copy"
}
};
ProcArg channel_copy_out_args[] =
{
{ PDB_CHANNEL,
"channel_copy",
"the newly copied channel"
}
};
ProcRecord channel_copy_proc =
{
"gimp_channel_copy",
"Copy a channel",
"This procedure copies the specified channel and returns the copy.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
PDB_INTERNAL,
/* Input arguments */
1,
channel_copy_args,
/* Output arguments */
1,
channel_copy_out_args,
/* Exec method */
{ { channel_copy_invoker } },
};
/********************/
/* CHANNEL_DELETE */
static Argument *
channel_delete_invoker (Argument *args)
{
Channel *channel;
success = TRUE;
if (success)
{
int_value = args[0].value.pdb_int;
if ((channel = channel_get_ID (int_value)) == NULL)
success = FALSE;
}
if (success)
channel_delete (channel);
return procedural_db_return_args (&channel_delete_proc, success);
}
/* The procedure definition */
ProcArg channel_delete_args[] =
{
{ PDB_CHANNEL,
"channel",
"the channel to delete"
}
};
ProcRecord channel_delete_proc =
{
"gimp_channel_delete",
"Delete a channel",
"This procedure deletes the specified channel. This does not need to be done if a gimage containing this channel was already deleted.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
PDB_INTERNAL,
/* Input arguments */
1,
channel_delete_args,
/* Output arguments */
0,
NULL,
/* Exec method */
{ { channel_delete_invoker } },
};
/**********************/
/* CHANNEL_GET_NAME */
static Argument *
channel_get_name_invoker (Argument *args)
{
Channel *channel;
char *name = NULL;
Argument *return_args;
success = TRUE;
if (success)
{
int_value = args[0].value.pdb_int;
if ((channel = channel_get_ID (int_value)))
name = GIMP_DRAWABLE(channel)->name;
else
success = FALSE;
}
return_args = procedural_db_return_args (&channel_get_name_proc, success);
if (success)
return_args[1].value.pdb_pointer = (name) ? g_strdup (name) : NULL;
return return_args;
}
/* The procedure definition */
ProcArg channel_get_name_args[] =
{
{ PDB_CHANNEL,
"channel",
"the channel"
}
};
ProcArg channel_get_name_out_args[] =
{
{ PDB_STRING,
"name",
"the channel name"
}
};
ProcRecord channel_get_name_proc =
{
"gimp_channel_get_name",
"Get the name of the specified channel.",
"This procedure returns the specified channel's name.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
PDB_INTERNAL,
/* Input arguments */
1,
channel_get_name_args,
/* Output arguments */
1,
channel_get_name_out_args,
/* Exec method */
{ { channel_get_name_invoker } },
};
/**********************/
/* CHANNEL_SET_NAME */
static Argument *
channel_set_name_invoker (Argument *args)
{
Channel *channel;
char *name;
success = TRUE;
if (success)
{
int_value = args[0].value.pdb_int;
if ((channel = channel_get_ID (int_value)) == NULL)
success = FALSE;
}
if (success)
{
name = (char *) args[1].value.pdb_pointer;
if (GIMP_DRAWABLE(channel)->name)
{
g_free (GIMP_DRAWABLE(channel)->name);
GIMP_DRAWABLE(channel)->name = (name) ? g_strdup (name) : NULL;
}
}
return procedural_db_return_args (&channel_set_name_proc, success);
}
/* The procedure definition */
ProcArg channel_set_name_args[] =
{
{ PDB_CHANNEL,
"channel",
"the channel"
},
{ PDB_STRING,
"name",
"the new channel name"
}
};
ProcRecord channel_set_name_proc =
{
"gimp_channel_set_name",
"Set the name of the specified channel.",
"This procedure sets the specified channel's name to the supplied name.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
PDB_INTERNAL,
/* Input arguments */
2,
channel_set_name_args,
/* Output arguments */
0,
NULL,
/* Exec method */
{ { channel_set_name_invoker } },
};
/*************************/
/* CHANNEL_GET_VISIBLE */
static Argument *
channel_get_visible_invoker (Argument *args)
{
Channel *channel;
int visible;
Argument *return_args;
visible = FALSE;
success = TRUE;
if (success)
{
int_value = args[0].value.pdb_int;
if ((channel = channel_get_ID (int_value)))
visible = GIMP_DRAWABLE(channel)->visible;
else
success = FALSE;
}
return_args = procedural_db_return_args (&channel_get_visible_proc, success);
if (success)
return_args[1].value.pdb_int = visible;
return return_args;
}
/* The procedure definition */
ProcArg channel_get_visible_args[] =
{
{ PDB_CHANNEL,
"channel",
"the channel"
}
};
ProcArg channel_get_visible_out_args[] =
{
{ PDB_INT32,
"visible",
"the channel visibility"
}
};
ProcRecord channel_get_visible_proc =
{
"gimp_channel_get_visible",
"Get the visibility of the specified channel.",
"This procedure returns the specified channel's visibility.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
PDB_INTERNAL,
/* Input arguments */
1,
channel_get_visible_args,
/* Output arguments */
1,
channel_get_visible_out_args,
/* Exec method */
{ { channel_get_visible_invoker } },
};
/*************************/
/* CHANNEL_SET_VISIBLE */
static Argument *
channel_set_visible_invoker (Argument *args)
{
Channel *channel;
int visible;
success = TRUE;
if (success)
{
int_value = args[0].value.pdb_int;
if ((channel = channel_get_ID (int_value)) == NULL)
success = FALSE;
}
if (success)
{
visible = args[1].value.pdb_int;
GIMP_DRAWABLE(channel)->visible = (visible) ? TRUE : FALSE;
}
return procedural_db_return_args (&channel_set_visible_proc, success);
}
/* The procedure definition */
ProcArg channel_set_visible_args[] =
{
{ PDB_CHANNEL,
"channel",
"the channel"
},
{ PDB_INT32,
"visible",
"the new channel visibility"
}
};
ProcRecord channel_set_visible_proc =
{
"gimp_channel_set_visible",
"Set the visibility of the specified channel.",
"This procedure sets the specified channel's visibility.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
PDB_INTERNAL,
/* Input arguments */
2,
channel_set_visible_args,
/* Output arguments */
0,
NULL,
/* Exec method */
{ { channel_set_visible_invoker } },
};
/*****************************/
/* CHANNEL_GET_SHOW_MASKED */
static Argument *
channel_get_show_masked_invoker (Argument *args)
{
Channel *channel;
int show_masked;
Argument *return_args;
show_masked = FALSE;
success = TRUE;
if (success)
{
int_value = args[0].value.pdb_int;
if ((channel = channel_get_ID (int_value)))
show_masked = channel->show_masked;
else
success = FALSE;
}
return_args = procedural_db_return_args (&channel_get_show_masked_proc, success);
if (success)
return_args[1].value.pdb_int = show_masked;
return return_args;
}
/* The procedure definition */
ProcArg channel_get_show_masked_args[] =
{
{ PDB_CHANNEL,
"channel",
"the channel"
}
};
ProcArg channel_get_show_masked_out_args[] =
{
{ PDB_INT32,
"show_masked",
"composite method for channel"
}
};
ProcRecord channel_get_show_masked_proc =
{
"gimp_channel_get_show_masked",
"Get the composite type for the channel",
"This procedure returns the specified channel's composite type. If it is non-zero, then the channel is composited with the image so that masked regions are shown. Otherwise, selected regions are shown.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
PDB_INTERNAL,
/* Input arguments */
1,
channel_get_show_masked_args,
/* Output arguments */
1,
channel_get_show_masked_out_args,
/* Exec method */
{ { channel_get_show_masked_invoker } },
};
/*****************************/
/* CHANNEL_SET_SHOW_MASKED */
static Argument *
channel_set_show_masked_invoker (Argument *args)
{
Channel *channel;
int show_masked;
success = TRUE;
if (success)
{
int_value = args[0].value.pdb_int;
if ((channel = channel_get_ID (int_value)) == NULL)
success = FALSE;
}
if (success)
{
show_masked = args[1].value.pdb_int;
channel->show_masked = (show_masked) ? TRUE : FALSE;
}
return procedural_db_return_args (&channel_set_show_masked_proc, success);
}
/* The procedure definition */
ProcArg channel_set_show_masked_args[] =
{
{ PDB_CHANNEL,
"channel",
"the channel"
},
{ PDB_INT32,
"show_masked",
"the new channel show_masked value"
}
};
ProcRecord channel_set_show_masked_proc =
{
"gimp_channel_set_show_masked",
"Set the composite type for the specified channel.",
"This procedure sets the specified channel's composite type. If it is non-zero, then the channel is composited with the image so that masked regions are shown. Otherwise, selected regions are shown.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
PDB_INTERNAL,
/* Input arguments */
2,
channel_set_show_masked_args,
/* Output arguments */
0,
NULL,
/* Exec method */
{ { channel_set_show_masked_invoker } },
};
/*************************/
/* CHANNEL_GET_OPACITY */
static Argument *
channel_get_opacity_invoker (Argument *args)
{
Channel *channel;
double opacity;
Argument *return_args;
opacity = 0.0;
success = TRUE;
if (success)
{
int_value = args[0].value.pdb_int;
if ((channel = channel_get_ID (int_value)))
opacity = ((channel->opacity) * 100.0) / 255.0;
else
success = FALSE;
}
return_args = procedural_db_return_args (&channel_get_opacity_proc, success);
if (success)
return_args[1].value.pdb_float = opacity;
return return_args;
}
/* The procedure definition */
ProcArg channel_get_opacity_args[] =
{
{ PDB_CHANNEL,
"channel",
"the channel"
}
};
ProcArg channel_get_opacity_out_args[] =
{
{ PDB_FLOAT,
"opacity",
"the channel opacity",
}
};
ProcRecord channel_get_opacity_proc =
{
"gimp_channel_get_opacity",
"Get the opacity of the specified channel.",
"This procedure returns the specified channel's opacity.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
PDB_INTERNAL,
/* Input arguments */
1,
channel_get_opacity_args,
/* Output arguments */
1,
channel_get_opacity_out_args,
/* Exec method */
{ { channel_get_opacity_invoker } },
};
/*************************/
/* CHANNEL_SET_OPACITY */
static Argument *
channel_set_opacity_invoker (Argument *args)
{
Channel *channel;
double opacity;
success = TRUE;
if (success)
{
int_value = args[0].value.pdb_int;
if ((channel = channel_get_ID (int_value)) == NULL)
success = FALSE;
}
if (success)
{
opacity = args[1].value.pdb_float;
channel->opacity = (int) ((opacity * 255) / 100);
}
return procedural_db_return_args (&channel_set_opacity_proc, success);
}
/* The procedure definition */
ProcArg channel_set_opacity_args[] =
{
{ PDB_CHANNEL,
"channel",
"the channel"
},
{ PDB_FLOAT,
"opacity",
"the new channel opacity: (0 <= opacity <= 100)"
}
};
ProcRecord channel_set_opacity_proc =
{
"gimp_channel_set_opacity",
"Set the opacity of the specified channel.",
"This procedure sets the specified channel's opacity.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
PDB_INTERNAL,
/* Input arguments */
2,
channel_set_opacity_args,
/* Output arguments */
0,
NULL,
/* Exec method */
{ { channel_set_opacity_invoker } },
};
/***********************/
/* CHANNEL_GET_COLOR */
static Argument *
channel_get_color_invoker (Argument *args)
{
Channel *channel;
unsigned char *color;
Argument *return_args;
color = NULL;
success = TRUE;
if (success)
{
int_value = args[0].value.pdb_int;
if ((channel = channel_get_ID (int_value)))
{
color = (unsigned char *) g_malloc (3);
color[RED_PIX] = channel->col[RED_PIX];
color[GREEN_PIX] = channel->col[GREEN_PIX];
color[BLUE_PIX] = channel->col[BLUE_PIX];
}
else
success = FALSE;
}
return_args = procedural_db_return_args (&channel_get_color_proc, success);
if (success)
return_args[1].value.pdb_pointer = color;
return return_args;
}
/* The procedure definition */
ProcArg channel_get_color_args[] =
{
{ PDB_CHANNEL,
"channel",
"the channel"
}
};
ProcArg channel_get_color_out_args[] =
{
{ PDB_COLOR,
"color",
"the channel's composite color",
}
};
ProcRecord channel_get_color_proc =
{
"gimp_channel_get_color",
"Get the compositing color of the specified channel.",
"This procedure returns the specified channel's compositing color.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
PDB_INTERNAL,
/* Input arguments */
1,
channel_get_color_args,
/* Output arguments */
1,
channel_get_color_out_args,
/* Exec method */
{ { channel_get_color_invoker } },
};
/***********************/
/* CHANNEL_SET_COLOR */
static Argument *
channel_set_color_invoker (Argument *args)
{
Channel *channel;
unsigned char * color;
int i;
success = TRUE;
if (success)
{
int_value = args[0].value.pdb_int;
if ((channel = channel_get_ID (int_value)) == NULL)
success = FALSE;
}
if (success)
{
color = (unsigned char *) args[1].value.pdb_pointer;
for (i = 0; i < 3; i++)
channel->col[i] = color[i];
}
return procedural_db_return_args (&channel_set_color_proc, success);
}
/* The procedure definition */
ProcArg channel_set_color_args[] =
{
{ PDB_CHANNEL,
"channel",
"the channel"
},
{ PDB_COLOR,
"color",
"the composite color"
}
};
ProcRecord channel_set_color_proc =
{
"gimp_channel_set_color",
"Set the compositing color of the specified channel.",
"This procedure sets the specified channel's compositing color.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
PDB_INTERNAL,
/* Input arguments */
2,
channel_set_color_args,
/* Output arguments */
0,
NULL,
/* Exec method */
{ { channel_set_color_invoker } },
};
|