76
82
GimpDrawable **drawable,
77
83
GimpPixelRgn *pixel_rgn);
85
static void transfer_registration_color (const guchar *src,
86
gint bpp, gint numpix, guchar **dst,
80
static void extract_rgb (guchar *src, gint bpp, gint numpix, guchar **dst);
81
static void extract_red (guchar *src, gint bpp, gint numpix, guchar **dst);
82
static void extract_green (guchar *src, gint bpp, gint numpix, guchar **dst);
83
static void extract_blue (guchar *src, gint bpp, gint numpix, guchar **dst);
84
static void extract_rgba (guchar *src, gint bpp, gint numpix, guchar **dst);
85
static void extract_alpha (guchar *src, gint bpp, gint numpix, guchar **dst);
86
static void extract_hsv (guchar *src, gint bpp, gint numpix, guchar **dst);
87
static void extract_hue (guchar *src, gint bpp, gint numpix, guchar **dst);
88
static void extract_sat (guchar *src, gint bpp, gint numpix, guchar **dst);
89
static void extract_val (guchar *src, gint bpp, gint numpix, guchar **dst);
90
static void extract_cmy (guchar *src, gint bpp, gint numpix, guchar **dst);
91
static void extract_cyan (guchar *src, gint bpp, gint numpix, guchar **dst);
92
static void extract_magenta (guchar *src, gint bpp, gint numpix, guchar **dst);
93
static void extract_yellow (guchar *src, gint bpp, gint numpix, guchar **dst);
94
static void extract_cmyk (guchar *src, gint bpp, gint numpix, guchar **dst);
95
static void extract_cyank (guchar *src, gint bpp, gint numpix, guchar **dst);
96
static void extract_magentak (guchar *src, gint bpp, gint numpix, guchar **dst);
97
static void extract_yellowk (guchar *src, gint bpp, gint numpix, guchar **dst);
98
static void extract_lab (guchar *src, gint bpp, gint numpix, guchar **dst);
99
static void extract_ycbcr470 (guchar *src, gint bpp, gint numpix, guchar **dst);
100
static void extract_ycbcr709 (guchar *src, gint bpp, gint numpix, guchar **dst);
101
static void extract_ycbcr470f(guchar *src, gint bpp, gint numpix, guchar **dst);
102
static void extract_ycbcr709f(guchar *src, gint bpp, gint numpix, guchar **dst);
89
static void extract_rgb (const guchar *src,
90
gint bpp, gint numpix, guchar **dst);
91
static void extract_red (const guchar *src,
92
gint bpp, gint numpix, guchar **dst);
93
static void extract_green (const guchar *src,
94
gint bpp, gint numpix, guchar **dst);
95
static void extract_blue (const guchar *src,
96
gint bpp, gint numpix, guchar **dst);
97
static void extract_rgba (const guchar *src,
98
gint bpp, gint numpix, guchar **dst);
99
static void extract_alpha (const guchar *src,
100
gint bpp, gint numpix, guchar **dst);
101
static void extract_hsv (const guchar *src,
102
gint bpp, gint numpix, guchar **dst);
103
static void extract_hsl (const guchar *src,
104
gint bpp, gint numpix, guchar **dst);
105
static void extract_hue (const guchar *src,
106
gint bpp, gint numpix, guchar **dst);
107
static void extract_sat (const guchar *src,
108
gint bpp, gint numpix, guchar **dst);
109
static void extract_val (const guchar *src,
110
gint bpp, gint numpix, guchar **dst);
111
static void extract_huel (const guchar *src,
112
gint bpp, gint numpix, guchar **dst);
113
static void extract_satl (const guchar *src,
114
gint bpp, gint numpix, guchar **dst);
115
static void extract_lightness (const guchar *src,
116
gint bpp, gint numpix, guchar **dst);
117
static void extract_cmy (const guchar *src,
118
gint bpp, gint numpix, guchar **dst);
119
static void extract_cyan (const guchar *src,
120
gint bpp, gint numpix, guchar **dst);
121
static void extract_magenta (const guchar *src,
122
gint bpp, gint numpix, guchar **dst);
123
static void extract_yellow (const guchar *src,
124
gint bpp, gint numpix, guchar **dst);
125
static void extract_cmyk (const guchar *src,
126
gint bpp, gint numpix, guchar **dst);
127
static void extract_cyank (const guchar *src,
128
gint bpp, gint numpix, guchar **dst);
129
static void extract_magentak (const guchar *src,
130
gint bpp, gint numpix, guchar **dst);
131
static void extract_yellowk (const guchar *src,
132
gint bpp, gint numpix, guchar **dst);
133
static void extract_lab (const guchar *src,
134
gint bpp, gint numpix, guchar **dst);
135
static void extract_ycbcr470 (const guchar *src,
136
gint bpp, gint numpix, guchar **dst);
137
static void extract_ycbcr709 (const guchar *src,
138
gint bpp, gint numpix, guchar **dst);
139
static void extract_ycbcr470f(const guchar *src,
140
gint bpp, gint numpix, guchar **dst);
141
static void extract_ycbcr709f(const guchar *src,
142
gint bpp, gint numpix, guchar **dst);
104
144
static gboolean decompose_dialog (void);
107
/* LAB colorspace constants */
108
static const gdouble Xn = 0.951;
109
static const gdouble Yn = 1.0;
110
static const gdouble Zn = 1.089;
113
/* Maximum number of new images generated by an extraction */
147
/* Maximum number of images/layers generated by an extraction */
114
148
#define MAX_EXTRACT_IMAGES 4
116
150
/* Description of an extraction */
119
gchar *type; /* What to extract */
120
gint dialog; /* Dialog-Flag. Set it to 1 if you want to appear */
121
/* this extract function within the dialog */
122
gint num_images; /* Number of images to create */
123
gchar *channel_name[MAX_EXTRACT_IMAGES]; /* Names of channels to extract */
124
/* Function that performs the extraction */
125
void (*extract_fun) (guchar *src, int bpp, gint numpix, guchar **dst);
153
const gchar *type; /* What to extract */
154
gboolean dialog; /* Dialog-Flag. Set it to TRUE if you want to appear
155
* this extract function within the dialog */
156
gint num_images; /* Number of images to create */
158
/* Names of channels to extract */
159
const gchar *channel_name[MAX_EXTRACT_IMAGES];
161
/* Function that performs the extraction */
162
void (* extract_fun) (const guchar *src,
128
168
static EXTRACT extract[] =
130
170
{ N_("RGB"), TRUE, 3, { N_("red"),
132
N_("blue") }, extract_rgb },
133
{ N_("Red"), FALSE, 1, { N_("red") }, extract_red },
172
N_("blue") }, extract_rgb },
174
{ N_("Red"), FALSE, 1, { N_("red") }, extract_red },
134
175
{ N_("Green"), FALSE, 1, { N_("green") }, extract_green },
176
{ N_("Blue"), FALSE, 1, { N_("blue") }, extract_blue },
135
178
{ N_("RGBA"), TRUE, 4, { N_("red"),
138
N_("alpha") }, extract_rgba },
139
{ N_("Blue"), FALSE, 1, { N_("blue") }, extract_blue },
181
N_("alpha") }, extract_rgba },
140
184
{ N_("HSV"), TRUE, 3, { N_("hue"),
142
N_("value") }, extract_hsv },
143
{ N_("Hue"), FALSE, 1, { N_("hue") }, extract_hue },
186
N_("value") }, extract_hsv },
188
{ N_("Hue"), FALSE, 1, { N_("hue") }, extract_hue },
144
189
{ N_("Saturation"), FALSE, 1, { N_("saturation") }, extract_sat },
145
{ N_("Value"), FALSE, 1, { N_("value") }, extract_val },
190
{ N_("Value"), FALSE, 1, { N_("value") }, extract_val },
193
{ N_("HSL"), TRUE, 3, { N_("hue_l"),
195
N_("lightness") }, extract_hsl },
197
{ N_("Hue (HSL)"), FALSE, 1, { N_("hue_l") }, extract_huel },
198
{ N_("Saturation (HSL)"), FALSE, 1, { N_("saturation_l") }, extract_satl },
199
{ N_("Lightness"), FALSE, 1, { N_("lightness")}, extract_lightness },
146
202
{ N_("CMY"), TRUE, 3, { N_("cyan"),
148
N_("yellow") }, extract_cmy },
149
{ N_("Cyan"), FALSE, 1, { N_("cyan") }, extract_cyan },
204
N_("yellow") }, extract_cmy },
206
{ N_("Cyan"), FALSE, 1, { N_("cyan") }, extract_cyan },
150
207
{ N_("Magenta"), FALSE, 1, { N_("magenta") }, extract_magenta },
151
{ N_("Yellow"), FALSE, 1, { N_("yellow") }, extract_yellow },
152
{ N_("CMYK"), TRUE, 4, { N_("cyan_k"),
155
N_("black") }, extract_cmyk },
156
{ N_("Cyan_K"), FALSE, 1, { N_("cyan_k") }, extract_cyank },
157
{ N_("Magenta_K"), FALSE, 1, { N_("magenta_k") }, extract_magentak },
158
{ N_("Yellow_K"), FALSE, 1, { N_("yellow_k") }, extract_yellowk },
208
{ N_("Yellow"), FALSE, 1, { N_("yellow") }, extract_yellow },
211
{ N_("CMYK"), TRUE, 4, { N_("cyan-k"),
214
N_("black") }, extract_cmyk },
216
{ N_("Cyan_K"), FALSE, 1, { N_("cyan-k") }, extract_cyank },
217
{ N_("Magenta_K"), FALSE, 1, { N_("magenta-k") }, extract_magentak },
218
{ N_("Yellow_K"), FALSE, 1, { N_("yellow-k") }, extract_yellowk },
159
221
{ N_("Alpha"), TRUE, 1, { N_("alpha") }, extract_alpha },
161
224
{ N_("LAB"), TRUE, 3, { "L",
163
226
"B" }, extract_lab },
166
TRUE, 3, { N_("luma_y470"),
167
N_("blueness_cb470"),
168
N_("redness_cr470") }, extract_ycbcr470 },
170
TRUE, 3, { N_("luma_y709"),
171
N_("blueness_cb709"),
172
N_("redness_cr709") }, extract_ycbcr709 },
173
{ "YCbCr_ITU_R470_256",
174
TRUE, 3, { N_("luma_y470f"),
175
N_("blueness_cb470f"),
176
N_("redness_cr470f") }, extract_ycbcr470f },
177
{ "YCbCr_ITU_R709_256",
178
TRUE, 3, { N_("luma_y709f"),
179
N_("blueness_cb709f"),
180
N_("redness_cr709f") }, extract_ycbcr709f },
229
{ "YCbCr_ITU_R470", TRUE, 3, { N_("luma-y470"),
230
N_("blueness-cb470"),
231
N_("redness-cr470") }, extract_ycbcr470 },
233
{ "YCbCr_ITU_R709", TRUE, 3, { N_("luma-y709"),
234
N_("blueness-cb709"),
235
N_("redness-cr709") }, extract_ycbcr709 },
237
{ "YCbCr ITU R470 256", TRUE, 3, { N_("luma-y470f"),
238
N_("blueness-cb470f"),
239
N_("redness-cr470f") }, extract_ycbcr470f },
241
{ "YCbCr ITU R709 256", TRUE, 3, { N_("luma-y709f"),
242
N_("blueness-cb709f"),
243
N_("redness-cr709f") }, extract_ycbcr709f }
222
static GimpParamDef args[] =
277
static const GimpParamDef args[] =
224
{ GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive" },
225
{ GIMP_PDB_IMAGE, "image", "Input image (unused)" },
226
{ GIMP_PDB_DRAWABLE, "drawable", "Input drawable" },
227
{ GIMP_PDB_STRING, "decompose_type", "What to decompose: RGB, Red, Green, Blue, RGBA, Red, Green, Blue, Alpha, HSV, Hue, Saturation, Value, CMY, Cyan, Magenta, Yellow, CMYK, Cyan_K, Magenta_K, Yellow_K, Alpha, LAB" },
228
{ GIMP_PDB_INT32, "layers_mode", "Create channels as layers in a single image" }
279
{ GIMP_PDB_INT32, "run-mode", "Interactive, non-interactive" },
280
{ GIMP_PDB_IMAGE, "image", "Input image (unused)" },
281
{ GIMP_PDB_DRAWABLE, "drawable", "Input drawable" },
282
{ GIMP_PDB_STRING, "decompose-type", "What to decompose: RGB, Red, Green, Blue, RGBA, Red, Green, Blue, Alpha, HSV, Hue, Saturation, Value, CMY, Cyan, Magenta, Yellow, CMYK, Cyan_K, Magenta_K, Yellow_K, Alpha, LAB" },
283
{ GIMP_PDB_INT32, "layers-mode", "Create channels as layers in a single image" }
230
static GimpParamDef return_vals[] =
285
static const GimpParamDef return_vals[] =
232
{ GIMP_PDB_IMAGE, "new_image", "Output gray image" },
233
{ GIMP_PDB_IMAGE, "new_image", "Output gray image (N/A for single channel extract)" },
234
{ GIMP_PDB_IMAGE, "new_image", "Output gray image (N/A for single channel extract)" },
235
{ GIMP_PDB_IMAGE, "new_image", "Output gray image (N/A for single channel extract)" }
287
{ GIMP_PDB_IMAGE, "new-image", "Output gray image" },
288
{ GIMP_PDB_IMAGE, "new-image", "Output gray image (N/A for single channel extract)" },
289
{ GIMP_PDB_IMAGE, "new-image", "Output gray image (N/A for single channel extract)" },
290
{ GIMP_PDB_IMAGE, "new-image", "Output gray image (N/A for single channel extract)" }
238
gimp_install_procedure ("plug_in_decompose",
239
"Decompose an image into different types of channels",
293
gimp_install_procedure (PLUG_IN_PROC,
294
N_("Decompose an image into separate colorspace components"),
240
295
"This function creates new gray images with "
241
296
"different channel information in each of them",
242
297
"Peter Kirchgessner",
243
"Peter Kirchgessner (peter@kirchgessner.net)",
249
G_N_ELEMENTS (return_vals),
252
gimp_plugin_menu_register ("plug_in_decompose", "<Image>/Filters/Colors");
253
gimp_plugin_menu_register ("plug_in_decompose", "<Image>/Image/Mode");
298
"Peter Kirchgessner",
304
G_N_ELEMENTS (return_vals),
307
gimp_install_procedure (PLUG_IN_PROC_REG,
308
N_("Decompose an image into separate colorspace components"),
309
"This function creates new gray images with "
310
"different channel information in each of them. "
311
"Pixels in the foreground color will appear black "
312
"in all output images. This can be used for "
313
"things like crop marks that have to show up on "
315
"Peter Kirchgessner",
316
"Peter Kirchgessner, Clarence Risher",
322
G_N_ELEMENTS (return_vals),
325
gimp_plugin_menu_register (PLUG_IN_PROC_REG, "<Image>/Colors/Components");
1185
1432
static gboolean
1186
1433
decompose_dialog (void)
1189
1436
GtkWidget *main_vbox;
1191
1437
GtkWidget *frame;
1192
1438
GtkWidget *vbox;
1197
gimp_ui_init ("decompose", FALSE);
1199
dlg = gimp_dialog_new (_("Decompose"), "decompose",
1201
gimp_standard_help_func, "plug-in-decompose",
1203
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
1204
GTK_STOCK_OK, GTK_RESPONSE_OK,
1448
for (j = 0; j < G_N_ELEMENTS (extract); j++)
1450
if (extract[j].dialog &&
1451
g_ascii_strcasecmp (decovals.extract_type, extract[j].type) == 0)
1458
gimp_ui_init (PLUG_IN_BINARY, FALSE);
1460
dialog = gimp_dialog_new (_("Decompose"), PLUG_IN_BINARY,
1462
gimp_standard_help_func, PLUG_IN_PROC,
1464
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
1465
GTK_STOCK_OK, GTK_RESPONSE_OK,
1469
gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
1471
GTK_RESPONSE_CANCEL,
1474
gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
1475
gimp_window_set_transient (GTK_WINDOW (dialog));
1208
1477
main_vbox = gtk_vbox_new (FALSE, 12);
1209
1478
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12);
1210
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), main_vbox,
1479
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), main_vbox,
1211
1480
TRUE, TRUE, 0);
1212
1481
gtk_widget_show (main_vbox);
1214
/* parameter settings */
1215
1483
frame = gimp_frame_new (_("Extract Channels"));
1216
1484
gtk_box_pack_start (GTK_BOX (main_vbox), frame, TRUE, TRUE, 0);
1485
gtk_widget_show (frame);
1218
vbox = gtk_vbox_new (FALSE, 2);
1487
vbox = gtk_vbox_new (FALSE, 6);
1219
1488
gtk_container_add (GTK_CONTAINER (frame), vbox);
1489
gtk_widget_show (vbox);
1491
hbox = gtk_hbox_new (FALSE, 6);
1492
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
1493
gtk_widget_show (hbox);
1495
label = gtk_label_new_with_mnemonic (_("Color _model:"));
1496
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
1497
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
1498
gtk_widget_show (label);
1500
combo = g_object_new (GIMP_TYPE_INT_COMBO_BOX, NULL);
1222
1501
for (j = 0; j < G_N_ELEMENTS (extract); j++)
1224
if (!extract[j].dialog)
1227
toggle = gtk_radio_button_new_with_label (group,
1228
gettext (extract[j].type));
1229
group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (toggle));
1230
gtk_box_pack_start (GTK_BOX (vbox), toggle, TRUE, TRUE, 0);
1231
decoint.extract_flag[j] =
1232
(g_ascii_strcasecmp (decovals.extract_type, extract[j].type) == 0);
1233
gtk_widget_show (toggle);
1235
g_signal_connect (toggle, "toggled",
1236
G_CALLBACK (gimp_toggle_button_update),
1237
&(decoint.extract_flag[j]));
1239
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle),
1240
decoint.extract_flag[j]);
1503
if (extract[j].dialog)
1505
gchar *label = g_strdup (gettext (extract[j].type));
1508
for (l = label; *l; l++)
1509
if (*l == '-' || *l == '_')
1512
gimp_int_combo_box_append (GIMP_INT_COMBO_BOX (combo),
1513
GIMP_INT_STORE_LABEL, label,
1514
GIMP_INT_STORE_VALUE, j,
1243
toggle = gtk_check_button_new_with_mnemonic (_("Decompose to _layers"));
1520
gtk_box_pack_start (GTK_BOX (hbox), combo, TRUE, TRUE, 0);
1521
gtk_widget_show (combo);
1523
gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo);
1525
gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo),
1527
G_CALLBACK (gimp_int_combo_box_get_active),
1530
toggle = gtk_check_button_new_with_mnemonic (_("_Decompose to layers"));
1531
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle),
1532
decovals.as_layers);
1244
1533
gtk_box_pack_start (GTK_BOX (main_vbox), toggle, FALSE, FALSE, 0);
1534
gtk_widget_show (toggle);
1245
1536
g_signal_connect (toggle, "toggled",
1246
1537
G_CALLBACK (gimp_toggle_button_update),
1247
1538
&decovals.as_layers);
1541
gtk_check_button_new_with_mnemonic (_("_Foreground as registration color"));
1542
gimp_help_set_help_data (toggle, _("Pixels in the foreground color will "
1543
"appear black in all output images. "
1544
"This can be used for things like crop "
1545
"marks that have to show up on all "
1546
"channels."), PLUG_IN_PROC);
1248
1547
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle),
1249
decovals.as_layers);
1548
decovals.use_registration);
1549
gtk_box_pack_start (GTK_BOX (main_vbox), toggle, FALSE, FALSE, 0);
1250
1550
gtk_widget_show (toggle);
1252
gtk_widget_show (vbox);
1253
gtk_widget_show (frame);
1254
gtk_widget_show (dlg);
1256
run = (gimp_dialog_run (GIMP_DIALOG (dlg)) == GTK_RESPONSE_OK);
1258
gtk_widget_destroy (dlg);
1552
g_signal_connect (toggle, "toggled",
1553
G_CALLBACK (gimp_toggle_button_update),
1554
&decovals.use_registration);
1556
gtk_widget_show (dialog);
1558
run = (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK);
1560
gtk_widget_destroy (dialog);
1264
for (j = 0; j < G_N_ELEMENTS (extract); j++)
1266
if (decoint.extract_flag[j])
1268
strcpy (decovals.extract_type, extract[j].type);
1563
strcpy (decovals.extract_type, extract[extract_idx].type);