don't conflict with the app translation files

* po-plug-ins/Makefile.in.in: don't conflict with the app translation
files

* plug-ins/compose
* plug-ins/decompose: updates

-Yosh
This commit is contained in:
Manish Singh 1999-06-05 21:20:19 +00:00
parent db54371de7
commit 18e5d0b381
8 changed files with 796 additions and 318 deletions

View file

@ -1,3 +1,11 @@
Sat Jun 5 14:16:57 PDT 1999 Manish Singh <yosh@gimp.org>
* po-plug-ins/Makefile.in.in: don't conflict with the app translation
files
* plug-ins/compose
* plug-ins/decompose: updates
Fri Jun 4 19:00:12 PDT 1999 Manish Singh <yosh@gimp.org>
* configure.in: version number bump to 1.1.6

View file

@ -1,7 +1,7 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
* Compose plug-in (C) 1997 Peter Kirchgessner
* e-mail: pkirchg@aol.com, WWW: http://members.aol.com/pkirchg
* Compose plug-in (C) 1997,1999 Peter Kirchgessner
* e-mail: peter@kirchgessner.net, WWW: http://www.kirchgessner.net
*
* 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
@ -25,8 +25,22 @@
/* Event history:
* V 1.00, PK, 29-Jul-97, Creation
* V 1.01, nn, 20-Dec-97, Add default case in switch for hsv_to_rgb ()
* V 1.02, PK, 18-Sep-98, Change variable names in Parameter definition.
* Otherwise script-fu merges parameters (reported by Patrick Valsecchi)
* Check images for same width/height (interactive mode)
* Use drawables in interactive menu
* Use g_message in interactive mode
* Check sensitivity of menues (thanks to Kevin Turner,
* kevint@poboxes.com)
* V1.03, PK, 17-Mar-99, Update for GIMP 1.1.3
* Allow image ID 0
* Prepare for localization
*/
static char ident[] = "@(#) GIMP Compose plug-in v1.01 20-Dec-97";
static char ident[] = "@(#) GIMP Compose plug-in v1.03 17-Mar-99";
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdio.h>
#include <stdlib.h>
@ -35,8 +49,6 @@ static char ident[] = "@(#) GIMP Compose plug-in v1.01 20-Dec-97";
#include "gtk/gtk.h"
#include "libgimp/gimp.h"
#include "libgimp/gimpmenu.h"
#include "config.h"
#include "libgimp/stdplugins-intl.h"
/* Declare local functions
@ -48,8 +60,11 @@ static void run (char *name,
int *nreturn_vals,
GParam **return_vals);
static void show_message (const char *message);
static gint32 compose (char *compose_type,
gint32 *compose_ID);
gint32 *compose_ID,
int compose_by_drawable);
static gint32 create_new_image (char *filename, guint width, guint height,
GDrawableType gdtype, gint32 *layer_ID, GDrawable **drawable,
@ -57,22 +72,22 @@ static gint32 create_new_image (char *filename, guint width, guint height,
static int cmp_icase (char *s1, char *s2);
static void compose_rgb (unsigned char **src, int numpix,
static void compose_rgb (unsigned char **src, int *incr, int numpix,
unsigned char *dst);
static void compose_rgba (unsigned char **src, int numpix,
static void compose_rgba (unsigned char **src, int *incr, int numpix,
unsigned char *dst);
static void compose_hsv (unsigned char **src, int numpix,
static void compose_hsv (unsigned char **src, int *incr, int numpix,
unsigned char *dst);
static void compose_cmy (unsigned char **src, int numpix,
static void compose_cmy (unsigned char **src, int *incr, int numpix,
unsigned char *dst);
static void compose_cmyk (unsigned char **src, int numpix,
static void compose_cmyk (unsigned char **src, int *incr, int numpix,
unsigned char *dst);
static void hsv_to_rgb (unsigned char *h, unsigned char *s,
unsigned char *v, unsigned char *rgb);
static gint compose_dialog (char *compose_type,
gint32 image_ID);
gint32 drawable_ID);
static gint check_gray (gint32 image_id,
gint32 drawable_id,
@ -99,21 +114,24 @@ typedef struct {
char *channel_name[MAX_COMPOSE_IMAGES]; /* channel names for dialog */
char *filename; /* Name of new image */
/* Compose functon */
void (*compose_fun)(unsigned char **src, int numpix, unsigned char *dst);
void (*compose_fun)(unsigned char **src, int *incr_src, int numpix,
unsigned char *dst);
} COMPOSE_DSC;
/* Array of available compositions. */
#define CHNL_NA "-"
static COMPOSE_DSC compose_dsc[] = {
{ N_("RGB"), 3, { N_("Red:"), N_("Green: "), N_("Blue:"), N_("N/A") },
"rgb-compose", compose_rgb },
{ N_("RGB"), 3, { N_("Red:"), N_("Green: "), N_("Blue:"), CHNL_NA },
N_("rgb-compose"), compose_rgb },
{ N_("RGBA"), 4, { N_("Red:"), N_("Green: "), N_("Blue:"),N_("Alpha:") },
"rgba-compose", compose_rgba },
{ N_("HSV"), 3, { N_("Hue:"), N_("Saturation:"), N_("Value:"), N_("N/A") },
"hsv-compose", compose_hsv },
{ N_("CMY"), 3, { N_("Cyan:"), N_("Magenta: "), N_("Yellow:"), N_("N/A") },
"cmy-compose", compose_cmy },
N_("rgba-compose"), compose_rgba },
{ N_("HSV"), 3, { N_("Hue:"), N_("Saturation:"), N_("Value:"), CHNL_NA },
N_("hsv-compose"), compose_hsv },
{ N_("CMY"), 3, { N_("Cyan:"), N_("Magenta: "), N_("Yellow:"), CHNL_NA },
N_("cmy-compose"), compose_cmy },
{ N_("CMYK"), 4, { N_("Cyan:"), N_("Magenta: "),N_("Yellow:"),N_("Black:")},
"cmyk-compose", compose_cmyk }
N_("cmyk-compose"), compose_cmyk }
};
#define MAX_COMPOSE_TYPES (sizeof (compose_dsc) / sizeof (compose_dsc[0]))
@ -126,7 +144,10 @@ typedef struct {
/* Dialog structure */
typedef struct {
int width, height; /* Size of selected image */
GtkWidget *channel_label[MAX_COMPOSE_IMAGES]; /* The labels to change */
GtkWidget *channel_menu[MAX_COMPOSE_IMAGES]; /* The menues */
gint32 select_ID[MAX_COMPOSE_IMAGES]; /* Image Ids selected by menu */
gint compose_flag[MAX_COMPOSE_TYPES]; /* toggle data of compose type */
@ -149,7 +170,9 @@ static ComposeVals composevals =
static ComposeInterface composeint =
{
0, 0, /* width, height */
{ NULL }, /* Label Widgets */
{ NULL }, /* Menu Widgets */
{ 0 }, /* Image IDs from menues */
{ 0 }, /* Compose type toggle flags */
FALSE /* run */
@ -166,11 +189,11 @@ query ()
static GParamDef args[] =
{
{ PARAM_INT32, "run_mode", "Interactive, non-interactive" },
{ PARAM_IMAGE, "image", "First input image" },
{ PARAM_IMAGE, "image1", "First input image" },
{ PARAM_DRAWABLE, "drawable", "Input drawable (not used)" },
{ PARAM_IMAGE, "image", "Second input image" },
{ PARAM_IMAGE, "image", "Third input image" },
{ PARAM_IMAGE, "image", "Fourth input image" },
{ PARAM_IMAGE, "image2", "Second input image" },
{ PARAM_IMAGE, "image3", "Third input image" },
{ PARAM_IMAGE, "image4", "Fourth input image" },
{ PARAM_STRING, "compose_type", "What to compose: RGB, RGBA, HSV,\
CMY, CMYK" }
};
@ -181,22 +204,64 @@ query ()
static int nargs = sizeof (args) / sizeof (args[0]);
static int nreturn_vals = sizeof (return_vals) / sizeof (return_vals[0]);
static GParamDef drw_args[] =
{
{ PARAM_INT32, "run_mode", "Interactive, non-interactive" },
{ PARAM_IMAGE, "image1", "First input image (not used)" },
{ PARAM_DRAWABLE, "drawable1", "First input drawable" },
{ PARAM_DRAWABLE, "drawable2", "Second input drawable" },
{ PARAM_DRAWABLE, "drawable3", "Third input drawable" },
{ PARAM_DRAWABLE, "drawable4", "Fourth input drawable" },
{ PARAM_STRING, "compose_type", "What to compose: RGB, RGBA, HSV,\
CMY, CMYK" }
};
static GParamDef drw_return_vals[] =
{
{ PARAM_IMAGE, "new_image", "Output image" }
};
static int drw_nargs = sizeof (args) / sizeof (args[0]);
static int drw_nreturn_vals = sizeof (return_vals) / sizeof (return_vals[0]);
INIT_I18N ();
gimp_install_procedure ("plug_in_compose",
_("Compose an image from different types of channels"),
_("Compose an image from multiple gray images"),
_("This function creates a new image from\
different channel informations kept in gray images"),
multiple gray images"),
"Peter Kirchgessner",
"Peter Kirchgessner (pkirchg@aol.com)",
"Peter Kirchgessner (peter@kirchgessner.net)",
"1997",
_("<Image>/Image/Channel Ops/Compose"),
"GRAY",
"GRAY*",
PROC_PLUG_IN,
nargs, nreturn_vals,
args, return_vals);
gimp_install_procedure ("plug_in_drawable_compose",
_("Compose an image from multiple drawables of gray images"),
_("This function creates a new image from\
multiple drawables of gray images"),
"Peter Kirchgessner",
"Peter Kirchgessner (peter@kirchgessner.net)",
"1998",
NULL, /* It is not available in interactive mode */
"GRAY*",
PROC_PLUG_IN,
drw_nargs, drw_nreturn_vals,
drw_args, drw_return_vals);
}
static void show_message (const char *message)
{
if (run_mode == RUN_INTERACTIVE)
g_message (message);
else
printf ("%s\n", message);
}
static void
run (char *name,
int nparams,
@ -206,11 +271,14 @@ run (char *name,
{
static GParam values[2];
GStatusType status = STATUS_SUCCESS;
gint32 image_ID;
gint32 image_ID, drawable_ID;
int compose_by_drawable;
char msg[256];
INIT_I18N ();
run_mode = param[0].data.d_int32;
compose_by_drawable = (strcmp (name, "plug_in_drawable_compose") == 0);
*nreturn_vals = 2;
*return_vals = values;
@ -224,20 +292,44 @@ run (char *name,
{
case RUN_INTERACTIVE:
/* Possibly retrieve data */
gimp_get_data ("plug_in_compose", &composevals);
gimp_get_data (name , &composevals);
/* The dialog is now drawable based. Get a drawable-ID of the image */
if (strcmp (name, "plug_in_compose") == 0)
{gint32 *layer_list;
gint nlayers;
layer_list = gimp_image_get_layers (param[1].data.d_int32, &nlayers);
if ((layer_list == NULL) || (nlayers <= 0))
{
sprintf (msg, _("compose: Could not get layers for image %d"),
(int)param[1].data.d_int32);
show_message (msg);
return;
}
drawable_ID = layer_list[0];
g_free (layer_list);
}
else
drawable_ID = param[2].data.d_int32;
compose_by_drawable = 1;
/* First acquire information with a dialog */
if (! compose_dialog (composevals.compose_type, param[1].data.d_int32))
if (! compose_dialog (composevals.compose_type, drawable_ID))
return;
break;
case RUN_NONINTERACTIVE:
/* Make sure all the arguments are there! */
if (nparams != 7)
status = STATUS_CALLING_ERROR;
if (status == STATUS_SUCCESS)
{
composevals.compose_ID[0] = param[1].data.d_int32;
composevals.compose_ID[0] =
compose_by_drawable ? param[2].data.d_int32 : param[1].data.d_int32;
composevals.compose_ID[1] = param[3].data.d_int32;
composevals.compose_ID[2] = param[4].data.d_int32;
composevals.compose_ID[3] = param[5].data.d_int32;
@ -249,7 +341,7 @@ run (char *name,
case RUN_WITH_LAST_VALS:
/* Possibly retrieve data */
gimp_get_data ("plug_in_compose", &composevals);
gimp_get_data (name, &composevals);
break;
default:
@ -261,9 +353,10 @@ run (char *name,
if (run_mode != RUN_NONINTERACTIVE)
gimp_progress_init (_("Composing..."));
image_ID = compose (composevals.compose_type, composevals.compose_ID);
image_ID = compose (composevals.compose_type, composevals.compose_ID,
compose_by_drawable);
if (image_ID <= 0)
if (image_ID < 0)
{
status = STATUS_EXECUTION_ERROR;
}
@ -278,7 +371,7 @@ run (char *name,
/* Store data */
if (run_mode == RUN_INTERACTIVE)
gimp_set_data ("plug_in_compose", &composevals, sizeof (ComposeVals));
gimp_set_data (name, &composevals, sizeof (ComposeVals));
}
values[0].data.d_status = status;
@ -288,13 +381,14 @@ run (char *name,
/* Compose an image from several gray-images */
static gint32
compose (char *compose_type,
gint32 *compose_ID)
gint32 *compose_ID,
int compose_by_drawable)
{int width, height, tile_height, scan_lines;
int num_images, compose_idx;
int num_images, compose_idx, incr_src[MAX_COMPOSE_IMAGES];
int i, j;
gint num_layers;
gint32 *g32, layer_ID_src[MAX_COMPOSE_IMAGES], layer_ID_dst, image_ID_dst;
gint32 layer_ID_dst, image_ID_dst;
unsigned char *src[MAX_COMPOSE_IMAGES], *dst = (unsigned char *)ident;
GDrawableType gdtype_dst;
GDrawable *drawable_src[MAX_COMPOSE_IMAGES], *drawable_dst;
@ -311,39 +405,69 @@ compose (char *compose_type,
return (-1);
num_images = compose_dsc[compose_idx].num_images;
tile_height = gimp_tile_height ();
/* Check image sizes */
if (compose_by_drawable)
{
width = gimp_drawable_width (compose_ID[0]);
height = gimp_drawable_height (compose_ID[0]);
for (j = 1; j < num_images; j++)
{
if ( (width != (int)gimp_drawable_width (compose_ID[j]))
|| (height != (int)gimp_drawable_height (compose_ID[j])))
{
show_message (_("compose: drawables have different size"));
return -1;
}
}
for (j = 0; j < num_images; j++)
drawable_src[j] = gimp_drawable_get (compose_ID[j]);
}
else /* Compose by image ID */
{
width = gimp_image_width (compose_ID[0]);
height = gimp_image_height (compose_ID[0]);
tile_height = gimp_tile_height ();
for (j = 1; j < num_images; j++)
{
if ( (width != (int)gimp_image_width (compose_ID[j]))
|| (height != (int)gimp_image_height (compose_ID[j])))
{
printf ("compose: images have different size\n");
show_message (_("compose: images have different size"));
return -1;
}
}
/* Get first layer/drawable/pixel region for all input images */
/* Get first layer/drawable for all input images */
for (j = 0; j < num_images; j++)
{
{gint32 *g32;
/* Get first layer of image */
g32 = gimp_image_get_layers (compose_ID[j], &num_layers);
if ((g32 == NULL) || (num_layers <= 0))
{
printf ("compose: error in getting layer IDs\n");
show_message (_("compose: error in getting layer IDs"));
return (-1);
}
layer_ID_src[j] = g32[0];
/* Get drawable for layer */
drawable_src[j] = gimp_drawable_get (layer_ID_src[j]);
if (drawable_src[j]->bpp != 1)
drawable_src[j] = gimp_drawable_get (g32[0]);
g_free (g32);
}
}
/* Get pixel region for all input drawables */
for (j = 0; j < num_images; j++)
{
printf ("compose: image is not a gray image\n");
/* Check bytes per pixel */
incr_src[j] = drawable_src[j]->bpp;
if ((incr_src[j] != 1) && (incr_src[j] != 2))
{char msg[256];
sprintf (msg, _("compose: image is not a gray image (bpp=%d)"),
incr_src[j]);
show_message (msg);
return (-1);
}
@ -356,7 +480,7 @@ compose (char *compose_type,
* drawable_src[j]->bpp);
if (src[j] == NULL)
{
printf ("compose: not enough memory\n");
show_message (_("compose: not enough memory"));
return (-1);
}
}
@ -371,7 +495,7 @@ compose (char *compose_type,
if (dst == NULL)
{
for (j = 0; j < num_images; j++) g_free (src[j]);
printf ("compose: not enough memory\n");
show_message (_("compose: not enough memory"));
return (-1);
}
@ -387,7 +511,7 @@ compose (char *compose_type,
width, scan_lines);
/* Do the composition */
compose_dsc[compose_idx].compose_fun (src, width*tile_height, dst);
compose_dsc[compose_idx].compose_fun (src,incr_src,width*tile_height,dst);
/* Set destination pixel region */
gimp_pixel_rgn_set_rect (&pixel_rgn_dst, dst, 0, i, width, scan_lines);
@ -465,6 +589,7 @@ static int cmp_icase (char *s1, char *s2)
static void
compose_rgb (unsigned char **src,
int *incr_src,
int numpix,
unsigned char *dst)
@ -473,7 +598,10 @@ compose_rgb (unsigned char **src,
register unsigned char *blue_src = src[2];
register unsigned char *rgb_dst = dst;
register int count = numpix;
int red_incr = incr_src[0], green_incr = incr_src[1], blue_incr = incr_src[2];
if ((red_incr == 1) && (green_incr == 1) && (blue_incr == 1))
{
while (count-- > 0)
{
*(rgb_dst++) = *(red_src++);
@ -481,10 +609,21 @@ compose_rgb (unsigned char **src,
*(rgb_dst++) = *(blue_src++);
}
}
else
{
while (count-- > 0)
{
*(rgb_dst++) = *red_src; red_src += red_incr;
*(rgb_dst++) = *green_src; green_src += green_incr;
*(rgb_dst++) = *blue_src; blue_src += blue_incr;
}
}
}
static void
compose_rgba (unsigned char **src,
int *incr_src,
int numpix,
unsigned char *dst)
@ -494,7 +633,12 @@ compose_rgba (unsigned char **src,
register unsigned char *alpha_src = src[3];
register unsigned char *rgb_dst = dst;
register int count = numpix;
int red_incr = incr_src[0], green_incr = incr_src[1],
blue_incr = incr_src[2], alpha_incr = incr_src[3];
if ( (red_incr == 1) && (green_incr == 1) && (blue_incr == 1)
&& (alpha_incr == 1))
{
while (count-- > 0)
{
*(rgb_dst++) = *(red_src++);
@ -503,10 +647,22 @@ compose_rgba (unsigned char **src,
*(rgb_dst++) = *(alpha_src++);
}
}
else
{
while (count-- > 0)
{
*(rgb_dst++) = *red_src; red_src += red_incr;
*(rgb_dst++) = *green_src; green_src += green_incr;
*(rgb_dst++) = *blue_src; blue_src += blue_incr;
*(rgb_dst++) = *alpha_src; alpha_src += alpha_incr;
}
}
}
static void
compose_hsv (unsigned char **src,
int *incr_src,
int numpix,
unsigned char *dst)
@ -515,17 +671,22 @@ compose_hsv (unsigned char **src,
register unsigned char *val_src = src[2];
register unsigned char *rgb_dst = dst;
register int count = numpix;
int hue_incr = incr_src[0], sat_incr = incr_src[1], val_incr = incr_src[2];
while (count-- > 0)
{
hsv_to_rgb (hue_src++, sat_src++, val_src++, rgb_dst);
hsv_to_rgb (hue_src, sat_src, val_src, rgb_dst);
rgb_dst += 3;
hue_src += hue_incr;
sat_src += sat_incr;
val_src += val_incr;
}
}
static void
compose_cmy (unsigned char **src,
int *incr_src,
int numpix,
unsigned char *dst)
@ -534,7 +695,11 @@ compose_cmy (unsigned char **src,
register unsigned char *yellow_src = src[2];
register unsigned char *rgb_dst = dst;
register int count = numpix;
int cyan_incr = incr_src[0], magenta_incr = incr_src[1],
yellow_incr = incr_src[2];
if ( (cyan_incr == 1) && (magenta_incr == 1) && (yellow_incr == 1))
{
while (count-- > 0)
{
*(rgb_dst++) = 255 - *(cyan_src++);
@ -542,10 +707,24 @@ compose_cmy (unsigned char **src,
*(rgb_dst++) = 255 - *(yellow_src++);
}
}
else
{
while (count-- > 0)
{
*(rgb_dst++) = 255 - *cyan_src;
*(rgb_dst++) = 255 - *magenta_src;
*(rgb_dst++) = 255 - *yellow_src;
cyan_src += cyan_incr;
magenta_src += magenta_incr;
yellow_src += yellow_incr;
}
}
}
static void
compose_cmyk (unsigned char **src,
int *incr_src,
int numpix,
unsigned char *dst)
@ -556,15 +735,17 @@ compose_cmyk (unsigned char **src,
register unsigned char *rgb_dst = dst;
register int count = numpix;
int cyan, magenta, yellow, black;
int cyan_incr = incr_src[0], magenta_incr = incr_src[1],
yellow_incr = incr_src[2], black_incr = incr_src[3];
while (count-- > 0)
{
black = (int)*(black_src++);
black = (int)*black_src;
if (black)
{
cyan = (int)*(cyan_src++);
magenta = (int)*(magenta_src++);
yellow = (int)*(yellow_src++);
cyan = (int)*cyan_src;
magenta = (int)*magenta_src;
yellow = (int)*yellow_src;
cyan += black; if (cyan > 255) cyan = 255;
magenta += black; if (magenta > 255) magenta = 255;
yellow += black; if (yellow > 255) yellow = 255;
@ -574,17 +755,21 @@ compose_cmyk (unsigned char **src,
}
else
{
*(rgb_dst++) = 255 - *(cyan_src++);
*(rgb_dst++) = 255 - *(magenta_src++);
*(rgb_dst++) = 255 - *(yellow_src++);
*(rgb_dst++) = 255 - *cyan_src;
*(rgb_dst++) = 255 - *magenta_src;
*(rgb_dst++) = 255 - *yellow_src;
}
cyan_src += cyan_incr;
magenta_src += magenta_incr;
yellow_src += yellow_incr;
black_src += black_incr;
}
}
static gint
compose_dialog (char *compose_type,
gint32 image_ID)
gint32 drawable_ID)
{
GtkWidget *dlg;
GtkWidget *button;
@ -598,7 +783,7 @@ compose_dialog (char *compose_type,
GSList *group;
gchar **argv;
gint argc;
int j, compose_idx;
int j, compose_idx, sensitive;
/* Check default compose type */
compose_idx = -1;
@ -609,6 +794,10 @@ compose_dialog (char *compose_type,
}
if (compose_idx < 0) compose_idx = 0;
/* Save original image width/height */
composeint.width = gimp_drawable_width (drawable_ID);
composeint.height = gimp_drawable_height (drawable_ID);
argc = 1;
argv = g_new (gchar *, 1);
argv[0] = g_strdup ("Compose");
@ -618,7 +807,7 @@ compose_dialog (char *compose_type,
dlg = gtk_dialog_new ();
gtk_window_set_title (GTK_WINDOW (dlg), _("Compose"));
gtk_window_position (GTK_WINDOW (dlg), GTK_WIN_POS_MOUSE);
gtk_window_set_position (GTK_WINDOW (dlg), GTK_WIN_POS_MOUSE);
gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
(GtkSignalFunc) compose_close_callback,
NULL);
@ -644,18 +833,18 @@ compose_dialog (char *compose_type,
/* parameter settings */
hbox = gtk_hbox_new (FALSE, 0);
gtk_container_border_width (GTK_CONTAINER (hbox), 0);
gtk_container_set_border_width (GTK_CONTAINER (hbox), 0);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), hbox, TRUE, TRUE, 0);
gtk_widget_show (hbox);
/* The left frame keeps the compose type toggles */
left_frame = gtk_frame_new (_("Compose channels:"));
gtk_frame_set_shadow_type (GTK_FRAME (left_frame), GTK_SHADOW_ETCHED_IN);
gtk_container_border_width (GTK_CONTAINER (left_frame), 10);
gtk_container_set_border_width (GTK_CONTAINER (left_frame), 5);
gtk_box_pack_start (GTK_BOX (hbox), left_frame, TRUE, TRUE, 0);
left_vbox = gtk_vbox_new (FALSE, 5);
gtk_container_border_width (GTK_CONTAINER (left_vbox), 10);
gtk_container_set_border_width (GTK_CONTAINER (left_vbox), 5);
gtk_container_add (GTK_CONTAINER (left_frame), left_vbox);
/* The right frame keeps the selection menues for images. */
@ -665,11 +854,11 @@ compose_dialog (char *compose_type,
right_frame = gtk_frame_new (_("Channel representations:"));
gtk_frame_set_shadow_type (GTK_FRAME (right_frame), GTK_SHADOW_ETCHED_IN);
gtk_container_border_width (GTK_CONTAINER (right_frame), 10);
gtk_container_set_border_width (GTK_CONTAINER (right_frame), 5);
gtk_box_pack_start (GTK_BOX (hbox), right_frame, TRUE, TRUE, 0);
right_vbox = gtk_vbox_new (FALSE, 5);
gtk_container_border_width (GTK_CONTAINER (right_vbox), 10);
gtk_container_set_border_width (GTK_CONTAINER (right_vbox), 5);
gtk_container_add (GTK_CONTAINER (right_frame), right_vbox);
table = gtk_table_new (MAX_COMPOSE_IMAGES, 3, FALSE);
@ -688,13 +877,17 @@ compose_dialog (char *compose_type,
GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (label);
}
/* Set sensitivity of last label */
sensitive = (strcmp (compose_dsc[compose_idx].channel_name[3],
CHNL_NA) != 0);
gtk_widget_set_sensitive (composeint.channel_label[3], sensitive);
/* Menues to select images */
for (j = 0; j < MAX_COMPOSE_IMAGES; j++)
{
composeint.select_ID[j] = image_ID;
image_option_menu = gtk_option_menu_new ();
image_menu = gimp_image_menu_new (check_gray, image_menu_callback,
composeint.select_ID[j] = drawable_ID;
composeint.channel_menu[j] = image_option_menu = gtk_option_menu_new ();
image_menu = gimp_drawable_menu_new (check_gray, image_menu_callback,
&(composeint.select_ID[j]), composeint.select_ID[j]);
gtk_table_attach (GTK_TABLE (table), image_option_menu, 2, 3, j, j+1,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
@ -702,6 +895,7 @@ compose_dialog (char *compose_type,
gtk_widget_show (image_option_menu);
gtk_option_menu_set_menu (GTK_OPTION_MENU (image_option_menu), image_menu);
}
gtk_widget_set_sensitive (composeint.channel_menu[3], sensitive);
/* Compose types */
group = NULL;
@ -816,7 +1010,9 @@ check_gray (gint32 image_id,
gpointer data)
{
return (gimp_image_base_type (image_id) == GRAY);
return ( (gimp_image_base_type (image_id) == GRAY)
&& (gimp_image_width (image_id) == composeint.width)
&& (gimp_image_height (image_id) == composeint.height));
}
@ -864,6 +1060,7 @@ compose_type_toggle_update (GtkWidget *widget,
{
gint *toggle_val;
gint compose_idx, j;
int sensitive;
toggle_val = (gint *) data;
@ -874,6 +1071,12 @@ compose_type_toggle_update (GtkWidget *widget,
for (j = 0; j < MAX_COMPOSE_IMAGES; j++)
gtk_label_set_text (GTK_LABEL (composeint.channel_label[j]),
compose_dsc[compose_idx].channel_name[j]);
/* Set sensitivity of last label */
sensitive = (strcmp (compose_dsc[compose_idx].channel_name[3],
CHNL_NA) != 0);
gtk_widget_set_sensitive (composeint.channel_label[3], sensitive);
gtk_widget_set_sensitive (composeint.channel_menu[3], sensitive);
}
else
*toggle_val = FALSE;

View file

@ -1,7 +1,7 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
* Decompose plug-in (C) 1997 Peter Kirchgessner
* e-mail: pkirchg@aol.com, WWW: http://members.aol.com/pkirchg
* e-mail: peter@kirchgessner.net, WWW: http://www.kirchgessner.net
*
* 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
@ -24,8 +24,15 @@
/* Event history:
* V 1.00, PK, 29-Jul-97, Creation
* V 1.01, PK, 19-Mar-99, Update for GIMP V1.1.3
* Prepare for localization
* Use g_message() in interactive mode
*/
static char ident[] = "@(#) GIMP Decompose plug-in v1.00 29-Jul-97";
static char ident[] = "@(#) GIMP Decompose plug-in v1.01 19-Mar-99";
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdio.h>
#include <stdlib.h>
@ -33,6 +40,7 @@ static char ident[] = "@(#) GIMP Decompose plug-in v1.00 29-Jul-97";
#include <ctype.h>
#include "gtk/gtk.h"
#include "libgimp/gimp.h"
#include "libgimp/stdplugins-intl.h"
/* Declare local functions
*/
@ -52,6 +60,7 @@ static gint32 create_new_image (char *filename, guint width, guint height,
GImageType type, gint32 *layer_ID, GDrawable **drawable,
GPixelRgn *pixel_rgn);
static void show_message (const char *msg);
static int cmp_icase (char *s1, char *s2);
static void rgb_to_hsv (unsigned char *r, unsigned char *g, unsigned char *b,
unsigned char *h, unsigned char *s, unsigned char *v);
@ -117,23 +126,26 @@ typedef struct {
} EXTRACT;
static EXTRACT extract[] = {
{ "RGB", 1, 3, { "red", "green", "blue" }, extract_rgb },
{ "Red", 0, 1, { "red" }, extract_red },
{ "Green", 0, 1, { "green" }, extract_green },
{ "Blue", 0, 1, { "blue" }, extract_blue },
{ "HSV", 1, 3, { "hue", "saturation", "value", }, extract_hsv },
{ "Hue", 0, 1, { "hue" }, extract_hue },
{ "Saturation",0,1, { "saturation", }, extract_sat },
{ "Value", 0, 1, { "value", }, extract_val },
{ "CMY", 1, 3, { "cyan", "magenta", "yellow" }, extract_cmy },
{ "Cyan", 0, 1, { "cyan", }, extract_cyan },
{ "Magenta", 0, 1, { "magenta", }, extract_magenta },
{ "Yellow", 0, 1, { "yellow", }, extract_yellow },
{ "CMYK", 1, 4, { "cyan_k", "magenta_k", "yellow_k", "black" }, extract_cmyk },
{ "Cyan_K", 0, 1, { "cyan_k", }, extract_cyank },
{ "Magenta_K", 0,1, { "magenta_k", }, extract_magentak },
{ "Yellow_K", 0, 1, { "yellow_k", }, extract_yellowk },
{ "Alpha", 1, 1, { "alpha" }, extract_alpha }
{ N_("RGB"), 1, 3, { N_("red"), N_("green"), N_("blue") }, extract_rgb },
{ N_("Red"), 0, 1, { N_("red") }, extract_red },
{ N_("Green"), 0, 1, { N_("green") }, extract_green },
{ N_("Blue"), 0, 1, { N_("blue") }, extract_blue },
{ N_("HSV"), 1, 3, { N_("hue"), N_("saturation"), N_("value") },
extract_hsv },
{ N_("Hue"), 0, 1, { N_("hue") }, extract_hue },
{ N_("Saturation"),0,1, { N_("saturation") }, extract_sat },
{ N_("Value"), 0, 1, { N_("value") }, extract_val },
{ N_("CMY"), 1, 3, { N_("cyan"), N_("magenta"), N_("yellow") },
extract_cmy },
{ N_("Cyan"), 0, 1, { N_("cyan") }, extract_cyan },
{ N_("Magenta"), 0, 1, { N_("magenta") }, extract_magenta },
{ N_("Yellow"), 0, 1, { N_("yellow") }, extract_yellow },
{ N_("CMYK"), 1, 4, { N_("cyan_k"), N_("magenta_k"), N_("yellow_k"),
N_("black") }, extract_cmyk },
{ N_("Cyan_K"), 0, 1, { N_("cyan_k") }, extract_cyank },
{ N_("Magenta_K"), 0,1, { N_("magenta_k") }, extract_magentak },
{ N_("Yellow_K"), 0, 1, { N_("yellow_k") }, extract_yellowk },
{ N_("Alpha"), 1, 1, { N_("alpha") }, extract_alpha }
};
/* Number of types of extractions */
@ -188,27 +200,41 @@ query ()
static GParamDef return_vals[] =
{
{ PARAM_IMAGE, "new_image", "Output gray image" },
{ PARAM_IMAGE, "new_image", "Output gray image (N/A for single channel extract)" },
{ PARAM_IMAGE, "new_image", "Output gray image (N/A for single channel extract)" },
{ PARAM_IMAGE, "new_image", "Output gray image (N/A for single channel extract)" },
{ PARAM_IMAGE, "new_image",
"Output gray image (N/A for single channel extract)" },
{ PARAM_IMAGE, "new_image",
"Output gray image (N/A for single channel extract)" },
{ PARAM_IMAGE, "new_image",
"Output gray image (N/A for single channel extract)" },
};
static int nargs = sizeof (args) / sizeof (args[0]);
static int nreturn_vals = sizeof (return_vals) / sizeof (return_vals[0]);
INIT_I18N ();
gimp_install_procedure ("plug_in_decompose",
"Decompose an image into different types of channels",
"This function creates new gray images with\
different channel information in each of them",
_("Decompose an image into different types of channels"),
_("This function creates new gray images with\
different channel information in each of them"),
"Peter Kirchgessner",
"Peter Kirchgessner (pkirchg@aol.com)",
"Peter Kirchgessner (peter@kirchgessner.net)",
"1997",
"<Image>/Image/Channel Ops/Decompose",
_("<Image>/Image/Channel Ops/Decompose"),
"RGB*",
PROC_PLUG_IN,
nargs, nreturn_vals,
args, return_vals);
}
static void show_message (const char *message)
{
if (run_mode == RUN_INTERACTIVE)
g_message (message);
else
printf ("%s\n", message);
}
static void
run (char *name,
int nparams,
@ -223,6 +249,8 @@ run (char *name,
gint32 image_ID_extract[MAX_EXTRACT_IMAGES];
gint j;
INIT_I18N ();
run_mode = param[0].data.d_int32;
*nreturn_vals = MAX_EXTRACT_IMAGES+1;
@ -272,13 +300,13 @@ run (char *name,
drawable_type = gimp_drawable_type (param[2].data.d_drawable);
if ((drawable_type != RGB_IMAGE) && (drawable_type != RGBA_IMAGE))
{
printf ("plug_in_decompose: Can only work on RGB*_IMAGE\n");
show_message (_("plug_in_decompose: Can only work on RGB*_IMAGE"));
status = STATUS_CALLING_ERROR;
}
if (status == STATUS_SUCCESS)
{
if (run_mode != RUN_NONINTERACTIVE)
gimp_progress_init ("Decomposing...");
gimp_progress_init (_("Decomposing..."));
num_images = decompose (param[1].data.d_image, param[2].data.d_drawable,
decovals.extract_type, image_ID_extract);
@ -343,13 +371,13 @@ decompose (gint32 image_ID,
drawable_src = gimp_drawable_get (drawable_ID);
if (drawable_src->bpp < 3)
{
printf ("decompose: not an RGB image\n");
show_message (_("decompose: not an RGB image"));
return (-1);
}
if ( (extract[extract_idx].extract_fun == extract_alpha)
&& (!gimp_drawable_has_alpha (drawable_ID)))
{
printf ("decompose: No alpha channel available\n");
show_message (_("decompose: No alpha channel available"));
return (-1);
}
@ -378,7 +406,7 @@ decompose (gint32 image_ID,
}
if (dst[num_images-1] == NULL)
{
printf ("decompose: out of memory\n");
show_message (_("decompose: out of memory"));
for (j = 0; j < num_images; j++)
{
if (dst[j] != NULL) g_free (dst[j]);
@ -441,7 +469,7 @@ create_new_image (char *filename,
image_ID = gimp_image_new (width, height, type);
gimp_image_set_filename (image_ID, filename);
*layer_ID = gimp_layer_new (image_ID, "Background", width, height,
*layer_ID = gimp_layer_new (image_ID, _("Background"), width, height,
gdtype, 100, NORMAL_MODE);
gimp_image_add_layer (image_ID, *layer_ID, 0);
@ -870,44 +898,46 @@ decompose_dialog (void)
argc = 1;
argv = g_new (gchar *, 1);
argv[0] = g_strdup ("Decompose");
argv[0] = g_strdup (_("Decompose"));
gtk_init (&argc, &argv);
gtk_rc_parse (gimp_gtkrc ());
dlg = gtk_dialog_new ();
gtk_window_set_title (GTK_WINDOW (dlg), "Decompose");
gtk_window_position (GTK_WINDOW (dlg), GTK_WIN_POS_MOUSE);
gtk_window_set_title (GTK_WINDOW (dlg), _("Decompose"));
gtk_window_set_position (GTK_WINDOW (dlg), GTK_WIN_POS_MOUSE);
gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
(GtkSignalFunc) decompose_close_callback,
NULL);
/* Action area */
button = gtk_button_new_with_label ("OK");
button = gtk_button_new_with_label (_("OK"));
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
(GtkSignalFunc) decompose_ok_callback,
dlg);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->action_area), button, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->action_area), button,
TRUE, TRUE, 0);
gtk_widget_grab_default (button);
gtk_widget_show (button);
button = gtk_button_new_with_label ("Cancel");
button = gtk_button_new_with_label (_("Cancel"));
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
(GtkSignalFunc) gtk_widget_destroy,
GTK_OBJECT (dlg));
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->action_area), button, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->action_area), button,
TRUE, TRUE, 0);
gtk_widget_show (button);
/* parameter settings */
frame = gtk_frame_new ("Extract channels:");
frame = gtk_frame_new (_("Extract channels:"));
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN);
gtk_container_border_width (GTK_CONTAINER (frame), 10);
gtk_container_set_border_width (GTK_CONTAINER (frame), 5);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), frame, TRUE, TRUE, 0);
vbox = gtk_vbox_new (FALSE, 5);
gtk_container_border_width (GTK_CONTAINER (vbox), 10);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
gtk_container_add (GTK_CONTAINER (frame), vbox);
group = NULL;

View file

@ -1,7 +1,7 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
* Compose plug-in (C) 1997 Peter Kirchgessner
* e-mail: pkirchg@aol.com, WWW: http://members.aol.com/pkirchg
* Compose plug-in (C) 1997,1999 Peter Kirchgessner
* e-mail: peter@kirchgessner.net, WWW: http://www.kirchgessner.net
*
* 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
@ -25,8 +25,22 @@
/* Event history:
* V 1.00, PK, 29-Jul-97, Creation
* V 1.01, nn, 20-Dec-97, Add default case in switch for hsv_to_rgb ()
* V 1.02, PK, 18-Sep-98, Change variable names in Parameter definition.
* Otherwise script-fu merges parameters (reported by Patrick Valsecchi)
* Check images for same width/height (interactive mode)
* Use drawables in interactive menu
* Use g_message in interactive mode
* Check sensitivity of menues (thanks to Kevin Turner,
* kevint@poboxes.com)
* V1.03, PK, 17-Mar-99, Update for GIMP 1.1.3
* Allow image ID 0
* Prepare for localization
*/
static char ident[] = "@(#) GIMP Compose plug-in v1.01 20-Dec-97";
static char ident[] = "@(#) GIMP Compose plug-in v1.03 17-Mar-99";
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdio.h>
#include <stdlib.h>
@ -35,8 +49,6 @@ static char ident[] = "@(#) GIMP Compose plug-in v1.01 20-Dec-97";
#include "gtk/gtk.h"
#include "libgimp/gimp.h"
#include "libgimp/gimpmenu.h"
#include "config.h"
#include "libgimp/stdplugins-intl.h"
/* Declare local functions
@ -48,8 +60,11 @@ static void run (char *name,
int *nreturn_vals,
GParam **return_vals);
static void show_message (const char *message);
static gint32 compose (char *compose_type,
gint32 *compose_ID);
gint32 *compose_ID,
int compose_by_drawable);
static gint32 create_new_image (char *filename, guint width, guint height,
GDrawableType gdtype, gint32 *layer_ID, GDrawable **drawable,
@ -57,22 +72,22 @@ static gint32 create_new_image (char *filename, guint width, guint height,
static int cmp_icase (char *s1, char *s2);
static void compose_rgb (unsigned char **src, int numpix,
static void compose_rgb (unsigned char **src, int *incr, int numpix,
unsigned char *dst);
static void compose_rgba (unsigned char **src, int numpix,
static void compose_rgba (unsigned char **src, int *incr, int numpix,
unsigned char *dst);
static void compose_hsv (unsigned char **src, int numpix,
static void compose_hsv (unsigned char **src, int *incr, int numpix,
unsigned char *dst);
static void compose_cmy (unsigned char **src, int numpix,
static void compose_cmy (unsigned char **src, int *incr, int numpix,
unsigned char *dst);
static void compose_cmyk (unsigned char **src, int numpix,
static void compose_cmyk (unsigned char **src, int *incr, int numpix,
unsigned char *dst);
static void hsv_to_rgb (unsigned char *h, unsigned char *s,
unsigned char *v, unsigned char *rgb);
static gint compose_dialog (char *compose_type,
gint32 image_ID);
gint32 drawable_ID);
static gint check_gray (gint32 image_id,
gint32 drawable_id,
@ -99,21 +114,24 @@ typedef struct {
char *channel_name[MAX_COMPOSE_IMAGES]; /* channel names for dialog */
char *filename; /* Name of new image */
/* Compose functon */
void (*compose_fun)(unsigned char **src, int numpix, unsigned char *dst);
void (*compose_fun)(unsigned char **src, int *incr_src, int numpix,
unsigned char *dst);
} COMPOSE_DSC;
/* Array of available compositions. */
#define CHNL_NA "-"
static COMPOSE_DSC compose_dsc[] = {
{ N_("RGB"), 3, { N_("Red:"), N_("Green: "), N_("Blue:"), N_("N/A") },
"rgb-compose", compose_rgb },
{ N_("RGB"), 3, { N_("Red:"), N_("Green: "), N_("Blue:"), CHNL_NA },
N_("rgb-compose"), compose_rgb },
{ N_("RGBA"), 4, { N_("Red:"), N_("Green: "), N_("Blue:"),N_("Alpha:") },
"rgba-compose", compose_rgba },
{ N_("HSV"), 3, { N_("Hue:"), N_("Saturation:"), N_("Value:"), N_("N/A") },
"hsv-compose", compose_hsv },
{ N_("CMY"), 3, { N_("Cyan:"), N_("Magenta: "), N_("Yellow:"), N_("N/A") },
"cmy-compose", compose_cmy },
N_("rgba-compose"), compose_rgba },
{ N_("HSV"), 3, { N_("Hue:"), N_("Saturation:"), N_("Value:"), CHNL_NA },
N_("hsv-compose"), compose_hsv },
{ N_("CMY"), 3, { N_("Cyan:"), N_("Magenta: "), N_("Yellow:"), CHNL_NA },
N_("cmy-compose"), compose_cmy },
{ N_("CMYK"), 4, { N_("Cyan:"), N_("Magenta: "),N_("Yellow:"),N_("Black:")},
"cmyk-compose", compose_cmyk }
N_("cmyk-compose"), compose_cmyk }
};
#define MAX_COMPOSE_TYPES (sizeof (compose_dsc) / sizeof (compose_dsc[0]))
@ -126,7 +144,10 @@ typedef struct {
/* Dialog structure */
typedef struct {
int width, height; /* Size of selected image */
GtkWidget *channel_label[MAX_COMPOSE_IMAGES]; /* The labels to change */
GtkWidget *channel_menu[MAX_COMPOSE_IMAGES]; /* The menues */
gint32 select_ID[MAX_COMPOSE_IMAGES]; /* Image Ids selected by menu */
gint compose_flag[MAX_COMPOSE_TYPES]; /* toggle data of compose type */
@ -149,7 +170,9 @@ static ComposeVals composevals =
static ComposeInterface composeint =
{
0, 0, /* width, height */
{ NULL }, /* Label Widgets */
{ NULL }, /* Menu Widgets */
{ 0 }, /* Image IDs from menues */
{ 0 }, /* Compose type toggle flags */
FALSE /* run */
@ -166,11 +189,11 @@ query ()
static GParamDef args[] =
{
{ PARAM_INT32, "run_mode", "Interactive, non-interactive" },
{ PARAM_IMAGE, "image", "First input image" },
{ PARAM_IMAGE, "image1", "First input image" },
{ PARAM_DRAWABLE, "drawable", "Input drawable (not used)" },
{ PARAM_IMAGE, "image", "Second input image" },
{ PARAM_IMAGE, "image", "Third input image" },
{ PARAM_IMAGE, "image", "Fourth input image" },
{ PARAM_IMAGE, "image2", "Second input image" },
{ PARAM_IMAGE, "image3", "Third input image" },
{ PARAM_IMAGE, "image4", "Fourth input image" },
{ PARAM_STRING, "compose_type", "What to compose: RGB, RGBA, HSV,\
CMY, CMYK" }
};
@ -181,22 +204,64 @@ query ()
static int nargs = sizeof (args) / sizeof (args[0]);
static int nreturn_vals = sizeof (return_vals) / sizeof (return_vals[0]);
static GParamDef drw_args[] =
{
{ PARAM_INT32, "run_mode", "Interactive, non-interactive" },
{ PARAM_IMAGE, "image1", "First input image (not used)" },
{ PARAM_DRAWABLE, "drawable1", "First input drawable" },
{ PARAM_DRAWABLE, "drawable2", "Second input drawable" },
{ PARAM_DRAWABLE, "drawable3", "Third input drawable" },
{ PARAM_DRAWABLE, "drawable4", "Fourth input drawable" },
{ PARAM_STRING, "compose_type", "What to compose: RGB, RGBA, HSV,\
CMY, CMYK" }
};
static GParamDef drw_return_vals[] =
{
{ PARAM_IMAGE, "new_image", "Output image" }
};
static int drw_nargs = sizeof (args) / sizeof (args[0]);
static int drw_nreturn_vals = sizeof (return_vals) / sizeof (return_vals[0]);
INIT_I18N ();
gimp_install_procedure ("plug_in_compose",
_("Compose an image from different types of channels"),
_("Compose an image from multiple gray images"),
_("This function creates a new image from\
different channel informations kept in gray images"),
multiple gray images"),
"Peter Kirchgessner",
"Peter Kirchgessner (pkirchg@aol.com)",
"Peter Kirchgessner (peter@kirchgessner.net)",
"1997",
_("<Image>/Image/Channel Ops/Compose"),
"GRAY",
"GRAY*",
PROC_PLUG_IN,
nargs, nreturn_vals,
args, return_vals);
gimp_install_procedure ("plug_in_drawable_compose",
_("Compose an image from multiple drawables of gray images"),
_("This function creates a new image from\
multiple drawables of gray images"),
"Peter Kirchgessner",
"Peter Kirchgessner (peter@kirchgessner.net)",
"1998",
NULL, /* It is not available in interactive mode */
"GRAY*",
PROC_PLUG_IN,
drw_nargs, drw_nreturn_vals,
drw_args, drw_return_vals);
}
static void show_message (const char *message)
{
if (run_mode == RUN_INTERACTIVE)
g_message (message);
else
printf ("%s\n", message);
}
static void
run (char *name,
int nparams,
@ -206,11 +271,14 @@ run (char *name,
{
static GParam values[2];
GStatusType status = STATUS_SUCCESS;
gint32 image_ID;
gint32 image_ID, drawable_ID;
int compose_by_drawable;
char msg[256];
INIT_I18N ();
run_mode = param[0].data.d_int32;
compose_by_drawable = (strcmp (name, "plug_in_drawable_compose") == 0);
*nreturn_vals = 2;
*return_vals = values;
@ -224,20 +292,44 @@ run (char *name,
{
case RUN_INTERACTIVE:
/* Possibly retrieve data */
gimp_get_data ("plug_in_compose", &composevals);
gimp_get_data (name , &composevals);
/* The dialog is now drawable based. Get a drawable-ID of the image */
if (strcmp (name, "plug_in_compose") == 0)
{gint32 *layer_list;
gint nlayers;
layer_list = gimp_image_get_layers (param[1].data.d_int32, &nlayers);
if ((layer_list == NULL) || (nlayers <= 0))
{
sprintf (msg, _("compose: Could not get layers for image %d"),
(int)param[1].data.d_int32);
show_message (msg);
return;
}
drawable_ID = layer_list[0];
g_free (layer_list);
}
else
drawable_ID = param[2].data.d_int32;
compose_by_drawable = 1;
/* First acquire information with a dialog */
if (! compose_dialog (composevals.compose_type, param[1].data.d_int32))
if (! compose_dialog (composevals.compose_type, drawable_ID))
return;
break;
case RUN_NONINTERACTIVE:
/* Make sure all the arguments are there! */
if (nparams != 7)
status = STATUS_CALLING_ERROR;
if (status == STATUS_SUCCESS)
{
composevals.compose_ID[0] = param[1].data.d_int32;
composevals.compose_ID[0] =
compose_by_drawable ? param[2].data.d_int32 : param[1].data.d_int32;
composevals.compose_ID[1] = param[3].data.d_int32;
composevals.compose_ID[2] = param[4].data.d_int32;
composevals.compose_ID[3] = param[5].data.d_int32;
@ -249,7 +341,7 @@ run (char *name,
case RUN_WITH_LAST_VALS:
/* Possibly retrieve data */
gimp_get_data ("plug_in_compose", &composevals);
gimp_get_data (name, &composevals);
break;
default:
@ -261,9 +353,10 @@ run (char *name,
if (run_mode != RUN_NONINTERACTIVE)
gimp_progress_init (_("Composing..."));
image_ID = compose (composevals.compose_type, composevals.compose_ID);
image_ID = compose (composevals.compose_type, composevals.compose_ID,
compose_by_drawable);
if (image_ID <= 0)
if (image_ID < 0)
{
status = STATUS_EXECUTION_ERROR;
}
@ -278,7 +371,7 @@ run (char *name,
/* Store data */
if (run_mode == RUN_INTERACTIVE)
gimp_set_data ("plug_in_compose", &composevals, sizeof (ComposeVals));
gimp_set_data (name, &composevals, sizeof (ComposeVals));
}
values[0].data.d_status = status;
@ -288,13 +381,14 @@ run (char *name,
/* Compose an image from several gray-images */
static gint32
compose (char *compose_type,
gint32 *compose_ID)
gint32 *compose_ID,
int compose_by_drawable)
{int width, height, tile_height, scan_lines;
int num_images, compose_idx;
int num_images, compose_idx, incr_src[MAX_COMPOSE_IMAGES];
int i, j;
gint num_layers;
gint32 *g32, layer_ID_src[MAX_COMPOSE_IMAGES], layer_ID_dst, image_ID_dst;
gint32 layer_ID_dst, image_ID_dst;
unsigned char *src[MAX_COMPOSE_IMAGES], *dst = (unsigned char *)ident;
GDrawableType gdtype_dst;
GDrawable *drawable_src[MAX_COMPOSE_IMAGES], *drawable_dst;
@ -311,39 +405,69 @@ compose (char *compose_type,
return (-1);
num_images = compose_dsc[compose_idx].num_images;
tile_height = gimp_tile_height ();
/* Check image sizes */
if (compose_by_drawable)
{
width = gimp_drawable_width (compose_ID[0]);
height = gimp_drawable_height (compose_ID[0]);
for (j = 1; j < num_images; j++)
{
if ( (width != (int)gimp_drawable_width (compose_ID[j]))
|| (height != (int)gimp_drawable_height (compose_ID[j])))
{
show_message (_("compose: drawables have different size"));
return -1;
}
}
for (j = 0; j < num_images; j++)
drawable_src[j] = gimp_drawable_get (compose_ID[j]);
}
else /* Compose by image ID */
{
width = gimp_image_width (compose_ID[0]);
height = gimp_image_height (compose_ID[0]);
tile_height = gimp_tile_height ();
for (j = 1; j < num_images; j++)
{
if ( (width != (int)gimp_image_width (compose_ID[j]))
|| (height != (int)gimp_image_height (compose_ID[j])))
{
printf ("compose: images have different size\n");
show_message (_("compose: images have different size"));
return -1;
}
}
/* Get first layer/drawable/pixel region for all input images */
/* Get first layer/drawable for all input images */
for (j = 0; j < num_images; j++)
{
{gint32 *g32;
/* Get first layer of image */
g32 = gimp_image_get_layers (compose_ID[j], &num_layers);
if ((g32 == NULL) || (num_layers <= 0))
{
printf ("compose: error in getting layer IDs\n");
show_message (_("compose: error in getting layer IDs"));
return (-1);
}
layer_ID_src[j] = g32[0];
/* Get drawable for layer */
drawable_src[j] = gimp_drawable_get (layer_ID_src[j]);
if (drawable_src[j]->bpp != 1)
drawable_src[j] = gimp_drawable_get (g32[0]);
g_free (g32);
}
}
/* Get pixel region for all input drawables */
for (j = 0; j < num_images; j++)
{
printf ("compose: image is not a gray image\n");
/* Check bytes per pixel */
incr_src[j] = drawable_src[j]->bpp;
if ((incr_src[j] != 1) && (incr_src[j] != 2))
{char msg[256];
sprintf (msg, _("compose: image is not a gray image (bpp=%d)"),
incr_src[j]);
show_message (msg);
return (-1);
}
@ -356,7 +480,7 @@ compose (char *compose_type,
* drawable_src[j]->bpp);
if (src[j] == NULL)
{
printf ("compose: not enough memory\n");
show_message (_("compose: not enough memory"));
return (-1);
}
}
@ -371,7 +495,7 @@ compose (char *compose_type,
if (dst == NULL)
{
for (j = 0; j < num_images; j++) g_free (src[j]);
printf ("compose: not enough memory\n");
show_message (_("compose: not enough memory"));
return (-1);
}
@ -387,7 +511,7 @@ compose (char *compose_type,
width, scan_lines);
/* Do the composition */
compose_dsc[compose_idx].compose_fun (src, width*tile_height, dst);
compose_dsc[compose_idx].compose_fun (src,incr_src,width*tile_height,dst);
/* Set destination pixel region */
gimp_pixel_rgn_set_rect (&pixel_rgn_dst, dst, 0, i, width, scan_lines);
@ -465,6 +589,7 @@ static int cmp_icase (char *s1, char *s2)
static void
compose_rgb (unsigned char **src,
int *incr_src,
int numpix,
unsigned char *dst)
@ -473,7 +598,10 @@ compose_rgb (unsigned char **src,
register unsigned char *blue_src = src[2];
register unsigned char *rgb_dst = dst;
register int count = numpix;
int red_incr = incr_src[0], green_incr = incr_src[1], blue_incr = incr_src[2];
if ((red_incr == 1) && (green_incr == 1) && (blue_incr == 1))
{
while (count-- > 0)
{
*(rgb_dst++) = *(red_src++);
@ -481,10 +609,21 @@ compose_rgb (unsigned char **src,
*(rgb_dst++) = *(blue_src++);
}
}
else
{
while (count-- > 0)
{
*(rgb_dst++) = *red_src; red_src += red_incr;
*(rgb_dst++) = *green_src; green_src += green_incr;
*(rgb_dst++) = *blue_src; blue_src += blue_incr;
}
}
}
static void
compose_rgba (unsigned char **src,
int *incr_src,
int numpix,
unsigned char *dst)
@ -494,7 +633,12 @@ compose_rgba (unsigned char **src,
register unsigned char *alpha_src = src[3];
register unsigned char *rgb_dst = dst;
register int count = numpix;
int red_incr = incr_src[0], green_incr = incr_src[1],
blue_incr = incr_src[2], alpha_incr = incr_src[3];
if ( (red_incr == 1) && (green_incr == 1) && (blue_incr == 1)
&& (alpha_incr == 1))
{
while (count-- > 0)
{
*(rgb_dst++) = *(red_src++);
@ -503,10 +647,22 @@ compose_rgba (unsigned char **src,
*(rgb_dst++) = *(alpha_src++);
}
}
else
{
while (count-- > 0)
{
*(rgb_dst++) = *red_src; red_src += red_incr;
*(rgb_dst++) = *green_src; green_src += green_incr;
*(rgb_dst++) = *blue_src; blue_src += blue_incr;
*(rgb_dst++) = *alpha_src; alpha_src += alpha_incr;
}
}
}
static void
compose_hsv (unsigned char **src,
int *incr_src,
int numpix,
unsigned char *dst)
@ -515,17 +671,22 @@ compose_hsv (unsigned char **src,
register unsigned char *val_src = src[2];
register unsigned char *rgb_dst = dst;
register int count = numpix;
int hue_incr = incr_src[0], sat_incr = incr_src[1], val_incr = incr_src[2];
while (count-- > 0)
{
hsv_to_rgb (hue_src++, sat_src++, val_src++, rgb_dst);
hsv_to_rgb (hue_src, sat_src, val_src, rgb_dst);
rgb_dst += 3;
hue_src += hue_incr;
sat_src += sat_incr;
val_src += val_incr;
}
}
static void
compose_cmy (unsigned char **src,
int *incr_src,
int numpix,
unsigned char *dst)
@ -534,7 +695,11 @@ compose_cmy (unsigned char **src,
register unsigned char *yellow_src = src[2];
register unsigned char *rgb_dst = dst;
register int count = numpix;
int cyan_incr = incr_src[0], magenta_incr = incr_src[1],
yellow_incr = incr_src[2];
if ( (cyan_incr == 1) && (magenta_incr == 1) && (yellow_incr == 1))
{
while (count-- > 0)
{
*(rgb_dst++) = 255 - *(cyan_src++);
@ -542,10 +707,24 @@ compose_cmy (unsigned char **src,
*(rgb_dst++) = 255 - *(yellow_src++);
}
}
else
{
while (count-- > 0)
{
*(rgb_dst++) = 255 - *cyan_src;
*(rgb_dst++) = 255 - *magenta_src;
*(rgb_dst++) = 255 - *yellow_src;
cyan_src += cyan_incr;
magenta_src += magenta_incr;
yellow_src += yellow_incr;
}
}
}
static void
compose_cmyk (unsigned char **src,
int *incr_src,
int numpix,
unsigned char *dst)
@ -556,15 +735,17 @@ compose_cmyk (unsigned char **src,
register unsigned char *rgb_dst = dst;
register int count = numpix;
int cyan, magenta, yellow, black;
int cyan_incr = incr_src[0], magenta_incr = incr_src[1],
yellow_incr = incr_src[2], black_incr = incr_src[3];
while (count-- > 0)
{
black = (int)*(black_src++);
black = (int)*black_src;
if (black)
{
cyan = (int)*(cyan_src++);
magenta = (int)*(magenta_src++);
yellow = (int)*(yellow_src++);
cyan = (int)*cyan_src;
magenta = (int)*magenta_src;
yellow = (int)*yellow_src;
cyan += black; if (cyan > 255) cyan = 255;
magenta += black; if (magenta > 255) magenta = 255;
yellow += black; if (yellow > 255) yellow = 255;
@ -574,17 +755,21 @@ compose_cmyk (unsigned char **src,
}
else
{
*(rgb_dst++) = 255 - *(cyan_src++);
*(rgb_dst++) = 255 - *(magenta_src++);
*(rgb_dst++) = 255 - *(yellow_src++);
*(rgb_dst++) = 255 - *cyan_src;
*(rgb_dst++) = 255 - *magenta_src;
*(rgb_dst++) = 255 - *yellow_src;
}
cyan_src += cyan_incr;
magenta_src += magenta_incr;
yellow_src += yellow_incr;
black_src += black_incr;
}
}
static gint
compose_dialog (char *compose_type,
gint32 image_ID)
gint32 drawable_ID)
{
GtkWidget *dlg;
GtkWidget *button;
@ -598,7 +783,7 @@ compose_dialog (char *compose_type,
GSList *group;
gchar **argv;
gint argc;
int j, compose_idx;
int j, compose_idx, sensitive;
/* Check default compose type */
compose_idx = -1;
@ -609,6 +794,10 @@ compose_dialog (char *compose_type,
}
if (compose_idx < 0) compose_idx = 0;
/* Save original image width/height */
composeint.width = gimp_drawable_width (drawable_ID);
composeint.height = gimp_drawable_height (drawable_ID);
argc = 1;
argv = g_new (gchar *, 1);
argv[0] = g_strdup ("Compose");
@ -618,7 +807,7 @@ compose_dialog (char *compose_type,
dlg = gtk_dialog_new ();
gtk_window_set_title (GTK_WINDOW (dlg), _("Compose"));
gtk_window_position (GTK_WINDOW (dlg), GTK_WIN_POS_MOUSE);
gtk_window_set_position (GTK_WINDOW (dlg), GTK_WIN_POS_MOUSE);
gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
(GtkSignalFunc) compose_close_callback,
NULL);
@ -644,18 +833,18 @@ compose_dialog (char *compose_type,
/* parameter settings */
hbox = gtk_hbox_new (FALSE, 0);
gtk_container_border_width (GTK_CONTAINER (hbox), 0);
gtk_container_set_border_width (GTK_CONTAINER (hbox), 0);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), hbox, TRUE, TRUE, 0);
gtk_widget_show (hbox);
/* The left frame keeps the compose type toggles */
left_frame = gtk_frame_new (_("Compose channels:"));
gtk_frame_set_shadow_type (GTK_FRAME (left_frame), GTK_SHADOW_ETCHED_IN);
gtk_container_border_width (GTK_CONTAINER (left_frame), 10);
gtk_container_set_border_width (GTK_CONTAINER (left_frame), 5);
gtk_box_pack_start (GTK_BOX (hbox), left_frame, TRUE, TRUE, 0);
left_vbox = gtk_vbox_new (FALSE, 5);
gtk_container_border_width (GTK_CONTAINER (left_vbox), 10);
gtk_container_set_border_width (GTK_CONTAINER (left_vbox), 5);
gtk_container_add (GTK_CONTAINER (left_frame), left_vbox);
/* The right frame keeps the selection menues for images. */
@ -665,11 +854,11 @@ compose_dialog (char *compose_type,
right_frame = gtk_frame_new (_("Channel representations:"));
gtk_frame_set_shadow_type (GTK_FRAME (right_frame), GTK_SHADOW_ETCHED_IN);
gtk_container_border_width (GTK_CONTAINER (right_frame), 10);
gtk_container_set_border_width (GTK_CONTAINER (right_frame), 5);
gtk_box_pack_start (GTK_BOX (hbox), right_frame, TRUE, TRUE, 0);
right_vbox = gtk_vbox_new (FALSE, 5);
gtk_container_border_width (GTK_CONTAINER (right_vbox), 10);
gtk_container_set_border_width (GTK_CONTAINER (right_vbox), 5);
gtk_container_add (GTK_CONTAINER (right_frame), right_vbox);
table = gtk_table_new (MAX_COMPOSE_IMAGES, 3, FALSE);
@ -688,13 +877,17 @@ compose_dialog (char *compose_type,
GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (label);
}
/* Set sensitivity of last label */
sensitive = (strcmp (compose_dsc[compose_idx].channel_name[3],
CHNL_NA) != 0);
gtk_widget_set_sensitive (composeint.channel_label[3], sensitive);
/* Menues to select images */
for (j = 0; j < MAX_COMPOSE_IMAGES; j++)
{
composeint.select_ID[j] = image_ID;
image_option_menu = gtk_option_menu_new ();
image_menu = gimp_image_menu_new (check_gray, image_menu_callback,
composeint.select_ID[j] = drawable_ID;
composeint.channel_menu[j] = image_option_menu = gtk_option_menu_new ();
image_menu = gimp_drawable_menu_new (check_gray, image_menu_callback,
&(composeint.select_ID[j]), composeint.select_ID[j]);
gtk_table_attach (GTK_TABLE (table), image_option_menu, 2, 3, j, j+1,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
@ -702,6 +895,7 @@ compose_dialog (char *compose_type,
gtk_widget_show (image_option_menu);
gtk_option_menu_set_menu (GTK_OPTION_MENU (image_option_menu), image_menu);
}
gtk_widget_set_sensitive (composeint.channel_menu[3], sensitive);
/* Compose types */
group = NULL;
@ -816,7 +1010,9 @@ check_gray (gint32 image_id,
gpointer data)
{
return (gimp_image_base_type (image_id) == GRAY);
return ( (gimp_image_base_type (image_id) == GRAY)
&& (gimp_image_width (image_id) == composeint.width)
&& (gimp_image_height (image_id) == composeint.height));
}
@ -864,6 +1060,7 @@ compose_type_toggle_update (GtkWidget *widget,
{
gint *toggle_val;
gint compose_idx, j;
int sensitive;
toggle_val = (gint *) data;
@ -874,6 +1071,12 @@ compose_type_toggle_update (GtkWidget *widget,
for (j = 0; j < MAX_COMPOSE_IMAGES; j++)
gtk_label_set_text (GTK_LABEL (composeint.channel_label[j]),
compose_dsc[compose_idx].channel_name[j]);
/* Set sensitivity of last label */
sensitive = (strcmp (compose_dsc[compose_idx].channel_name[3],
CHNL_NA) != 0);
gtk_widget_set_sensitive (composeint.channel_label[3], sensitive);
gtk_widget_set_sensitive (composeint.channel_menu[3], sensitive);
}
else
*toggle_val = FALSE;

View file

@ -12,6 +12,9 @@ INCLUDES = \
$(GTK_CFLAGS) \
-I$(includedir)
AM_CPPFLAGS = \
-DLOCALEDIR=\""$(localedir)"\"
LDADD = \
$(top_builddir)/libgimp/libgimp.la \
$(GTK_LIBS)

View file

@ -1,7 +1,7 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
* Decompose plug-in (C) 1997 Peter Kirchgessner
* e-mail: pkirchg@aol.com, WWW: http://members.aol.com/pkirchg
* e-mail: peter@kirchgessner.net, WWW: http://www.kirchgessner.net
*
* 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
@ -24,8 +24,15 @@
/* Event history:
* V 1.00, PK, 29-Jul-97, Creation
* V 1.01, PK, 19-Mar-99, Update for GIMP V1.1.3
* Prepare for localization
* Use g_message() in interactive mode
*/
static char ident[] = "@(#) GIMP Decompose plug-in v1.00 29-Jul-97";
static char ident[] = "@(#) GIMP Decompose plug-in v1.01 19-Mar-99";
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdio.h>
#include <stdlib.h>
@ -33,6 +40,7 @@ static char ident[] = "@(#) GIMP Decompose plug-in v1.00 29-Jul-97";
#include <ctype.h>
#include "gtk/gtk.h"
#include "libgimp/gimp.h"
#include "libgimp/stdplugins-intl.h"
/* Declare local functions
*/
@ -52,6 +60,7 @@ static gint32 create_new_image (char *filename, guint width, guint height,
GImageType type, gint32 *layer_ID, GDrawable **drawable,
GPixelRgn *pixel_rgn);
static void show_message (const char *msg);
static int cmp_icase (char *s1, char *s2);
static void rgb_to_hsv (unsigned char *r, unsigned char *g, unsigned char *b,
unsigned char *h, unsigned char *s, unsigned char *v);
@ -117,23 +126,26 @@ typedef struct {
} EXTRACT;
static EXTRACT extract[] = {
{ "RGB", 1, 3, { "red", "green", "blue" }, extract_rgb },
{ "Red", 0, 1, { "red" }, extract_red },
{ "Green", 0, 1, { "green" }, extract_green },
{ "Blue", 0, 1, { "blue" }, extract_blue },
{ "HSV", 1, 3, { "hue", "saturation", "value", }, extract_hsv },
{ "Hue", 0, 1, { "hue" }, extract_hue },
{ "Saturation",0,1, { "saturation", }, extract_sat },
{ "Value", 0, 1, { "value", }, extract_val },
{ "CMY", 1, 3, { "cyan", "magenta", "yellow" }, extract_cmy },
{ "Cyan", 0, 1, { "cyan", }, extract_cyan },
{ "Magenta", 0, 1, { "magenta", }, extract_magenta },
{ "Yellow", 0, 1, { "yellow", }, extract_yellow },
{ "CMYK", 1, 4, { "cyan_k", "magenta_k", "yellow_k", "black" }, extract_cmyk },
{ "Cyan_K", 0, 1, { "cyan_k", }, extract_cyank },
{ "Magenta_K", 0,1, { "magenta_k", }, extract_magentak },
{ "Yellow_K", 0, 1, { "yellow_k", }, extract_yellowk },
{ "Alpha", 1, 1, { "alpha" }, extract_alpha }
{ N_("RGB"), 1, 3, { N_("red"), N_("green"), N_("blue") }, extract_rgb },
{ N_("Red"), 0, 1, { N_("red") }, extract_red },
{ N_("Green"), 0, 1, { N_("green") }, extract_green },
{ N_("Blue"), 0, 1, { N_("blue") }, extract_blue },
{ N_("HSV"), 1, 3, { N_("hue"), N_("saturation"), N_("value") },
extract_hsv },
{ N_("Hue"), 0, 1, { N_("hue") }, extract_hue },
{ N_("Saturation"),0,1, { N_("saturation") }, extract_sat },
{ N_("Value"), 0, 1, { N_("value") }, extract_val },
{ N_("CMY"), 1, 3, { N_("cyan"), N_("magenta"), N_("yellow") },
extract_cmy },
{ N_("Cyan"), 0, 1, { N_("cyan") }, extract_cyan },
{ N_("Magenta"), 0, 1, { N_("magenta") }, extract_magenta },
{ N_("Yellow"), 0, 1, { N_("yellow") }, extract_yellow },
{ N_("CMYK"), 1, 4, { N_("cyan_k"), N_("magenta_k"), N_("yellow_k"),
N_("black") }, extract_cmyk },
{ N_("Cyan_K"), 0, 1, { N_("cyan_k") }, extract_cyank },
{ N_("Magenta_K"), 0,1, { N_("magenta_k") }, extract_magentak },
{ N_("Yellow_K"), 0, 1, { N_("yellow_k") }, extract_yellowk },
{ N_("Alpha"), 1, 1, { N_("alpha") }, extract_alpha }
};
/* Number of types of extractions */
@ -188,27 +200,41 @@ query ()
static GParamDef return_vals[] =
{
{ PARAM_IMAGE, "new_image", "Output gray image" },
{ PARAM_IMAGE, "new_image", "Output gray image (N/A for single channel extract)" },
{ PARAM_IMAGE, "new_image", "Output gray image (N/A for single channel extract)" },
{ PARAM_IMAGE, "new_image", "Output gray image (N/A for single channel extract)" },
{ PARAM_IMAGE, "new_image",
"Output gray image (N/A for single channel extract)" },
{ PARAM_IMAGE, "new_image",
"Output gray image (N/A for single channel extract)" },
{ PARAM_IMAGE, "new_image",
"Output gray image (N/A for single channel extract)" },
};
static int nargs = sizeof (args) / sizeof (args[0]);
static int nreturn_vals = sizeof (return_vals) / sizeof (return_vals[0]);
INIT_I18N ();
gimp_install_procedure ("plug_in_decompose",
"Decompose an image into different types of channels",
"This function creates new gray images with\
different channel information in each of them",
_("Decompose an image into different types of channels"),
_("This function creates new gray images with\
different channel information in each of them"),
"Peter Kirchgessner",
"Peter Kirchgessner (pkirchg@aol.com)",
"Peter Kirchgessner (peter@kirchgessner.net)",
"1997",
"<Image>/Image/Channel Ops/Decompose",
_("<Image>/Image/Channel Ops/Decompose"),
"RGB*",
PROC_PLUG_IN,
nargs, nreturn_vals,
args, return_vals);
}
static void show_message (const char *message)
{
if (run_mode == RUN_INTERACTIVE)
g_message (message);
else
printf ("%s\n", message);
}
static void
run (char *name,
int nparams,
@ -223,6 +249,8 @@ run (char *name,
gint32 image_ID_extract[MAX_EXTRACT_IMAGES];
gint j;
INIT_I18N ();
run_mode = param[0].data.d_int32;
*nreturn_vals = MAX_EXTRACT_IMAGES+1;
@ -272,13 +300,13 @@ run (char *name,
drawable_type = gimp_drawable_type (param[2].data.d_drawable);
if ((drawable_type != RGB_IMAGE) && (drawable_type != RGBA_IMAGE))
{
printf ("plug_in_decompose: Can only work on RGB*_IMAGE\n");
show_message (_("plug_in_decompose: Can only work on RGB*_IMAGE"));
status = STATUS_CALLING_ERROR;
}
if (status == STATUS_SUCCESS)
{
if (run_mode != RUN_NONINTERACTIVE)
gimp_progress_init ("Decomposing...");
gimp_progress_init (_("Decomposing..."));
num_images = decompose (param[1].data.d_image, param[2].data.d_drawable,
decovals.extract_type, image_ID_extract);
@ -343,13 +371,13 @@ decompose (gint32 image_ID,
drawable_src = gimp_drawable_get (drawable_ID);
if (drawable_src->bpp < 3)
{
printf ("decompose: not an RGB image\n");
show_message (_("decompose: not an RGB image"));
return (-1);
}
if ( (extract[extract_idx].extract_fun == extract_alpha)
&& (!gimp_drawable_has_alpha (drawable_ID)))
{
printf ("decompose: No alpha channel available\n");
show_message (_("decompose: No alpha channel available"));
return (-1);
}
@ -378,7 +406,7 @@ decompose (gint32 image_ID,
}
if (dst[num_images-1] == NULL)
{
printf ("decompose: out of memory\n");
show_message (_("decompose: out of memory"));
for (j = 0; j < num_images; j++)
{
if (dst[j] != NULL) g_free (dst[j]);
@ -441,7 +469,7 @@ create_new_image (char *filename,
image_ID = gimp_image_new (width, height, type);
gimp_image_set_filename (image_ID, filename);
*layer_ID = gimp_layer_new (image_ID, "Background", width, height,
*layer_ID = gimp_layer_new (image_ID, _("Background"), width, height,
gdtype, 100, NORMAL_MODE);
gimp_image_add_layer (image_ID, *layer_ID, 0);
@ -870,44 +898,46 @@ decompose_dialog (void)
argc = 1;
argv = g_new (gchar *, 1);
argv[0] = g_strdup ("Decompose");
argv[0] = g_strdup (_("Decompose"));
gtk_init (&argc, &argv);
gtk_rc_parse (gimp_gtkrc ());
dlg = gtk_dialog_new ();
gtk_window_set_title (GTK_WINDOW (dlg), "Decompose");
gtk_window_position (GTK_WINDOW (dlg), GTK_WIN_POS_MOUSE);
gtk_window_set_title (GTK_WINDOW (dlg), _("Decompose"));
gtk_window_set_position (GTK_WINDOW (dlg), GTK_WIN_POS_MOUSE);
gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
(GtkSignalFunc) decompose_close_callback,
NULL);
/* Action area */
button = gtk_button_new_with_label ("OK");
button = gtk_button_new_with_label (_("OK"));
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
(GtkSignalFunc) decompose_ok_callback,
dlg);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->action_area), button, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->action_area), button,
TRUE, TRUE, 0);
gtk_widget_grab_default (button);
gtk_widget_show (button);
button = gtk_button_new_with_label ("Cancel");
button = gtk_button_new_with_label (_("Cancel"));
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
(GtkSignalFunc) gtk_widget_destroy,
GTK_OBJECT (dlg));
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->action_area), button, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->action_area), button,
TRUE, TRUE, 0);
gtk_widget_show (button);
/* parameter settings */
frame = gtk_frame_new ("Extract channels:");
frame = gtk_frame_new (_("Extract channels:"));
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN);
gtk_container_border_width (GTK_CONTAINER (frame), 10);
gtk_container_set_border_width (GTK_CONTAINER (frame), 5);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), frame, TRUE, TRUE, 0);
vbox = gtk_vbox_new (FALSE, 5);
gtk_container_border_width (GTK_CONTAINER (vbox), 10);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
gtk_container_add (GTK_CONTAINER (frame), vbox);
group = NULL;

View file

@ -6,7 +6,7 @@
# but which still want to provide support for the GNU gettext functionality.
# Please note that the actual code is *not* freely available.
PACKAGE = @PACKAGE@
PACKAGE = gimp-std-plugins
VERSION = @VERSION@
SHELL = /bin/sh
@ -22,7 +22,7 @@ datadir = $(prefix)/@DATADIRNAME@
localedir = $(datadir)/locale
gnulocaledir = $(prefix)/share/locale
gettextsrcdir = $(prefix)/share/gettext/po
subdir = po
subdir = po-plug-ins
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@

View file

@ -19,6 +19,7 @@ plug-ins/colorify/colorify.c
plug-ins/compose/compose.c
plug-ins/convmatrix/convmatrix.c
plug-ins/cubism/cubism.c
plug-ins/decompose/decompose.c
plug-ins/depthmerge/depthmerge.c
plug-ins/destripe/destripe.c
plug-ins/gif/gif.c