4
4
* Compose plug-in (C) 1997,1999 Peter Kirchgessner
5
5
* e-mail: peter@kirchgessner.net, WWW: http://www.kirchgessner.net
7
* This program is free software; you can redistribute it and/or modify
7
* This program is free software: you can redistribute it and/or modify
8
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; either version 2 of the License, or
9
* the Free Software Foundation; either version 3 of the License, or
10
10
* (at your option) any later version.
12
12
* This program is distributed in the hope that it will be useful,
15
15
* GNU General Public License for more details.
17
17
* You should have received a copy of the GNU General Public License
18
* along with this program; if not, write to the Free Software
19
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
* along with this program. If not, see <http://www.gnu.org/licenses/>.
345
345
static GimpParamDef args[] =
347
{ GIMP_PDB_INT32, "run-mode", "Interactive, non-interactive" },
347
{ GIMP_PDB_INT32, "run-mode", "The run mode { RUN-INTERACTIVE (0), RUN-NONINTERACTIVE (1) }" },
348
348
{ GIMP_PDB_IMAGE, "image1", "First input image" },
349
349
{ GIMP_PDB_DRAWABLE, "drawable", "Input drawable (not used)" },
350
350
{ GIMP_PDB_IMAGE, "image2", "Second input image" },
361
361
static GimpParamDef drw_args[] =
363
{ GIMP_PDB_INT32, "run-mode", "Interactive, non-interactive" },
363
{ GIMP_PDB_INT32, "run-mode", "The run mode { RUN-INTERACTIVE (0), RUN-NONINTERACTIVE (1) }" },
364
364
{ GIMP_PDB_IMAGE, "image1", "First input image (not used)" },
365
365
{ GIMP_PDB_DRAWABLE, "drawable1", "First input drawable" },
366
366
{ GIMP_PDB_DRAWABLE, "drawable2", "Second input drawable" },
377
377
static const GimpParamDef recompose_args[] =
379
{ GIMP_PDB_INT32, "run-mode", "Interactive, non-interactive" },
379
{ GIMP_PDB_INT32, "run-mode", "The run mode { RUN-INTERACTIVE (0), RUN-NONINTERACTIVE (1) }" },
380
380
{ GIMP_PDB_IMAGE, "image", "Image to recompose from" },
381
381
{ GIMP_PDB_DRAWABLE, "drawable", "Not used" },
401
401
drw_args[6].description = type_desc->str;
403
403
gimp_install_procedure (COMPOSE_PROC,
404
N_("Create an image using multiple gray images as color channels"),
405
"This function creates a new image from "
406
"multiple gray images",
407
"Peter Kirchgessner",
408
"Peter Kirchgessner (peter@kirchgessner.net)",
404
N_("Create an image using multiple gray images as color channels"),
405
"This function creates a new image from "
406
"multiple gray images",
407
"Peter Kirchgessner",
408
"Peter Kirchgessner (peter@kirchgessner.net)",
414
414
G_N_ELEMENTS (return_vals),
417
417
gimp_plugin_menu_register (COMPOSE_PROC, "<Image>/Colors/Components");
419
419
gimp_install_procedure (DRAWABLE_COMPOSE_PROC,
420
"Compose an image from multiple drawables of gray images",
421
"This function creates a new image from "
422
"multiple drawables of gray images",
423
"Peter Kirchgessner",
424
"Peter Kirchgessner (peter@kirchgessner.net)",
426
NULL, /* It is not available in interactive mode */
429
G_N_ELEMENTS (drw_args),
420
"Compose an image from multiple drawables of gray images",
421
"This function creates a new image from "
422
"multiple drawables of gray images",
423
"Peter Kirchgessner",
424
"Peter Kirchgessner (peter@kirchgessner.net)",
426
NULL, /* It is not available in interactive mode */
429
G_N_ELEMENTS (drw_args),
430
430
G_N_ELEMENTS (drw_return_vals),
431
drw_args, drw_return_vals);
431
drw_args, drw_return_vals);
433
433
gimp_install_procedure (RECOMPOSE_PROC,
434
N_("Recompose an image that was previously decomposed"),
435
"This function recombines the grayscale layers produced "
436
"by Decompose into a single RGB or RGBA layer, and "
434
N_("Recompose an image that was previously decomposed"),
435
"This function recombines the grayscale layers produced "
436
"by Decompose into a single RGB or RGBA layer, and "
437
437
"replaces the originally decomposed layer with the "
445
G_N_ELEMENTS (recompose_args), 0,
446
recompose_args, NULL);
445
G_N_ELEMENTS (recompose_args), 0,
446
recompose_args, NULL);
448
448
gimp_plugin_menu_register (RECOMPOSE_PROC, "<Image>/Colors/Components");
832
832
gimp_pixel_rgn_init (&pixel_rgn_dst_read, drawable_dst,
833
833
0, 0, drawable_dst->width, drawable_dst->height,
835
image_ID_dst = gimp_drawable_get_image (layer_ID_dst);
835
image_ID_dst = gimp_item_get_image (layer_ID_dst);
868
868
width, scan_lines);
870
870
if (composevals.do_recompose)
871
gimp_pixel_rgn_get_rect (&pixel_rgn_dst_read, dst, 0, i,
871
gimp_pixel_rgn_get_rect (&pixel_rgn_dst_read, dst, 0, i,
874
874
/* Do the composition */
875
875
compose_dsc[compose_idx].compose_fun (src,
879
879
gimp_drawable_has_alpha (layer_ID_dst));
881
881
/* Set destination pixel region */
933
934
gimp_image_set_filename (image_ID, filename);
935
936
*layer_ID = gimp_layer_new (image_ID, _("Background"), width, height,
936
gdtype, 100, GIMP_NORMAL_MODE);
937
gimp_image_add_layer (image_ID, *layer_ID, 0);
937
gdtype, 100, GIMP_NORMAL_MODE);
938
gimp_image_insert_layer (image_ID, *layer_ID, -1, 0);
939
940
*drawable = gimp_drawable_get (*layer_ID);
940
941
gimp_pixel_rgn_init (pixel_rgn, *drawable, 0, 0, (*drawable)->width,
941
(*drawable)->height, TRUE, FALSE);
942
(*drawable)->height, TRUE, FALSE);
962
963
if ((red_incr == 1) && (green_incr == 1) && (blue_incr == 1))
964
965
while (count-- > 0)
966
*(rgb_dst++) = *(red_src++);
967
*(rgb_dst++) = *(green_src++);
968
*(rgb_dst++) = *(blue_src++);
967
*(rgb_dst++) = *(red_src++);
968
*(rgb_dst++) = *(green_src++);
969
*(rgb_dst++) = *(blue_src++);
969
970
if (dst_has_alpha)
975
976
while (count-- > 0)
977
*(rgb_dst++) = *red_src; red_src += red_incr;
978
*(rgb_dst++) = *green_src; green_src += green_incr;
979
*(rgb_dst++) = *blue_src; blue_src += blue_incr;
978
*(rgb_dst++) = *red_src; red_src += red_incr;
979
*(rgb_dst++) = *green_src; green_src += green_incr;
980
*(rgb_dst++) = *blue_src; blue_src += blue_incr;
980
981
if (dst_has_alpha)
1006
1007
(alpha_incr == 1))
1008
1009
while (count-- > 0)
1010
*(rgb_dst++) = *(red_src++);
1011
*(rgb_dst++) = *(green_src++);
1012
*(rgb_dst++) = *(blue_src++);
1013
*(rgb_dst++) = *(alpha_src++);
1011
*(rgb_dst++) = *(red_src++);
1012
*(rgb_dst++) = *(green_src++);
1013
*(rgb_dst++) = *(blue_src++);
1014
*(rgb_dst++) = *(alpha_src++);
1018
1019
while (count-- > 0)
1020
*(rgb_dst++) = *red_src; red_src += red_incr;
1021
*(rgb_dst++) = *green_src; green_src += green_incr;
1022
*(rgb_dst++) = *blue_src; blue_src += blue_incr;
1023
*(rgb_dst++) = *alpha_src; alpha_src += alpha_incr;
1021
*(rgb_dst++) = *red_src; red_src += red_incr;
1022
*(rgb_dst++) = *green_src; green_src += green_incr;
1023
*(rgb_dst++) = *blue_src; blue_src += blue_incr;
1024
*(rgb_dst++) = *alpha_src; alpha_src += alpha_incr;
1045
1046
while (count-- > 0)
1047
1048
gimp_hsv_to_rgb4 (rgb_dst, (gdouble) *hue_src / 255.0,
1048
(gdouble) *sat_src / 255.0,
1049
(gdouble) *val_src / 255.0);
1049
(gdouble) *sat_src / 255.0,
1050
(gdouble) *val_src / 255.0);
1051
1052
hue_src += hue_incr;
1052
1053
sat_src += sat_incr;
1115
1116
if ((cyan_incr == 1) && (magenta_incr == 1) && (yellow_incr == 1))
1117
1118
while (count-- > 0)
1119
*(rgb_dst++) = 255 - *(cyan_src++);
1120
*(rgb_dst++) = 255 - *(magenta_src++);
1121
*(rgb_dst++) = 255 - *(yellow_src++);
1120
*(rgb_dst++) = 255 - *(cyan_src++);
1121
*(rgb_dst++) = 255 - *(magenta_src++);
1122
*(rgb_dst++) = 255 - *(yellow_src++);
1122
1123
if (dst_has_alpha)
1128
1129
while (count-- > 0)
1130
*(rgb_dst++) = 255 - *cyan_src;
1131
*(rgb_dst++) = 255 - *magenta_src;
1132
*(rgb_dst++) = 255 - *yellow_src;
1133
cyan_src += cyan_incr;
1134
magenta_src += magenta_incr;
1135
yellow_src += yellow_incr;
1131
*(rgb_dst++) = 255 - *cyan_src;
1132
*(rgb_dst++) = 255 - *magenta_src;
1133
*(rgb_dst++) = 255 - *yellow_src;
1134
cyan_src += cyan_incr;
1135
magenta_src += magenta_incr;
1136
yellow_src += yellow_incr;
1136
1137
if (dst_has_alpha)
1167
1168
guchar r, g, b;
1169
1170
gimp_cmyk_set_uchar (&gcmyk,
1170
*cyan_src, *magenta_src, *yellow_src, *black_src);
1171
*cyan_src, *magenta_src, *yellow_src,
1171
1173
gimp_cmyk_to_rgb (&gcmyk, &grgb);
1172
1174
gimp_rgb_get_uchar (&grgb, &r, &g, &b);
1476
1478
gimp_ui_init (PLUG_IN_BINARY, TRUE);
1478
layer_list = gimp_image_get_layers (gimp_drawable_get_image (drawable_ID),
1480
layer_list = gimp_image_get_layers (gimp_item_get_image (drawable_ID),
1481
dialog = gimp_dialog_new (_("Compose"), PLUG_IN_BINARY,
1483
dialog = gimp_dialog_new (_("Compose"), PLUG_IN_ROLE,
1483
1485
gimp_standard_help_func, COMPOSE_PROC,
1499
1501
gimp_window_set_transient (GTK_WINDOW (dialog));
1501
main_vbox = gtk_vbox_new (FALSE, 12);
1503
main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
1502
1504
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12);
1503
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), main_vbox);
1505
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
1506
main_vbox, TRUE, TRUE, 0);
1504
1507
gtk_widget_show (main_vbox);
1506
1509
/* Compose type combo */
1509
1512
gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
1510
1513
gtk_widget_show (frame);
1512
hbox = gtk_hbox_new (FALSE, 6);
1515
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
1513
1516
gtk_container_add (GTK_CONTAINER (frame), hbox);
1514
1517
gtk_widget_show (hbox);
1551
1554
gtk_box_pack_start (GTK_BOX (main_vbox), frame, TRUE, TRUE, 0);
1552
1555
gtk_widget_show (frame);
1554
vbox = gtk_vbox_new (FALSE, 6);
1557
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
1555
1558
gtk_container_add (GTK_CONTAINER (frame), vbox);
1556
1559
gtk_widget_show (vbox);
1571
1574
GtkTreeModel *model;
1572
1575
GdkPixbuf *ico;
1574
hbox = gtk_hbox_new (FALSE, 6);
1577
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
1575
1578
gtk_table_attach (GTK_TABLE (table), hbox, 0, 1, j, j + 1,
1576
1579
GTK_FILL, GTK_FILL, 0, 0);
1577
1580
gtk_widget_show (hbox);
1616
1619
g_object_unref (ico);
1617
1620
gtk_table_attach (GTK_TABLE (table), combo, 1, 2, j, j + 1,
1618
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
1621
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
1619
1622
gtk_widget_show (combo);
1621
1624
gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo);