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 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316
|
# GIMP - The GNU 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 3 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, see <https://www.gnu.org/licenses/>.
# "Perlized" from C source by Manish Singh <yosh@gimp.org>
sub drawable_get_pixel {
$blurb = 'Gets the value of the pixel at the specified coordinates.';
$help = <<'HELP';
This procedure gets the pixel value at the specified coordinates.
HELP
&std_pdb_misc;
$date = '1997';
@inargs = (
{ name => 'drawable', type => 'drawable',
desc => 'The drawable' },
{ name => 'x_coord', type => '0 <= int32',
desc => 'The x coordinate' },
{ name => 'y_coord', type => '0 <= int32',
desc => 'The y coordinate' }
);
@outargs = (
{ name => 'color', type => 'geglcolor',
desc => 'The pixel color' }
);
%invoke = (
code => <<'CODE'
{
const Babl *format = gimp_drawable_get_format (drawable);
if (x_coord < gimp_item_get_width (GIMP_ITEM (drawable)) &&
y_coord < gimp_item_get_height (GIMP_ITEM (drawable)))
{
gint n_bytes = babl_format_get_bytes_per_pixel (format);
gpointer pixel;
pixel = g_malloc0 (n_bytes);
gegl_buffer_sample (gimp_drawable_get_buffer (drawable),
x_coord, y_coord, NULL, pixel, format,
GEGL_SAMPLER_NEAREST, GEGL_ABYSS_NONE);
color = gegl_color_new ("black");
gegl_color_set_pixel (color, format, pixel);
g_free (pixel);
}
else
success = FALSE;
}
CODE
);
}
sub drawable_set_pixel {
$blurb = 'Sets the value of the pixel at the specified coordinates.';
$help = <<'HELP';
This procedure sets the pixel value at the specified coordinates.
Note that this function is not undoable, you should use it only on drawables you
just created yourself.
HELP
&std_pdb_misc;
$date = '1997';
@inargs = (
{ name => 'drawable', type => 'drawable',
desc => 'The drawable' },
{ name => 'x_coord', type => '0 <= int32',
desc => 'The x coordinate' },
{ name => 'y_coord', type => '0 <= int32',
desc => 'The y coordinate' },
{ name => 'color', type => 'geglcolor',
desc => 'The pixel color' }
);
%invoke = (
code => <<'CODE'
{
if (gimp_pdb_item_is_modifiable (GIMP_ITEM (drawable),
GIMP_PDB_ITEM_CONTENT, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) &&
x_coord < gimp_item_get_width (GIMP_ITEM (drawable)) &&
y_coord < gimp_item_get_height (GIMP_ITEM (drawable)))
{
gegl_buffer_set_color (gimp_drawable_get_buffer (drawable),
GEGL_RECTANGLE (x_coord, y_coord, 1, 1),
color);
}
else
success = FALSE;
}
CODE
);
}
sub drawable_append_filter {
$blurb = 'Append the specified effect to the top of the list of drawable effects.';
$help = <<'HELP';
This procedure adds the specified drawable effect at the top of the effect list of @drawable.
The @drawable argument must be the same as the one used when you created
the effect with [ctor@Gimp.DrawableFilter.new].
Some effects may be slower than others to render. In order to minimize
processing time, it is preferred to customize the operation's arguments
as received with [method@Gimp.DrawableFilter.get_config] then sync them
to the application with [method@Gimp.DrawableFilter.update] before
adding the effect.
This function is private and should not be used. Use
[method@Gimp.Drawable.append_filter] instead.
HELP
&jehan_pdb_misc('2024', '3.0');
$lib_private = 1;
@inargs = (
{ name => 'drawable', type => 'drawable',
desc => 'The drawable' },
{ name => 'filter', type => 'filter',
desc => 'The drawable filter to append' }
);
$invoke{code} = <<'CODE';
{
GeglNode *node;
if (gimp_drawable_filter_get_drawable (filter) != drawable)
{
g_set_error (error, GIMP_PDB_ERROR, GIMP_PDB_ERROR_INVALID_ARGUMENT,
"%s: the filter was not created for this drawable.",
G_STRFUNC);
success = FALSE;
}
else if (! GIMP_IS_LAYER (drawable))
{
g_set_error (error, GIMP_PDB_ERROR, GIMP_PDB_ERROR_INVALID_ARGUMENT,
"%s: only drawables of type GimpLayer can have non-destructive effects.",
G_STRFUNC);
success = FALSE;
}
node = gimp_drawable_filter_get_operation (filter);
if (success && gegl_node_has_pad (node, "aux"))
{
/* Filters with aux input should not be NDE. See: gimp_filter_tool_create_filter(). */
g_set_error (error, GIMP_PDB_ERROR, GIMP_PDB_ERROR_INVALID_ARGUMENT,
"%s: effects with an 'aux' pad cannot be applied non-destructively.",
G_STRFUNC);
success = FALSE;
}
if (success)
{
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
gimp_image_undo_push_filter_add (image, _("Add filter"), drawable, filter);
gimp_drawable_filter_apply (filter, NULL);
gimp_drawable_filter_commit (filter, TRUE, NULL, FALSE);
gimp_drawable_filter_layer_mask_freeze (filter);
g_object_unref (filter);
}
}
CODE
}
sub drawable_merge_filter {
$blurb = 'Apply the specified effect directly to the drawable.';
$help = <<'HELP';
This procedure applies the specified drawable effect on @drawable and merge it
(therefore before non-destructive effects are computed).
The @drawable argument must be the same as the one used when you created
the effect with [ctor@Gimp.DrawableFilter.new].
Once this is run, @filter is not valid anymore and you should not try to
do anything with it. In particular, you must customize the operation's
arguments as received with [method@Gimp.DrawableFilter.get_config] then
sync them to the application with [method@Gimp.DrawableFilter.update]
before merging the effect.
This function is private and should not be used. Use
[method@Gimp.Drawable.merge_filter] instead.
HELP
&jehan_pdb_misc('2024', '3.0');
$lib_private = 1;
@inargs = (
{ name => 'drawable', type => 'drawable',
desc => 'The drawable' },
{ name => 'filter', type => 'filter',
desc => 'The drawable filter to merge' }
);
$invoke{code} = <<'CODE';
{
if (gimp_drawable_filter_get_drawable (filter) != drawable)
{
g_set_error (error, GIMP_PDB_ERROR, GIMP_PDB_ERROR_INVALID_ARGUMENT,
"%s: the filter was not created for this drawable.",
G_STRFUNC);
success = FALSE;
}
if (success)
{
GimpContainer *filters;
gint count;
gimp_drawable_filter_apply (filter, NULL);
filters = gimp_drawable_get_filters (drawable);
count = gimp_container_get_n_children (filters);
if (count > 1)
gimp_container_reorder (filters, GIMP_OBJECT (filter), count - 1);
gimp_drawable_filter_layer_mask_freeze (filter);
gimp_drawable_filter_commit (filter, FALSE, NULL, FALSE);
g_object_unref (filter);
}
}
CODE
}
sub drawable_get_filters {
$blurb = 'Returns the list of filters applied to the drawable.';
$help = <<'HELP';
This procedure returns the list of filters which are currently applied non-destructively to @drawable.
The order of filters is from topmost to bottommost.
HELP
&jehan_pdb_misc('2024', '3.0');
@inargs = (
{ name => 'drawable', type => 'drawable',
desc => 'The drawable' }
);
@outargs = (
{ name => 'filters', type => 'filterarray',
desc => 'The list of filters on the drawable.' }
);
%invoke = (
code => <<'CODE'
{
GimpContainer *container;
GList *iter;
gsize num_filters;
gint i;
container = gimp_drawable_get_filters (drawable);
num_filters = gimp_container_get_n_children (container);
filters = g_new0 (GimpDrawableFilter *, num_filters + 1);
iter = GIMP_LIST (container)->queue->head;
for (i = 0; i < num_filters; i++, iter = iter->next)
filters[i] = iter->data;
}
CODE
);
}
sub drawable_merge_filters {
$blurb = 'Merge the layer effect filters to the specified drawable.';
$help = <<'HELP';
This procedure combines the contents of the drawable's filter stack
(for export) with the specified drawable.
HELP
&std_pdb_misc;
@inargs = (
{ name => 'drawable', type => 'drawable',
desc => 'The drawable' }
);
%invoke = (
headers => [ qw("core/gimpdrawable-filters.h") ],
code => <<'CODE'
{
if (gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
gimp_drawable_merge_filters (drawable);
else
success = FALSE;
}
CODE
);
}
sub drawable_merge_shadow {
$blurb = 'Merge the shadow buffer with the specified drawable.';
$help = <<'HELP';
This procedure combines the contents of the drawable's shadow buffer
(for temporary processing) with the specified drawable. The 'undo'
parameter specifies whether to add an undo step for the operation.
Requesting no undo is useful for such applications as 'auto-apply'.
HELP
&std_pdb_misc;
@inargs = (
{ name => 'drawable', type => 'drawable',
desc => 'The drawable' },
{ name => 'undo', type => 'boolean',
desc => 'Push merge to undo stack?' }
);
%invoke = (
headers => [ qw("core/gimpdrawable-shadow.h"
"plug-in/gimpplugin.h"
"plug-in/gimppluginmanager.h") ],
code => <<'CODE'
{
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL,
GIMP_PDB_ITEM_CONTENT, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
const gchar *undo_desc = _("Plug-in");
if (gimp->plug_in_manager->current_plug_in)
undo_desc = gimp_plug_in_get_undo_desc (gimp->plug_in_manager->current_plug_in);
gimp_drawable_merge_shadow_buffer (drawable, undo, undo_desc);
}
else
success = FALSE;
}
CODE
);
}
sub drawable_free_shadow {
$blurb = "Free the specified drawable's shadow data (if it exists).";
$help = <<'HELP';
This procedure is intended as a memory saving device. If any shadow
memory has been allocated, it will be freed automatically when the
drawable is removed from the image, or when the plug-in procedure
which allocated it returns.
HELP
&mitch_pdb_misc('2008', '2.6');
@inargs = (
{ name => 'drawable', type => 'drawable',
desc => 'The drawable' }
);
%invoke = (
headers => [ qw("plug-in/gimpplugin-cleanup.h") ],
code => <<'CODE'
{
if (gimp->plug_in_manager->current_plug_in)
gimp_plug_in_cleanup_remove_shadow (gimp->plug_in_manager->current_plug_in,
drawable);
gimp_drawable_free_shadow_buffer (drawable);
}
CODE
);
}
sub drawable_fill {
$blurb = 'Fill the drawable with the specified fill mode.';
$help = <<'HELP';
This procedure fills the drawable. If the fill mode is foreground the
current foreground color is used. If the fill mode is background, the
current background color is used. If the fill type is white, then
white is used. Transparent fill only affects layers with an alpha
channel, in which case the alpha channel is set to transparent. If the
drawable has no alpha channel, it is filled to white. No fill leaves
the drawable's contents undefined.
This procedure is unlike gimp_drawable_edit_fill() or the bucket fill
tool because it fills regardless of a selection. Its main purpose is to
fill a newly created drawable before adding it to the image. This
operation cannot be undone.
HELP
&std_pdb_misc;
@inargs = (
{ name => 'drawable', type => 'drawable',
desc => 'The drawable' },
{ name => 'fill_type', type => 'enum GimpFillType',
desc => 'The type of fill' }
);
%invoke = (
headers => [ qw("core/gimpdrawable-fill.h") ],
code => <<'CODE'
{
if (gimp_pdb_item_is_modifiable (GIMP_ITEM (drawable),
GIMP_PDB_ITEM_CONTENT, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
gimp_drawable_fill (drawable, context, (GimpFillType) fill_type);
}
else
success = FALSE;
}
CODE
);
}
sub drawable_update {
$blurb = 'Update the specified region of the drawable.';
$help = <<'HELP';
This procedure updates the specified region of the drawable. The (x, y)
coordinate pair is relative to the drawable's origin, not to the image origin.
Therefore, the entire drawable can be updated using (0, 0, width, height).
HELP
&std_pdb_misc;
@inargs = (
{ name => 'drawable', type => 'drawable',
desc => 'The drawable' },
{ name => 'x', type => 'int32',
desc => 'x coordinate of upper left corner of update region' },
{ name => 'y', type => 'int32',
desc => 'y coordinate of upper left corner of update region' },
{ name => 'width', type => 'int32',
desc => 'Width of update region' },
{ name => 'height', type => 'int32',
desc => 'Height of update region' }
);
%invoke = (
code => <<'CODE'
{
gimp_drawable_update (drawable, x, y, width, height);
}
CODE
);
}
sub drawable_mask_bounds {
$blurb = <<'BLURB';
Find the bounding box of the current selection in relation to the specified
drawable.
BLURB
$help = <<'HELP';
This procedure returns whether there is a selection. If there is one, the
upper left and lower right-hand corners of its bounding box are returned. These
coordinates are specified relative to the drawable's origin, and bounded by
the drawable's extents. Please note that the pixel specified by the lower
right-hand coordinate of the bounding box is not part of the selection. The
selection ends at the upper left corner of this pixel. This means the width
of the selection can be calculated as (x2 - x1), its height as (y2 - y1).
Note that the returned boolean does NOT correspond with the returned
region being empty or not, it always returns whether the selection
is non_empty. See gimp_drawable_mask_intersect() for a boolean
return value which is more useful in most cases.
HELP
&std_pdb_misc;
@inargs = (
{ name => 'drawable', type => 'drawable',
desc => 'The drawable' }
);
@outargs = (
{ name => 'non_empty', type => 'boolean',
desc => 'TRUE if there is a selection' },
{ name => 'x1', type => 'int32',
desc => "x coordinate of the upper left corner of selection bounds" },
{ name => 'y1', type => 'int32',
desc => "y coordinate of the upper left corner of selection bounds" },
{ name => 'x2', type => 'int32',
desc => "x coordinate of the lower right corner of selection bounds" },
{ name => 'y2', type => 'int32',
desc => "y coordinate of the lower right corner of selection bounds" }
);
%invoke = (
code => <<'CODE'
{
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, 0, error))
non_empty = gimp_item_mask_bounds (GIMP_ITEM (drawable), &x1, &y1, &x2, &y2);
else
success = FALSE;
}
CODE
);
}
sub drawable_mask_intersect {
$blurb = <<'BLURB';
Find the bounding box of the current selection in relation to the specified
drawable.
BLURB
$help = <<'HELP';
This procedure returns whether there is an intersection between the
drawable and the selection. Unlike gimp_drawable_mask_bounds(), the
intersection's bounds are returned as x, y, width, height.
If there is no selection this function returns TRUE and the returned
bounds are the extents of the whole drawable.
HELP
&mitch_pdb_misc('2004', '2.2');
@inargs = (
{ name => 'drawable', type => 'drawable',
desc => 'The drawable' }
);
@outargs = (
{ name => 'non_empty', type => 'boolean',
desc => 'TRUE if the returned area is not empty' },
{ name => 'x', type => 'int32',
desc => 'x coordinate of the upper left corner of the intersection' },
{ name => 'y', type => 'int32',
desc => 'y coordinate of the upper left corner of the intersection' },
{ name => 'width', type => 'int32',
desc => 'width of the intersection' },
{ name => 'height', type => 'int32',
desc => 'height of the intersection' }
);
%invoke = (
code => <<'CODE'
{
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, 0, error))
non_empty = gimp_item_mask_intersect (GIMP_ITEM (drawable),
&x, &y, &width, &height);
else
success = FALSE;
}
CODE
);
}
sub drawable_get_format {
$blurb = "Returns the drawable's Babl format";
$help = <<'HELP';
This procedure returns the drawable's Babl format.
Note that the actual PDB procedure only transfers the format's
encoding. In order to get to the real format, the libbgimp C wrapper
must be used.
HELP
&mitch_pdb_misc('2012', '2.10');
$lib_private = 1;
@inargs = (
{ name => 'drawable', type => 'drawable',
desc => 'The drawable' }
);
@outargs = (
{ name => 'format', type => 'string',
desc => "The drawable's Babl format" }
);
%invoke = (
code => <<'CODE'
{
/* this only transfers the encoding, losing the space, see the
* code in libgimp/gimpdrawable.c which reconstructs the actual
* format in the plug-in process
*/
format = g_strdup (babl_format_get_encoding (gimp_drawable_get_format (drawable)));
}
CODE
);
}
sub drawable_get_thumbnail_format {
$blurb = "Returns the drawable's thumbnail Babl format";
$help = <<'HELP';
This procedure returns the drawable's thumbnail Babl format.
Thumbnails are always 8-bit images, see gimp_drawable_thumbnail() and
gimp_drawable_sub_thmbnail().
HELP
&mitch_pdb_misc('2019', '2.10.14');
$lib_private = 1;
@inargs = (
{ name => 'drawable', type => 'drawable',
desc => 'The drawable' }
);
@outargs = (
{ name => 'format', type => 'string',
desc => "The drawable's thumbnail Babl format" }
);
%invoke = (
code => <<'CODE'
{
format = g_strdup (babl_format_get_encoding (gimp_drawable_get_preview_format (drawable)));
}
CODE
);
}
sub drawable_type {
$blurb = "Returns the drawable's type.";
$help = "This procedure returns the drawable's type.";
&std_pdb_misc;
@inargs = (
{ name => 'drawable', type => 'drawable',
desc => 'The drawable' }
);
@outargs = (
{ name => 'type', type => 'enum GimpImageType',
desc => "The drawable's type" }
);
%invoke = (
code => <<'CODE'
{
type = gimp_babl_format_get_image_type (gimp_drawable_get_format (drawable));
}
CODE
);
}
sub drawable_has_alpha {
$blurb = 'Returns TRUE if the drawable has an alpha channel.';
$help = <<'HELP';
This procedure returns whether the specified drawable has an alpha channel.
This can only be true for layers, and the associated type will be one of:
{ RGBA , GRAYA, INDEXEDA }.
HELP
&std_pdb_misc;
@inargs = (
{ name => 'drawable', type => 'drawable',
desc => 'The drawable' }
);
@outargs = (
{ name => 'has_alpha', type => 'boolean',
desc => 'Does the drawable have an alpha channel?' }
);
%invoke = (
code => <<'CODE'
{
has_alpha = gimp_drawable_has_alpha (drawable);
}
CODE
);
}
sub drawable_type_with_alpha {
$blurb = "Returns the drawable's type with alpha.";
$help = <<'HELP';
This procedure returns the drawable's type as if had an alpha
channel. If the type is currently Gray, for instance, the returned
type would be GrayA. If the drawable already has an alpha channel, the
drawable's type is simply returned.
HELP
&std_pdb_misc;
@inargs = (
{ name => 'drawable', type => 'drawable',
desc => 'The drawable' }
);
@outargs = (
{ name => 'type_with_alpha', type => 'enum GimpImageType
(no GIMP_RGB_IMAGE,
GIMP_GRAY_IMAGE,
GIMP_INDEXED_IMAGE)',
desc => "The drawable's type with alpha" }
);
%invoke = (
code => <<'CODE'
{
const Babl *format = gimp_drawable_get_format_with_alpha (drawable);
type_with_alpha = gimp_babl_format_get_image_type (format);
}
CODE
);
}
sub drawable_is_rgb {
$blurb = 'Returns whether the drawable is an RGB type.';
$help = <<HELP;
This procedure returns TRUE if the specified drawable
is of type { RGB, RGBA }.
HELP
&std_pdb_misc;
@inargs = (
{ name => 'drawable', type => 'drawable',
desc => 'The drawable' }
);
@outargs = (
{ name => 'is_rgb', type => 'boolean',
desc => 'TRUE if the drawable is an RGB type' }
);
%invoke = (
code => <<'CODE'
{
is_rgb = gimp_drawable_is_rgb (drawable);
}
CODE
);
}
sub drawable_is_gray {
$blurb = 'Returns whether the drawable is a grayscale type.';
$help = <<HELP;
This procedure returns TRUE if the specified drawable
is of type { Gray, GrayA }.
HELP
&std_pdb_misc;
@inargs = (
{ name => 'drawable', type => 'drawable',
desc => 'The drawable' }
);
@outargs = (
{ name => 'is_gray', type => 'boolean',
desc => 'TRUE if the drawable is a grayscale type' }
);
%invoke = (
code => <<'CODE'
{
is_gray = gimp_drawable_is_gray (drawable);
}
CODE
);
}
sub drawable_is_indexed {
$blurb = 'Returns whether the drawable is an indexed type.';
$help = <<HELP;
This procedure returns TRUE if the specified drawable
is of type { Indexed, IndexedA }.
HELP
&std_pdb_misc;
@inargs = (
{ name => 'drawable', type => 'drawable',
desc => 'The drawable' }
);
@outargs = (
{ name => 'is_indexed', type => 'boolean',
desc => 'TRUE if the drawable is an indexed type' }
);
%invoke = (
code => <<'CODE'
{
is_indexed = gimp_drawable_is_indexed (drawable);
}
CODE
);
}
sub drawable_get_bpp {
$blurb = 'Returns the bytes per pixel.';
$help = <<'HELP';
This procedure returns the number of bytes per pixel.
HELP
&std_pdb_misc;
@inargs = (
{ name => 'drawable', type => 'drawable',
desc => 'The drawable' }
);
@outargs = (
{ name => 'bpp', type => 'int32',
desc => 'Bytes per pixel' }
);
%invoke = (
code => <<'CODE'
{
const Babl *format = gimp_drawable_get_format (drawable);
bpp = babl_format_get_bytes_per_pixel (format);
}
CODE
);
}
sub drawable_get_width {
$blurb = 'Returns the width of the drawable.';
$help = "This procedure returns the specified drawable's width in pixels.";
&std_pdb_misc;
@inargs = (
{ name => 'drawable', type => 'drawable',
desc => 'The drawable' }
);
@outargs = (
{ name => 'width', type => 'int32',
desc => 'Width of drawable' }
);
%invoke = (
code => <<'CODE'
{
width = gimp_item_get_width (GIMP_ITEM (drawable));
}
CODE
);
}
sub drawable_get_height {
$blurb = 'Returns the height of the drawable.';
$help = "This procedure returns the specified drawable's height in pixels.";
&std_pdb_misc;
@inargs = (
{ name => 'drawable', type => 'drawable',
desc => 'The drawable' }
);
@outargs = (
{ name => 'height', type => 'int32',
desc => 'Height of drawable' }
);
%invoke = (
code => <<'CODE'
{
height = gimp_item_get_height (GIMP_ITEM (drawable));
}
CODE
);
}
sub drawable_get_offsets {
$blurb = 'Returns the offsets for the drawable.';
$help = <<'HELP';
This procedure returns the specified drawable's offsets. This only makes sense
if the drawable is a layer since channels are anchored. The offsets of a
channel will be returned as 0.
HELP
&std_pdb_misc;
@inargs = (
{ name => 'drawable', type => 'drawable',
desc => 'The drawable' }
);
@outargs = (
{ name => 'offset_x', type => 'int32', void_ret => 1,
desc => "x offset of drawable" },
{ name => 'offset_y', type => 'int32',
desc => "y offset of drawable" }
);
%invoke = (
code => <<'CODE'
{
gimp_item_get_offset (GIMP_ITEM (drawable), &offset_x, &offset_y);
}
CODE
);
}
sub drawable_thumbnail {
$blurb = 'Get a thumbnail of a drawable.';
$help = <<'HELP';
This function gets data from which a thumbnail of a drawable preview
can be created. Maximum x or y dimension is 1024 pixels. The pixels are
returned in RGB[A] or GRAY[A] format. The bpp return value gives the
number of bytes in the image.
HELP
&andy_pdb_misc('1999');
$lib_private = 1;
@inargs = (
{ name => 'drawable', type => 'drawable',
desc => 'The drawable' },
{ name => 'width', type => '1 <= int32 <= 1024',
desc => 'The requested thumbnail width' },
{ name => 'height', type => '1 <= int32 <= 1024',
desc => 'The requested thumbnail height' }
);
@outargs = (
{ name => 'actual_width', type => 'int32', void_ret => 1,
desc => 'The previews width' },
{ name => 'actual_height', type => 'int32',
desc => 'The previews height' },
{ name => 'bpp', type => 'int32',
desc => 'The previews bpp' },
{ name => 'thumbnail_data', type => 'bytes',
desc => 'The thumbnail data', }
);
%invoke = (
code => <<'CODE'
{
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
GimpTempBuf *buf;
gint dwidth, dheight;
gimp_assert (GIMP_VIEWABLE_MAX_PREVIEW_SIZE >= 1024);
/* Adjust the width/height ratio */
dwidth = gimp_item_get_width (GIMP_ITEM (drawable));
dheight = gimp_item_get_height (GIMP_ITEM (drawable));
if (dwidth > dheight)
height = MAX (1, (width * dheight) / dwidth);
else
width = MAX (1, (height * dwidth) / dheight);
if (image->gimp->config->layer_previews)
buf = gimp_viewable_get_new_preview (GIMP_VIEWABLE (drawable), context,
width, height, NULL);
else
buf = gimp_viewable_get_dummy_preview (GIMP_VIEWABLE (drawable),
width, height,
gimp_drawable_get_preview_format (drawable));
if (buf)
{
const Babl *format = gimp_temp_buf_get_format (buf);
const Babl *rgb_format = babl_format ("R'G'B' u8");
const Babl *rgba_format = babl_format ("R'G'B'A u8");
const Babl *fish = NULL;
if (babl_format_has_alpha (format) && format != rgba_format)
{
fish = babl_fish (format, rgba_format);
format = rgba_format;
}
else if (! babl_format_has_alpha (format) && format != rgb_format)
{
fish = babl_fish (format, rgb_format);
format = rgb_format;
}
actual_width = gimp_temp_buf_get_width (buf);
actual_height = gimp_temp_buf_get_height (buf);
bpp = babl_format_get_bytes_per_pixel (format);
if (fish)
{
guchar *data;
gint data_size = bpp * actual_width * actual_height;
data = g_malloc (data_size);
babl_process (fish, gimp_temp_buf_get_data (buf), data, actual_width * actual_height);
thumbnail_data = g_bytes_new (data, data_size);
g_free (data);
}
else
{
thumbnail_data = g_bytes_new (gimp_temp_buf_get_data (buf),
gimp_temp_buf_get_data_size (buf));
}
gimp_temp_buf_unref (buf);
}
else
success = FALSE;
}
CODE
);
}
sub drawable_sub_thumbnail {
$blurb = 'Get a thumbnail of a sub-area of a drawable drawable.';
$help = <<'HELP';
This function gets data from which a thumbnail of a drawable preview
can be created. Maximum x or y dimension is 1024 pixels. The pixels are
returned in RGB[A] or GRAY[A] format. The bpp return value gives the
number of bytes in the image.
HELP
&mitch_pdb_misc('2004', '2.2');
$lib_private = 1;
@inargs = (
{ name => 'drawable', type => 'drawable',
desc => 'The drawable' },
{ name => 'src_x', type => '0 <= int32',
desc => 'The x coordinate of the area' },
{ name => 'src_y', type => '0 <= int32',
desc => 'The y coordinate of the area' },
{ name => 'src_width', type => '1 <= int32',
desc => 'The width of the area' },
{ name => 'src_height', type => '1 <= int32',
desc => 'The height of the area' },
{ name => 'dest_width', type => '1 <= int32 <= 1024',
desc => 'The thumbnail width' },
{ name => 'dest_height', type => '1 <= int32 <= 1024',
desc => 'The thumbnail height' }
);
@outargs = (
{ name => 'width', type => 'int32', void_ret => 1,
desc => 'The previews width' },
{ name => 'height', type => 'int32',
desc => 'The previews height' },
{ name => 'bpp', type => 'int32',
desc => 'The previews bpp' },
{ name => 'thumbnail_data', type => 'bytes',
desc => 'The thumbnail data' }
);
%invoke = (
headers => [ qw("core/gimpdrawable-preview.h") ],
code => <<'CODE'
{
if ((src_x + src_width) <= gimp_item_get_width (GIMP_ITEM (drawable)) &&
(src_y + src_height) <= gimp_item_get_height (GIMP_ITEM (drawable)))
{
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
GimpTempBuf *buf;
if (image->gimp->config->layer_previews)
buf = gimp_drawable_get_sub_preview (drawable,
src_x, src_y,
src_width, src_height,
dest_width, dest_height);
else
buf = gimp_viewable_get_dummy_preview (GIMP_VIEWABLE (drawable),
dest_width, dest_height,
gimp_drawable_get_preview_format (drawable));
if (buf)
{
const Babl *format = gimp_temp_buf_get_format (buf);
const Babl *rgb_format = babl_format ("R'G'B' u8");
const Babl *rgba_format = babl_format ("R'G'B'A u8");
const Babl *fish = NULL;
if (babl_format_has_alpha (format) && format != rgba_format)
{
fish = babl_fish (format, rgba_format);
format = rgba_format;
}
else if (! babl_format_has_alpha (format) && format != rgb_format)
{
fish = babl_fish (format, rgb_format);
format = rgb_format;
}
width = gimp_temp_buf_get_width (buf);
height = gimp_temp_buf_get_height (buf);
bpp = babl_format_get_bytes_per_pixel (format);
if (fish)
{
guchar *data;
gint data_size = bpp * width * height;
data = g_malloc (data_size);
babl_process (fish, gimp_temp_buf_get_data (buf), data,
width * height);
thumbnail_data = g_bytes_new (data, data_size);
g_free (data);
}
else
{
thumbnail_data = g_bytes_new (gimp_temp_buf_get_data (buf),
gimp_temp_buf_get_data_size (buf));
}
gimp_temp_buf_unref (buf);
}
else
success = FALSE;
}
else
success = FALSE;
}
CODE
);
}
sub drawable_offset {
$blurb = <<'BLURB';
Offset the drawable by the specified amounts in the X and Y directions
BLURB
$help = <<'HELP';
This procedure offsets the specified drawable by the amounts specified by
'offset_x' and 'offset_y'. If 'wrap_around' is set to TRUE, then portions of
the drawable which are offset out of bounds are wrapped around. Alternatively,
the undefined regions of the drawable can be filled with transparency or the
background color, as specified by the 'fill-type' parameter.
HELP
&std_pdb_misc;
$date = '1997';
@inargs = (
{ name => 'drawable', type => 'drawable',
desc => 'The drawable to offset' },
{ name => 'wrap_around', type => 'boolean',
desc => 'wrap image around or fill vacated regions' },
{ name => 'fill_type', type => 'enum GimpOffsetType',
desc => 'fill vacated regions of drawable with background or
transparent' },
{ name => 'color', type => 'geglcolor',
desc => 'fills in the background color when fill_type is
set to OFFSET-COLOR' },
{ name => 'offset_x', type => 'int32',
desc => 'offset by this amount in X direction' },
{ name => 'offset_y', type => 'int32',
desc => 'offset by this amount in Y direction' }
);
%invoke = (
code => <<'CODE'
{
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL,
GIMP_PDB_ITEM_CONTENT, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
gimp_drawable_offset (drawable, context, wrap_around, fill_type,
color, offset_x, offset_y);
else
success = FALSE;
}
CODE
);
}
sub drawable_foreground_extract {
$blurb = 'Extract the foreground of a drawable using a given trimap.';
$help = <<'HELP';
This procedure extracts the foreground from @drawable using @mask as a trimap.
Set white as foreground, black as background and uncertain pixels as
any other value, for the tri-map.
HELP
$author = 'Gerald Friedland <fland@inf.fu-berlin.de>, Kristian Jantz <jantz@inf.fu-berlin.de>, Sven Neumann <sven@gimp.org>';
$copyright = 'Gerald Friedland';
$date = '2005';
$since = '2.4';
@inargs = (
{ name => 'drawable', type => 'drawable',
desc => 'The drawable' },
{ name => 'mode', type => 'enum GimpForegroundExtractMode',
desc => 'The algorithm to use' },
{ name => 'mask', type => 'drawable', desc => 'Tri-Map' }
);
%invoke = (
headers => [ qw("core/gimpdrawable-foreground-extract.h") ],
code => <<'CODE'
{
if (mode == GIMP_FOREGROUND_EXTRACT_MATTING &&
gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, 0, error))
{
GimpPDBContext *pdb_context = GIMP_PDB_CONTEXT (context);
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
GeglBuffer *buffer;
buffer = gimp_drawable_foreground_extract (drawable,
GIMP_MATTING_ENGINE_GLOBAL,
2,
2,
2,
gimp_drawable_get_buffer (mask),
progress);
gimp_channel_select_buffer (gimp_image_get_mask (image),
C_("command", "Foreground Select"),
buffer,
0, /* x offset */
0, /* y offset */
GIMP_CHANNEL_OP_REPLACE,
pdb_context->feather,
pdb_context->feather_radius_x,
pdb_context->feather_radius_y);
g_object_unref (buffer);
}
else
success = FALSE;
}
CODE
);
}
@headers = qw("config/gimpcoreconfig.h"
"gegl/gimp-babl.h"
"gegl/gimp-babl-compat.h"
"core/gimp.h"
"core/gimpcontainer.h"
"core/gimpchannel-select.h"
"core/gimpdrawablefilter.h"
"core/gimpdrawable-filters.h"
"core/gimpdrawable-offset.h"
"core/gimpimage.h"
"core/gimpimage-undo-push.h"
"core/gimplayer.h"
"core/gimplist.h"
"core/gimptempbuf.h"
"gimppdb-utils.h"
"gimppdbcontext.h"
"gimppdberror.h"
"gimp-intl.h");
@procs = qw(drawable_get_format
drawable_get_thumbnail_format
drawable_get_pixel
drawable_set_pixel
drawable_type
drawable_type_with_alpha
drawable_has_alpha
drawable_is_rgb
drawable_is_gray
drawable_is_indexed
drawable_get_bpp
drawable_get_width
drawable_get_height
drawable_get_offsets
drawable_mask_bounds
drawable_mask_intersect
drawable_append_filter
drawable_merge_filter
drawable_get_filters
drawable_merge_filters
drawable_merge_shadow
drawable_free_shadow
drawable_update
drawable_fill
drawable_offset
drawable_thumbnail
drawable_sub_thumbnail
drawable_foreground_extract);
%exports = (app => [@procs], lib => [@procs]);
$desc = 'Drawable procedures';
$doc_title = 'gimpdrawable';
$doc_short_desc = 'Functions to manipulate drawables.';
$doc_long_desc = 'Functions to manipulate drawables.';
1;
|