plug-ins/print/* updated to the current CVS version from sourceforge

2000-08-15  Michael Natterer  <mitch@gimp.org>

	* plug-ins/print/*
	* po-plug-ins/POTFILES.in: updated to the current CVS version
	from sourceforge (something after 4.0a1).
This commit is contained in:
Michael Natterer 2000-08-15 00:43:48 +00:00 committed by Michael Natterer
parent 0bb72aa6c8
commit 3d5b39f71c
19 changed files with 27534 additions and 4879 deletions

View File

@ -1,3 +1,9 @@
2000-08-15 Michael Natterer <mitch@gimp.org>
* plug-ins/print/*
* po-plug-ins/POTFILES.in: updated to the current CVS version
from sourceforge (something after 4.0a1).
2000-08-14 Daniel Egger <egger@suse.de>
* app/menus.c: Added missing tearoff_delete_cb prototype.

View File

@ -7,15 +7,22 @@ EXTRA_DIST = print-printers.c
libexec_PROGRAMS = print
print_SOURCES = \
print_gimp.h \
print-canon.c \
print-dither.c \
print-escp2.c \
print-pcl.c \
print-ps.c \
print-util.c \
print.c \
print-weave.c \
print.h \
quickmatrix257.h \
ran.367.179.h \
\
print-image-gimp.c \
print.c \
gimp_color_window.c \
gimp_main_window.c
gimp_main_window.c \
print_gimp.h
INCLUDES = \
-I$(top_srcdir) \
@ -27,7 +34,9 @@ AM_CPPFLAGS = \
@LP_DEF@ \
@LPSTAT_DEF@ \
@LPR_DEF@ \
@LPC_DEF@
@LPC_DEF@ \
-DVERSION=\"4.0a1\" \
-DRELEASE_DATE=\"11\ Aug\ 2000\"
LDADD = \
$(top_builddir)/libgimp/libgimpui.la \

View File

@ -21,33 +21,33 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include "print_gimp.h"
#ifndef GIMP_1_0
#include <libgimp/gimpui.h>
#include "libgimp/stdplugins-intl.h"
extern vars_t vars;
extern gint plist_count; /* Number of system printers */
extern gint plist_current; /* Current system printer */
extern plist_t plist[MAX_PLIST]; /* System printers */
extern plist_t *plist; /* System printers */
GtkWidget *gimp_color_adjust_dialog;
GtkObject *brightness_adjustment;
GtkObject *saturation_adjustment;
GtkObject *density_adjustment;
GtkObject *contrast_adjustment;
GtkObject *red_adjustment;
GtkObject *green_adjustment;
GtkObject *blue_adjustment;
GtkObject *gamma_adjustment;
static GtkObject *brightness_adjustment;
static GtkObject *saturation_adjustment;
static GtkObject *density_adjustment;
static GtkObject *contrast_adjustment;
static GtkObject *red_adjustment;
static GtkObject *green_adjustment;
static GtkObject *blue_adjustment;
static GtkObject *gamma_adjustment;
static GtkWidget *dither_algo_button = NULL;
static GtkWidget *dither_algo_menu = NULL;
static void gimp_brightness_update (GtkAdjustment *adjustment);
static void gimp_saturation_update (GtkAdjustment *adjustment);
@ -58,6 +58,10 @@ static void gimp_green_update (GtkAdjustment *adjustment);
static void gimp_blue_update (GtkAdjustment *adjustment);
static void gimp_gamma_update (GtkAdjustment *adjustment);
static void gimp_dither_algo_callback (GtkWidget *widget,
gpointer data);
void gimp_build_dither_menu (void);
/*
* gimp_create_color_adjust_window (void)
@ -74,7 +78,7 @@ gimp_create_color_adjust_window (void)
gimp_color_adjust_dialog = dialog =
gimp_dialog_new (_("Print Color Adjust"), "print",
gimp_standard_help_func, "filters/print.html",
gimp_plugin_help_func, "filters/print.html",
GTK_WIN_POS_MOUSE,
FALSE, TRUE, FALSE,
@ -83,10 +87,13 @@ gimp_create_color_adjust_window (void)
NULL);
table = gtk_table_new (8, 3, FALSE);
table = gtk_table_new (9, 3, FALSE);
gtk_container_set_border_width (GTK_CONTAINER (table), 6);
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
gtk_table_set_row_spacings (GTK_TABLE (table), 4);
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
gtk_table_set_row_spacing (GTK_TABLE (table), 1, 6);
gtk_table_set_row_spacing (GTK_TABLE (table), 4, 6);
gtk_table_set_row_spacing (GTK_TABLE (table), 7, 6);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), table,
FALSE, FALSE, 0);
gtk_widget_show (table);
@ -168,7 +175,7 @@ gimp_create_color_adjust_window (void)
saturation_adjustment =
gimp_scale_entry_new (GTK_TABLE (table), 0, 5,
_("Saturation:"), 200, 0,
vars.saturation, 0.001, 10.0, 0.001, 0.01, 3,
vars.saturation, 0, 10.0, 0.001, 0.01, 3,
TRUE, 0, 0,
NULL, NULL);
gtk_signal_connect (GTK_OBJECT (saturation_adjustment), "value_changed",
@ -202,6 +209,16 @@ gimp_create_color_adjust_window (void)
gtk_signal_connect (GTK_OBJECT (gamma_adjustment), "value_changed",
GTK_SIGNAL_FUNC (gimp_gamma_update),
NULL);
/*
* Dither algorithm option menu...
*/
dither_algo_button = gtk_option_menu_new ();
gimp_table_attach_aligned (GTK_TABLE (table), 0, 8,
_("Dither Algorithm:"), 1.0, 0.5,
dither_algo_button, 1, TRUE);
gimp_build_dither_menu ();
}
static void
@ -284,4 +301,106 @@ gimp_gamma_update (GtkAdjustment *adjustment)
}
}
void
gimp_do_color_updates(void)
{
gtk_adjustment_set_value (GTK_ADJUSTMENT (brightness_adjustment),
plist[plist_current].v.brightness);
gtk_adjustment_set_value (GTK_ADJUSTMENT (gamma_adjustment),
plist[plist_current].v.gamma);
gtk_adjustment_set_value (GTK_ADJUSTMENT (contrast_adjustment),
plist[plist_current].v.contrast);
gtk_adjustment_set_value (GTK_ADJUSTMENT (red_adjustment),
plist[plist_current].v.red);
gtk_adjustment_set_value (GTK_ADJUSTMENT (green_adjustment),
plist[plist_current].v.green);
gtk_adjustment_set_value (GTK_ADJUSTMENT (blue_adjustment),
plist[plist_current].v.blue);
gtk_adjustment_set_value (GTK_ADJUSTMENT (saturation_adjustment),
plist[plist_current].v.saturation);
gtk_adjustment_set_value (GTK_ADJUSTMENT (density_adjustment),
plist[plist_current].v.density);
}
void
gimp_build_dither_menu (void)
{
GtkWidget *item;
GtkWidget *item0 = NULL;
gint i;
if (dither_algo_menu != NULL)
{
gtk_widget_destroy (dither_algo_menu);
dither_algo_menu = NULL;
}
dither_algo_menu = gtk_menu_new ();
if (num_dither_algos == 0)
{
item = gtk_menu_item_new_with_label (_("Standard"));
gtk_menu_append (GTK_MENU (dither_algo_menu), item);
gtk_widget_show (item);
gtk_option_menu_set_menu (GTK_OPTION_MENU (dither_algo_button),
dither_algo_menu);
gtk_widget_set_sensitive (dither_algo_button, FALSE);
return;
}
else
{
gtk_widget_set_sensitive (dither_algo_button, TRUE);
}
for (i = 0; i < num_dither_algos; i++)
{
item = gtk_menu_item_new_with_label (gettext (dither_algo_names[i]));
if (i == 0)
item0 = item;
gtk_menu_append (GTK_MENU (dither_algo_menu), item);
gtk_signal_connect (GTK_OBJECT (item), "activate",
GTK_SIGNAL_FUNC (gimp_dither_algo_callback),
(gpointer) i);
gtk_widget_show (item);
}
gtk_option_menu_set_menu (GTK_OPTION_MENU (dither_algo_button),
dither_algo_menu);
for (i = 0; i < num_dither_algos; i++)
{
#ifdef DEBUG
g_print ("item[%d] = \'%s\'\n", i, dither_algo_names[i]);
#endif /* DEBUG */
if (strcmp (dither_algo_names[i], plist[plist_current].v.dither_algorithm) == 0)
{
gtk_option_menu_set_history (GTK_OPTION_MENU (dither_algo_button), i);
break;
}
}
if (i == num_dither_algos)
{
gtk_option_menu_set_history (GTK_OPTION_MENU (dither_algo_button), 0);
gtk_signal_emit_by_name (GTK_OBJECT (item0), "activate");
}
}
static void
gimp_dither_algo_callback (GtkWidget *widget,
gpointer data)
{
strcpy(vars.dither_algorithm, dither_algo_names[(gint) data]);
strcpy(plist[plist_current].v.dither_algorithm,
dither_algo_names[(gint) data]);
}
#endif /* ! GIMP_1_0 */

File diff suppressed because it is too large Load Diff

1512
plug-ins/print/print-canon.c Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,301 @@
/*
* "$Id$"
*
* Print plug-in for the GIMP.
*
* Copyright 1997-2000 Michael Sweet (mike@easysw.com) and
* Robert Krawitz (rlk@alum.mit.edu)
* Copyright 2000 Charles Briscoe-Smith <cpbs@debian.org>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* Contents:
*
* See print.h for prototypes
*
* Revision History:
*
* See ChangeLog
*/
#include "config.h"
#include "print_gimp.h"
#include "libgimp/stdplugins-intl.h"
/*
* "Image" ADT
*
* This file defines an abstract data type called "Image". An Image wraps
* a Gimp drawable (or some other application-level image representation)
* for presentation to the low-level printer drivers (which do CMYK
* separation, dithering and weaving). The Image ADT has the ability
* to perform any combination of flips and rotations on the image,
* and then deliver individual rows to the driver code.
*
* Stuff which might be useful to do in this layer:
*
* - Scaling, optionally with interpolation/filtering.
*
* - Colour-adjustment.
*
* - Multiple-image composition.
*
* Also useful might be to break off a thin application-dependent
* sublayer leaving this layer (which does the interesting stuff)
* application-independent.
*/
/* Concrete type to represent image */
typedef struct
{
GDrawable *drawable;
GPixelRgn rgn;
/*
* Transformations we can impose on the image. The transformations
* are considered to be performed in the order given here.
*/
/* 1: Transpose the x and y axes (flip image over its leading diagonal) */
int columns; /* Set if returning columns instead of rows. */
/* 2: Translate (ox,oy) to the origin */
int ox, oy; /* Origin of image */
/* 3: Flip vertically about the x axis */
int increment; /* +1 or -1 for offset of row n+1 from row n. */
/* 4: Crop to width w, height h */
int w, h; /* Width and height of output image */
/* 5: Flip horizontally about the vertical centre-line of the image */
int mirror; /* Set if mirroring rows end-for-end. */
} Gimp_Image_t;
Image
Image_GDrawable_new(GDrawable *drawable)
{
Gimp_Image_t *i = malloc(sizeof(Gimp_Image_t));
i->drawable = drawable;
gimp_pixel_rgn_init(&(i->rgn), drawable, 0, 0,
drawable->width, drawable->height, FALSE, FALSE);
Image_reset((Image) i);
return i;
}
void
Image_init(Image image)
{
/* Nothing to do. */
}
void
Image_reset(Image image)
{
Gimp_Image_t *i = (Gimp_Image_t *) image;
i->columns = FALSE;
i->ox = 0;
i->oy = 0;
i->increment = 1;
i->w = i->drawable->width;
i->h = i->drawable->height;
i->mirror = FALSE;
}
void
Image_transpose(Image image)
{
Gimp_Image_t *i = (Gimp_Image_t *) image;
int tmp;
if (i->mirror) i->ox += i->w - 1;
i->columns = !i->columns;
tmp = i->ox;
i->ox = i->oy;
i->oy = tmp;
tmp = i->mirror;
i->mirror = i->increment < 0;
i->increment = tmp ? -1 : 1;
tmp = i->w;
i->w = i->h;
i->h = tmp;
if (i->mirror) i->ox -= i->w - 1;
}
void
Image_hflip(Image image)
{
Gimp_Image_t *i = (Gimp_Image_t *) image;
i->mirror = !i->mirror;
}
void
Image_vflip(Image image)
{
Gimp_Image_t *i = (Gimp_Image_t *) image;
i->oy += (i->h-1) * i->increment;
i->increment = -i->increment;
}
/*
* Image_crop:
*
* Crop the given number of pixels off the LEFT, TOP, RIGHT and BOTTOM
* of the image.
*/
void
Image_crop(Image image, int left, int top, int right, int bottom)
{
Gimp_Image_t *i = (Gimp_Image_t *) image;
int xmax = (i->columns ? i->drawable->height : i->drawable->width) - 1;
int ymax = (i->columns ? i->drawable->width : i->drawable->height) - 1;
int nx = i->ox + i->mirror ? right : left;
int ny = i->oy + top * (i->increment);
int nw = i->w - left - right;
int nh = i->h - top - bottom;
int wmax, hmax;
if (nx < 0) nx = 0;
else if (nx > xmax) nx = xmax;
if (ny < 0) ny = 0;
else if (ny > ymax) ny = ymax;
wmax = xmax - nx + 1;
hmax = i->increment ? ny + 1 : ymax - ny + 1;
if (nw < 1) nw = 1;
else if (nw > wmax) nw = wmax;
if (nh < 1) nh = 1;
else if (nh > hmax) nh = hmax;
i->ox = nx;
i->oy = ny;
i->w = nw;
i->h = nh;
}
void
Image_rotate_ccw(Image image)
{
Image_transpose(image);
Image_vflip(image);
}
void
Image_rotate_cw(Image image)
{
Image_transpose(image);
Image_hflip(image);
}
void
Image_rotate_180(Image image)
{
Image_vflip(image);
Image_hflip(image);
}
int
Image_bpp(Image image)
{
Gimp_Image_t *i = (Gimp_Image_t *) image;
return i->drawable->bpp;
}
int
Image_width(Image image)
{
Gimp_Image_t *i = (Gimp_Image_t *) image;
return i->w;
}
int
Image_height(Image image)
{
Gimp_Image_t *i = (Gimp_Image_t *) image;
return i->h;
}
void
Image_get_row(Image image, unsigned char *data, int row)
{
Gimp_Image_t *i = (Gimp_Image_t *) image;
if (i->columns)
gimp_pixel_rgn_get_col(&(i->rgn), data,
i->oy + row * i->increment, i->ox, i->w);
else
gimp_pixel_rgn_get_row(&(i->rgn), data,
i->ox, i->oy + row * i->increment, i->w);
if (i->mirror) {
/* Flip row -- probably inefficiently */
int f, l, b = i->drawable->bpp;
for (f = 0, l = i->w - 1; f < l; f++, l--) {
int c;
unsigned char tmp;
for (c = 0; c < b; c++) {
tmp = data[f*b+c];
data[f*b+c] = data[l*b+c];
data[l*b+c] = tmp;
}
}
}
}
void
Image_progress_init(Image image)
{
gimp_progress_init(_("Printing..."));
}
void
Image_note_progress(Image image, double current, double total)
{
gimp_progress_update(current / total);
}
void
Image_progress_conclude(Image image)
{
gimp_progress_update(1);
}
const char *
Image_get_appname(Image image)
{
static char pluginname[] = PLUG_IN_NAME " plug-in V" PLUG_IN_VERSION
" for GIMP";
return pluginname;
}
/*
* End of "$Id$".
*/

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -37,10 +37,12 @@
#include "print.h"
#include <time.h>
#include <glib.h>
#include <string.h>
#include <limits.h>
/*#define DEBUG*/
/*
* Local variables...
*/
@ -55,7 +57,7 @@ static char *ps_ppd_file = NULL;
static void ps_hex(FILE *, unsigned short *, int);
static void ps_ascii85(FILE *, unsigned short *, int, int);
static char *ppd_find(char *, char *, char *, int *);
static char *ppd_find(const char *, const char *, const char *, int *);
/*
@ -63,7 +65,7 @@ static char *ppd_find(char *, char *, char *, int *);
*/
char ** /* O - Parameter values */
ps_parameters(int model, /* I - Printer model */
ps_parameters(const printer_t *printer, /* I - Printer model */
char *ppd_file, /* I - PPD file (not used) */
char *name, /* I - Name of parameter */
int *count) /* O - Number of values */
@ -73,16 +75,6 @@ ps_parameters(int model, /* I - Printer model */
lname[255],
loption[255];
char **valptrs;
static char *media_sizes[] =
{
("Letter"),
("Legal"),
("A4"),
("Tabloid"),
("A3"),
("12x18")
};
if (count == NULL)
return (NULL);
@ -109,16 +101,18 @@ ps_parameters(int model, /* I - Printer model */
{
if (strcmp(name, "PageSize") == 0)
{
*count = 6;
valptrs = malloc(*count * sizeof(char *));
for (i = 0; i < *count; i ++)
const papersize_t *papersizes = get_papersizes();
valptrs = malloc(sizeof(char *) * known_papersizes());
*count = 0;
for (i = 0; i < known_papersizes(); i++)
{
/* strdup doesn't appear to be POSIX... */
valptrs[i] = malloc(strlen(media_sizes[i]) + 1);
strcpy(valptrs[i], media_sizes[i]);
if (strlen(papersizes[i].name) > 0)
{
valptrs[*count] = malloc(strlen(papersizes[i].name) + 1);
strcpy(valptrs[*count], papersizes[i].name);
(*count)++;
}
}
return (valptrs);
}
else
@ -138,7 +132,7 @@ ps_parameters(int model, /* I - Printer model */
if (sscanf(line, "*%s %[^/:]", lname, loption) != 2)
continue;
if (g_strcasecmp(lname, name) == 0)
if (strcasecmp(lname, name) == 0)
{
valptrs[(*count)] = malloc(strlen(loption) + 1);
strcpy(valptrs[(*count)], loption);
@ -161,9 +155,8 @@ ps_parameters(int model, /* I - Printer model */
*/
void
ps_media_size(int model, /* I - Printer model */
char *ppd_file, /* I - PPD file (not used) */
char *media_size, /* I - Media size */
ps_media_size(const printer_t *printer, /* I - Printer model */
const vars_t *v, /* I */
int *width, /* O - Width in points */
int *length) /* O - Length in points */
{
@ -175,10 +168,12 @@ ps_media_size(int model, /* I - Printer model */
media_size, width, length);
#endif /* DEBUG */
if ((dimensions = ppd_find(ppd_file, "PaperDimension", media_size, NULL)) != NULL)
if ((dimensions = ppd_find(v->ppd_file, "PaperDimension", v->media_size,
NULL))
!= NULL)
sscanf(dimensions, "%d%d", width, length);
else
default_media_size(model, ppd_file, media_size, width, length);
default_media_size(printer, v, width, length);
}
@ -187,9 +182,8 @@ ps_media_size(int model, /* I - Printer model */
*/
void
ps_imageable_area(int model, /* I - Printer model */
char *ppd_file, /* I - PPD file (not used) */
char *media_size, /* I - Media size */
ps_imageable_area(const printer_t *printer, /* I - Printer model */
const vars_t *v, /* I */
int *left, /* O - Left position in points */
int *right, /* O - Right position in points */
int *bottom, /* O - Bottom position in points */
@ -202,7 +196,8 @@ ps_imageable_area(int model, /* I - Printer model */
ftop;
if ((area = ppd_find(ppd_file, "ImageableArea", media_size, NULL)) != NULL)
if ((area = ppd_find(v->ppd_file, "ImageableArea", v->media_size, NULL))
!= NULL)
{
#ifdef DEBUG
printf("area = \'%s\'\n", area);
@ -219,7 +214,7 @@ ps_imageable_area(int model, /* I - Printer model */
}
else
{
default_media_size(model, ppd_file, media_size, right, top);
default_media_size(printer, v, right, top);
*left = 18;
*right -= 18;
*top -= 36;
@ -227,20 +222,35 @@ ps_imageable_area(int model, /* I - Printer model */
}
}
void
ps_limit(const printer_t *printer, /* I - Printer model */
const vars_t *v, /* I */
int *width, /* O - Left position in points */
int *length) /* O - Top position in points */
{
*width = INT_MAX;
*length = INT_MAX;
}
const char *
ps_default_resolution(const printer_t *printer)
{
return "default";
}
/*
* 'ps_print()' - Print an image to a PostScript printer.
*/
void
ps_print(int model, /* I - Model (Level 1 or 2) */
ps_print(const printer_t *printer, /* I - Model (Level 1 or 2) */
int copies, /* I - Number of copies */
FILE *prn, /* I - File to print to */
Image image, /* I - Image to print */
unsigned char *cmap, /* I - Colormap (for indexed images) */
lut_t *lut, /* I - Brightness lookup table */
vars_t *v)
const vars_t *v)
{
unsigned char *cmap = v->cmap;
int model = printer->model;
char *ppd_file = v->ppd_file;
char *resolution = v->resolution;
char *media_size = v->media_size;
@ -252,7 +262,7 @@ ps_print(int model, /* I - Model (Level 1 or 2) */
int top = v->top;
int left = v->left;
int i, j; /* Looping vars */
int x, y; /* Looping vars */
int y; /* Looping vars */
unsigned char *in; /* Input pixels from image */
unsigned short *out; /* Output pixels for printer */
int page_left, /* Left margin of page */
@ -265,10 +275,7 @@ ps_print(int model, /* I - Model (Level 1 or 2) */
out_height, /* Height of image on page */
out_bpp, /* Output bytes per pixel */
out_length, /* Output length (Level 2 output) */
out_offset, /* Output offset (Level 2 output) */
temp_width, /* Temporary width of image on page */
temp_height, /* Temporary height of image on page */
landscape; /* True if we rotate the output 90 degrees */
out_offset; /* Output offset (Level 2 output) */
time_t curtime; /* Current time of day */
convert_t colorfunc; /* Color conversion function... */
char *command; /* PostScript command */
@ -282,8 +289,9 @@ ps_print(int model, /* I - Model (Level 1 or 2) */
int image_height,
image_width,
image_bpp;
vars_t nv;
memcpy(&nv, v, sizeof(vars_t));
/*
* Setup a read-only pixel region for the entire image...
*/
@ -297,141 +305,28 @@ ps_print(int model, /* I - Model (Level 1 or 2) */
* Choose the correct color conversion function...
*/
if (image_bpp < 3 && cmap == NULL)
output_type = OUTPUT_GRAY; /* Force grayscale output */
if (image_bpp < 3 && cmap == NULL && output_type == OUTPUT_COLOR)
output_type = OUTPUT_GRAY_COLOR; /* Force grayscale output */
if (output_type == OUTPUT_COLOR)
{
out_bpp = 3;
if (image_bpp >= 3)
colorfunc = rgb_to_rgb;
else
colorfunc = indexed_to_rgb;
}
else
{
out_bpp = 1;
if (image_bpp >= 3)
colorfunc = rgb_to_gray;
else if (cmap == NULL)
colorfunc = gray_to_gray;
else
colorfunc = indexed_to_gray;
}
colorfunc = choose_colorfunc(output_type, image_bpp, cmap, &out_bpp, &nv);
/*
* Compute the output size...
*/
landscape = 0;
ps_imageable_area(model, ppd_file, media_size, &page_left, &page_right,
ps_imageable_area(printer, &nv, &page_left, &page_right,
&page_bottom, &page_top);
page_width = page_right - page_left;
page_height = page_top - page_bottom;
#ifdef DEBUG
printf("page_width = %d, page_height = %d\n", page_width, page_height);
printf("image_width = %d, image_height = %d\n", image_width, image_height);
printf("scaling = %.1f\n", scaling);
#endif /* DEBUG */
compute_page_parameters(page_right, page_left, page_top, page_bottom,
scaling, image_width, image_height, image,
&orientation, &page_width, &page_height,
&out_width, &out_height, &left, &top);
/*
* Portrait width/height...
* Recompute the image height and width. If the image has been
* rotated, these will change from previously.
*/
if (scaling < 0.0)
{
/*
* Scale to pixels per inch...
*/
out_width = image_width * -72.0 / scaling;
out_height = image_height * -72.0 / scaling;
}
else
{
/*
* Scale by percent...
*/
out_width = page_width * scaling / 100.0;
out_height = out_width * image_height / image_width;
if (out_height > page_height)
{
out_height = page_height * scaling / 100.0;
out_width = out_height * image_width / image_height;
}
}
/*
* Landscape width/height...
*/
if (scaling < 0.0)
{
/*
* Scale to pixels per inch...
*/
temp_width = image_height * -72.0 / scaling;
temp_height = image_width * -72.0 / scaling;
}
else
{
/*
* Scale by percent...
*/
temp_width = page_width * scaling / 100.0;
temp_height = temp_width * image_width / image_height;
if (temp_height > page_height)
{
temp_height = page_height;
temp_width = temp_height * image_height / image_width;
}
}
/*
* See which orientation has the greatest area (or if we need to rotate the
* image to fit it on the page...)
*/
if (orientation == ORIENT_AUTO)
{
if (scaling < 0.0)
{
if ((out_width > page_width && out_height < page_width) ||
(out_height > page_height && out_width < page_height))
orientation = ORIENT_LANDSCAPE;
else
orientation = ORIENT_PORTRAIT;
}
else
{
if ((temp_width * temp_height) > (out_width * out_height))
orientation = ORIENT_LANDSCAPE;
else
orientation = ORIENT_PORTRAIT;
}
}
if (orientation == ORIENT_LANDSCAPE)
{
out_width = temp_width;
out_height = temp_height;
landscape = 1;
/*
* Swap left/top offsets...
*/
x = top;
top = left;
left = x;
}
image_height = Image_height(image);
image_width = Image_width(image);
/*
* Let the user know what we're doing...
@ -447,6 +342,8 @@ ps_print(int model, /* I - Model (Level 1 or 2) */
if (left < 0)
left = (page_width - out_width) / 2 + page_left;
else
left += page_left;
if (top < 0)
top = (page_height + out_height) / 2 + page_bottom;
@ -464,9 +361,9 @@ ps_print(int model, /* I - Model (Level 1 or 2) */
_fsetmode(prn, "t");
#endif
fputs("%!PS-Adobe-3.0\n", prn);
fprintf(prn, "%%Creator: %s\n", Image_get_pluginname(image));
fprintf(prn, "%%%%Creator: %s\n", Image_get_appname(image));
fprintf(prn, "%%%%CreationDate: %s", ctime(&curtime));
fputs("%%Copyright: 1997-1999 by Michael Sweet (mike@easysw.com) and Robert Krawitz (rlk@alum.mit.edu)\n", prn);
fputs("%%Copyright: 1997-2000 by Michael Sweet (mike@easysw.com) and Robert Krawitz (rlk@alum.mit.edu)\n", prn);
fprintf(prn, "%%%%BoundingBox: %d %d %d %d\n",
left, top - out_height, left + out_width, top);
fputs("%%DocumentData: Clean7Bit\n", prn);
@ -548,39 +445,28 @@ ps_print(int model, /* I - Model (Level 1 or 2) */
}
/*
* Output the page, rotating as necessary...
* Output the page...
*/
fputs("%%Page: 1\n", prn);
fputs("gsave\n", prn);
if (landscape)
{
fprintf(prn, "%d %d translate\n", left, top - out_height);
fprintf(prn, "%.3f %.3f scale\n",
(float)out_width / ((float)image_height),
(float)out_height / ((float)image_width));
}
else
{
fprintf(prn, "%d %d translate\n", left, top);
fprintf(prn, "%.3f %.3f scale\n",
(float)out_width / ((float)image_width),
(float)out_height / ((float)image_height));
}
in = malloc(image_width * image_bpp);
out = malloc((image_width * out_bpp + 3) * 2);
compute_lut(256, &nv);
if (model == 0)
{
fprintf(prn, "/picture %d string def\n", image_width * out_bpp);
fprintf(prn, "%d %d 8\n", image_width, image_height);
if (landscape)
fputs("[ 0 1 1 0 0 0 ]\n", prn);
else
fputs("[ 1 0 0 -1 0 1 ]\n", prn);
if (output_type == OUTPUT_GRAY)
@ -594,7 +480,7 @@ ps_print(int model, /* I - Model (Level 1 or 2) */
Image_note_progress(image, y, image_height);
Image_get_row(image, in, y);
(*colorfunc)(in, out, image_width, image_bpp, lut, cmap, v);
(*colorfunc)(in, out, image_width, image_bpp, cmap, &nv);
ps_hex(prn, out, image_width * out_bpp);
}
@ -623,9 +509,6 @@ ps_print(int model, /* I - Model (Level 1 or 2) */
if ((image_width * 72 / out_width) < 100)
fputs("\t/Interpolate true\n", prn);
if (landscape)
fputs("\t/ImageMatrix [ 0 1 1 0 0 0 ]\n", prn);
else
fputs("\t/ImageMatrix [ 1 0 0 -1 0 1 ]\n", prn);
fputs(">>\n", prn);
@ -637,7 +520,7 @@ ps_print(int model, /* I - Model (Level 1 or 2) */
Image_note_progress(image, y, image_height);
Image_get_row(image, in, y);
(*colorfunc)(in, out + out_offset, image_width, image_bpp, lut, cmap, v);
(*colorfunc)(in, out + out_offset, image_width, image_bpp, cmap, &nv);
out_length = out_offset + image_width * out_bpp;
@ -656,7 +539,9 @@ ps_print(int model, /* I - Model (Level 1 or 2) */
memcpy(out, out + out_length - out_offset, out_offset);
}
}
Image_progress_conclude(image);
free_lut(&nv);
free(in);
free(out);
@ -778,20 +663,22 @@ ps_ascii85(FILE *prn, /* I - File to print to */
*/
static char * /* O - Control string */
ppd_find(char *ppd_file, /* I - Name of PPD file */
char *name, /* I - Name of parameter */
char *option, /* I - Value of parameter */
ppd_find(const char *ppd_file, /* I - Name of PPD file */
const char *name, /* I - Name of parameter */
const char *option, /* I - Value of parameter */
int *order) /* O - Order of the control string */
{
char line[1024], /* Line from file */
lname[255], /* Name from line */
loption[255], /* Value from line */
*opt; /* Current control string pointer */
static char value[32768]; /* Current control string value */
static char *value = NULL; /* Current control string value */
if (ppd_file == NULL || name == NULL || option == NULL)
return (NULL);
if (!value)
value = malloc(32768);
if (ps_ppd_file == NULL || strcmp(ps_ppd_file, ppd_file) != 0)
{
@ -818,7 +705,7 @@ ppd_find(char *ppd_file, /* I - Name of PPD file */
if (line[0] != '*')
continue;
if (g_strncasecmp(line, "*OrderDependency:", 17) == 0 && order != NULL)
if (strncasecmp(line, "*OrderDependency:", 17) == 0 && order != NULL)
{
sscanf(line, "%*s%d", order);
continue;
@ -826,8 +713,8 @@ ppd_find(char *ppd_file, /* I - Name of PPD file */
else if (sscanf(line, "*%s %[^/:]", lname, loption) != 2)
continue;
if (g_strcasecmp(lname, name) == 0 &&
g_strcasecmp(loption, option) == 0)
if (strcasecmp(lname, name) == 0 &&
strcasecmp(loption, option) == 0)
{
opt = strchr(line, ':') + 1;
while (*opt == ' ' || *opt == '\t')
@ -857,8 +744,3 @@ ppd_find(char *ppd_file, /* I - Name of PPD file */
return (NULL);
}
/*
* End of "$Id$".
*/

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,771 @@
/*
* "$Id$"
*
* Softweave calculator for gimp-print.
*
* Copyright 2000 Charles Briscoe-Smith <cpbs@debian.org>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdio.h>
#include <stdlib.h>
#if 0
#define TEST_RAW
#endif
#if 0
#define TEST_COOKED
#endif
#if 0
#define ACCUMULATE
#endif
#if 1
#define ASSERTIONS
#endif
#if defined(TEST_RAW) || defined(TEST_COOKED)
#define TEST
#endif
#ifdef ASSERTIONS
#define assert(x) if (!(x)) { fprintf(stderr, "ASSERTION FAILURE! \"%s\", line %d.\n", __FILE__, __LINE__); exit(1); }
#else
#define assert(x) /* nothing */
#endif
#ifdef TEST
#define MAXCOLLECT (1000)
#endif
static int
gcd(int x, int y)
{
assert (x >= 0);
assert (y >= 0);
if (y == 0)
return x;
while (x != 0) {
if (y > x) {
int t = x;
x = y;
y = t;
}
x %= y;
}
return y;
}
/* RAW WEAVE */
typedef struct raw {
int separation;
int jets;
int oversampling;
int advancebasis;
int subblocksperpassblock;
int passespersubblock;
} raw_t;
static void
initialize_raw_weave(raw_t *w, /* I - weave struct to be filled in */
int S, /* I - jet separation */
int J, /* I - number of jets */
int H) /* I - oversampling factor */
{
w->separation = S;
w->jets = J;
w->oversampling = H;
w->advancebasis = J / H;
w->subblocksperpassblock = gcd(S, w->advancebasis);
w->passespersubblock = S / w->subblocksperpassblock;
}
static void
calculate_raw_pass_parameters(raw_t *w, /* I - weave parameters */
int pass, /* I - pass number ( >= 0) */
int *startrow, /* O - print head position */
int *subpass) /* O - subpass number */
{
int band, passinband, subpassblock, subpassoffset;
band = pass / (w->separation * w->oversampling);
passinband = pass % (w->separation * w->oversampling);
subpassblock = pass % w->separation
* w->subblocksperpassblock / w->separation;
if (subpassblock * 2 < w->subblocksperpassblock)
subpassoffset = 2 * subpassblock;
else
subpassoffset = 2 * (w->subblocksperpassblock - subpassblock)
- 1;
*startrow = w->separation * w->jets * band
+ w->advancebasis * passinband + subpassoffset;
*subpass = passinband / w->separation;
}
static void
calculate_raw_row_parameters(raw_t *w, /* I - weave parameters */
int row, /* I - row number */
int subpass, /* I - subpass number */
int *pass, /* O - pass number */
int *jet, /* O - jet number in pass */
int *startrow) /* O - starting row of pass */
{
int subblockoffset, subpassblock, band, baserow, passinband, offset;
subblockoffset = row % w->subblocksperpassblock;
if (subblockoffset % 2 == 0)
subpassblock = subblockoffset / 2;
else
subpassblock = w->subblocksperpassblock
- (subblockoffset + 1) / 2;
band = row / (w->separation * w->jets);
baserow = row - subblockoffset - band * w->separation * w->jets;
passinband = baserow / w->advancebasis;
offset = baserow % w->advancebasis;
while (offset % w->separation != 0
|| passinband / w->separation != subpass
|| passinband % w->separation / w->passespersubblock
!= subpassblock)
{
offset += w->advancebasis;
passinband--;
if (passinband < 0) {
const int roundedjets = w->advancebasis
* w->oversampling;
band--;
passinband += w->separation * w->oversampling;
offset += w->separation * (w->jets - roundedjets);
}
}
*pass = band * w->oversampling * w->separation + passinband;
*jet = offset / w->separation;
*startrow = row - (*jet * w->separation);
}
/* COOKED WEAVE */
typedef struct cooked {
raw_t rw;
int first_row_printed;
int last_row_printed;
int first_premapped_pass; /* First raw pass used by this page */
int first_normal_pass;
int first_postmapped_pass;
int first_unused_pass;
int *pass_premap;
int *stagger_premap;
int *pass_postmap;
int *stagger_postmap;
} cooked_t;
static void
sort_by_start_row(int *map, int *startrows, int count)
{
/*
* Yes, it's a bubble sort, but we do it no more than 4 times
* per page, and we are only sorting a small number of items.
*/
int dirty;
do {
int x;
dirty = 0;
for (x = 1; x < count; x++) {
if (startrows[x - 1] > startrows[x]) {
int temp = startrows[x - 1];
startrows[x - 1] = startrows[x];
startrows[x] = temp;
temp = map[x - 1];
map[x - 1] = map[x];
map[x] = temp;
dirty = 1;
}
}
} while (dirty);
}
static void
calculate_stagger(raw_t *w, int *map, int *startrows_stagger, int count)
{
int i;
for (i = 0; i < count; i++) {
int startrow, subpass;
calculate_raw_pass_parameters(w, map[i], &startrow, &subpass);
startrow -= w->separation * w->jets;
startrows_stagger[i] = (startrows_stagger[i] - startrow)
/ w->separation;
}
}
static void
invert_map(int *map, int *stagger, int count, int oldfirstpass,
int newfirstpass)
{
int newmap[count], newstagger[count];
int i;
for (i = 0; i < count; i++) {
newmap[map[i] - oldfirstpass] = i + newfirstpass;
newstagger[map[i] - oldfirstpass] = stagger[i];
}
memcpy(map, newmap, count * sizeof(int));
memcpy(stagger, newstagger, count * sizeof(int));
}
static void
make_passmap(raw_t *w, int **map, int **starts, int first_pass_number,
int first_pass_to_map, int first_pass_after_map,
int first_pass_to_stagger, int first_pass_after_stagger,
int first_row_of_maximal_pass, int separations_to_distribute)
{
int *passmap, *startrows;
int passes_to_map = first_pass_after_map - first_pass_to_map;
int i;
assert(first_pass_to_map <= first_pass_after_map);
assert(first_pass_to_stagger <= first_pass_after_stagger);
*map = passmap = malloc(passes_to_map * sizeof(int));
*starts = startrows = malloc(passes_to_map * sizeof(int));
for (i = 0; i < passes_to_map; i++) {
int startrow, subpass;
int pass = i + first_pass_to_map;
calculate_raw_pass_parameters(w, pass, &startrow, &subpass);
passmap[i] = pass;
if (first_row_of_maximal_pass >= 0)
startrow = first_row_of_maximal_pass - startrow
+ w->separation * w->jets;
else
startrow -= w->separation * w->jets;
while (startrow < 0)
startrow += w->separation;
startrows[i] = startrow;
}
sort_by_start_row(passmap, startrows, passes_to_map);
separations_to_distribute++;
for (i = 0; i < first_pass_after_stagger - first_pass_to_stagger; i++) {
int offset = first_pass_to_stagger - first_pass_to_map;
if (startrows[i + offset] / w->separation
< i % separations_to_distribute)
{
startrows[i + offset]
= startrows[i + offset] % w->separation
+ w->separation * (i % separations_to_distribute);
}
}
if (first_row_of_maximal_pass >= 0) {
for (i = 0; i < passes_to_map; i++) {
startrows[i] = first_row_of_maximal_pass - startrows[i];
}
}
sort_by_start_row(passmap, startrows, passes_to_map);
calculate_stagger(w, passmap, startrows, passes_to_map);
invert_map(passmap, startrows, passes_to_map, first_pass_to_map,
first_pass_to_map - first_pass_number);
}
static void
calculate_pass_map(cooked_t *w, /* I - weave parameters */
int pagelength, /* I - number of rows on page */
int firstrow, /* I - first printed row */
int lastrow) /* I - last printed row */
{
int startrow, subpass;
int pass = -1;
w->first_row_printed = firstrow;
w->last_row_printed = lastrow;
if (pagelength <= lastrow)
pagelength = lastrow + 1;
do {
calculate_raw_pass_parameters(&w->rw, ++pass,
&startrow, &subpass);
} while (startrow - w->rw.separation < firstrow);
w->first_premapped_pass = pass;
while (startrow < w->rw.separation * w->rw.jets
&& startrow - w->rw.separation < pagelength
&& startrow <= lastrow + w->rw.separation * w->rw.jets)
{
calculate_raw_pass_parameters(&w->rw, ++pass,
&startrow, &subpass);
}
w->first_normal_pass = pass;
while (startrow - w->rw.separation < pagelength
&& startrow <= lastrow + w->rw.separation * w->rw.jets)
{
calculate_raw_pass_parameters(&w->rw, ++pass,
&startrow, &subpass);
}
w->first_postmapped_pass = pass;
while (startrow <= lastrow + w->rw.separation * w->rw.jets) {
calculate_raw_pass_parameters(&w->rw, ++pass,
&startrow, &subpass);
}
w->first_unused_pass = pass;
/*
* FIXME: make sure first_normal_pass doesn't advance beyond
* first_postmapped_pass, or first_postmapped_pass doesn't
* retreat before first_normal_pass.
*/
if (w->first_normal_pass > w->first_premapped_pass) {
int spread, separations_to_distribute, normal_passes_mapped;
separations_to_distribute = firstrow / w->rw.separation;
spread = (separations_to_distribute + 1) * w->rw.separation;
normal_passes_mapped = (spread + w->rw.advancebasis - 1)
/ w->rw.advancebasis;
w->first_normal_pass += normal_passes_mapped;
make_passmap(&w->rw, &w->pass_premap, &w->stagger_premap,
w->first_premapped_pass,
w->first_premapped_pass, w->first_normal_pass,
w->first_premapped_pass,
w->first_normal_pass - normal_passes_mapped,
-1, separations_to_distribute);
} else {
w->pass_premap = 0;
w->stagger_premap = 0;
}
if (w->first_unused_pass > w->first_postmapped_pass) {
int spread, separations_to_distribute, normal_passes_mapped;
separations_to_distribute = (pagelength - lastrow - 1)
/ w->rw.separation;
spread = (separations_to_distribute + 1) * w->rw.separation;
normal_passes_mapped = (spread + w->rw.advancebasis)
/ w->rw.advancebasis;
w->first_postmapped_pass -= normal_passes_mapped;
make_passmap(&w->rw, &w->pass_postmap, &w->stagger_postmap,
w->first_premapped_pass,
w->first_postmapped_pass, w->first_unused_pass,
w->first_postmapped_pass + normal_passes_mapped,
w->first_unused_pass,
pagelength - 1
- w->rw.separation * (w->rw.jets - 1),
separations_to_distribute);
} else {
w->pass_postmap = 0;
w->stagger_postmap = 0;
}
}
void * /* O - weave parameter block */
initialize_weave_params(int S, /* I - jet separation */
int J, /* I - number of jets */
int H, /* I - oversampling factor */
int firstrow, /* I - first row number to print */
int lastrow, /* I - last row number to print */
int pagelength) /* I - number of rows on the whole
page, without using any
expanded margin facilities */
{
cooked_t *w = malloc(sizeof(cooked_t));
if (w) {
initialize_raw_weave(&w->rw, S, J, H);
calculate_pass_map(w, pagelength, firstrow, lastrow);
}
return w;
}
void
destroy_weave_params(void *vw)
{
cooked_t *w = (cooked_t *) vw;
if (w->pass_premap) free(w->pass_premap);
if (w->stagger_premap) free(w->stagger_premap);
if (w->pass_postmap) free(w->pass_postmap);
if (w->stagger_postmap) free(w->stagger_postmap);
free(w);
}
void
calculate_row_parameters(void *vw, /* I - weave parameters */
int row, /* I - row number */
int subpass, /* I - subpass */
int *pass, /* O - pass containing row */
int *jetnum, /* O - jet number of row */
int *startingrow, /* O - phys start row of pass */
int *ophantomrows, /* O - missing rows at start */
int *ojetsused) /* O - jets used by pass */
{
cooked_t *w = (cooked_t *) vw;
int raw_pass, jet, startrow, phantomrows, jetsused;
int stagger = 0;
int extra;
assert(row >= w->first_row_printed);
assert(row <= w->last_row_printed);
calculate_raw_row_parameters(&w->rw,
row + w->rw.separation * w->rw.jets,
subpass, &raw_pass, &jet, &startrow);
startrow -= w->rw.separation * w->rw.jets;
jetsused = w->rw.jets;
phantomrows = 0;
if (raw_pass < w->first_normal_pass) {
*pass = w->pass_premap[raw_pass - w->first_premapped_pass];
stagger = w->stagger_premap[raw_pass - w->first_premapped_pass];
} else if (raw_pass >= w->first_postmapped_pass) {
*pass = w->pass_postmap[raw_pass - w->first_postmapped_pass];
stagger = w->stagger_postmap[raw_pass
- w->first_postmapped_pass];
} else {
*pass = raw_pass - w->first_premapped_pass;
}
startrow += stagger * w->rw.separation;
*jetnum = jet - stagger;
if (stagger < 0) {
stagger = -stagger;
phantomrows += stagger;
}
jetsused -= stagger;
extra = w->first_row_printed
- (startrow + w->rw.separation * phantomrows);
if (extra > 0) {
extra = (extra + w->rw.separation - 1) / w->rw.separation;
jetsused -= extra;
phantomrows += extra;
}
extra = startrow + w->rw.separation * (phantomrows + jetsused - 1)
- w->last_row_printed;
if (extra > 0) {
extra = (extra + w->rw.separation - 1) / w->rw.separation;
jetsused -= extra;
}
*startingrow = startrow;
*ophantomrows = phantomrows;
*ojetsused = jetsused;
}
#ifdef TEST_COOKED
static void
calculate_pass_parameters(cooked_t *w, /* I - weave parameters */
int pass, /* I - pass number ( >= 0) */
int *startrow, /* O - print head position */
int *subpass, /* O - subpass number */
int *phantomrows, /* O - missing rows */
int *jetsused) /* O - jets used to print */
{
int raw_pass = pass + w->first_premapped_pass;
int stagger = 0;
int extra;
if (raw_pass < w->first_normal_pass) {
int i = 0;
while (i + w->first_premapped_pass < w->first_normal_pass) {
if (w->pass_premap[i] == pass) {
raw_pass = i + w->first_premapped_pass;
stagger = w->stagger_premap[i];
break;
}
i++;
}
} else if (raw_pass >= w->first_postmapped_pass) {
int i = 0;
while (i + w->first_postmapped_pass < w->first_unused_pass) {
if (w->pass_postmap[i] == pass) {
raw_pass = i + w->first_postmapped_pass;
stagger = w->stagger_postmap[i];
break;
}
i++;
}
}
calculate_raw_pass_parameters(&w->rw, raw_pass, startrow, subpass);
*startrow -= w->rw.separation * w->rw.jets;
*jetsused = w->rw.jets;
*phantomrows = 0;
*startrow += stagger * w->rw.separation;
if (stagger < 0) {
stagger = -stagger;
*phantomrows += stagger;
}
*jetsused -= stagger;
extra = w->first_row_printed - (*startrow + w->rw.separation * *phantomrows);
extra = (extra + w->rw.separation - 1) / w->rw.separation;
if (extra > 0) {
*jetsused -= extra;
*phantomrows += extra;
}
extra = *startrow + w->rw.separation * (*phantomrows + *jetsused - 1)
- w->last_row_printed;
extra = (extra + w->rw.separation - 1) / w->rw.separation;
if (extra > 0) {
*jetsused -= extra;
}
}
#endif /* TEST_COOKED */
#ifdef TEST
#ifdef ACCUMULATE
#define PUTCHAR(x) /* nothing */
#else
#define PUTCHAR(x) putchar(x)
#endif
static void
plotpass(int startrow, int phantomjets, int jetsused, int totaljets,
int separation, int subpass, int *collect, int *prints)
{
int hpos, i;
for (hpos = 0; hpos < startrow; hpos++)
PUTCHAR(' ');
for (i = 0; i < phantomjets; i++) {
int j;
PUTCHAR('X');
hpos++;
for (j = 1; j < separation; j++) {
PUTCHAR(' ');
hpos++;
}
}
for (; i < phantomjets + jetsused; i++) {
if (i > phantomjets) {
int j;
for (j = 1; j < separation; j++) {
PUTCHAR('-');
hpos++;
}
}
if (hpos < MAXCOLLECT) {
if (collect[hpos] & 1 << subpass)
PUTCHAR('^');
else if (subpass < 10)
PUTCHAR('0' + subpass);
else
PUTCHAR('A' + subpass - 10);
collect[hpos] |= 1 << subpass;
prints[hpos]++;
} else {
PUTCHAR('0' + subpass);
}
hpos++;
}
while (i++ < totaljets) {
int j;
for (j = 1; j < separation; j++) {
PUTCHAR(' ');
hpos++;
}
PUTCHAR('X');
}
#ifdef ACCUMULATE
for (i=0; i<=MAXCOLLECT; i++) {
if (collect[i] == 0)
putchar(' ');
else if (collect[i] < 10)
putchar('0'+collect[i]);
else
putchar('A'+collect[i]-10);
}
#endif
putchar('\n');
}
#endif /* TEST */
#ifdef TEST_COOKED
int
main(int ac, char *av[])
{
int S =ac>1 ? atoi(av[1]) : 4;
int J =ac>2 ? atoi(av[2]) : 12;
int H =ac>3 ? atoi(av[3]) : 1;
int firstrow =ac>4 ? atoi(av[4]) : 1;
int lastrow =ac>5 ? atoi(av[5]) : 100;
int pagelength=ac>6 ? atoi(av[6]) : 1000;
cooked_t *weave;
int passes;
int pass, x;
int collect[MAXCOLLECT];
int prints[MAXCOLLECT];
memset(collect, 0, MAXCOLLECT*sizeof(int));
memset(prints, 0, MAXCOLLECT*sizeof(int));
printf("S=%d J=%d H=%d firstrow=%d lastrow=%d pagelength=%d\n",
S, J, H, firstrow, lastrow, pagelength);
weave = initialize_weave_params(S, J, H, firstrow, lastrow, pagelength);
passes = weave->first_unused_pass - weave->first_premapped_pass;
for (pass = 0; pass < passes; pass++) {
int startrow, subpass, phantomjets, jetsused;
calculate_pass_parameters(weave, pass, &startrow, &subpass,
&phantomjets, &jetsused);
plotpass(startrow, phantomjets, jetsused, J, S, subpass,
collect, prints);
}
for (pass=MAXCOLLECT - 1; prints[pass] == 0; pass--)
;
for (x=0; x<=pass; x++) {
if (collect[x] < 10)
putchar('0'+collect[x]);
else
putchar('A'+collect[x]-10);
}
putchar('\n');
for (x=0; x<=pass; x++) {
if (prints[x] < 10)
putchar('0'+prints[x]);
else
putchar('A'+prints[x]-10);
}
putchar('\n');
return 0;
}
#endif /* TEST_COOKED */
#ifdef TEST_RAW
int
main(int ac, char *av[])
{
int S =ac>1 ? atoi(av[1]) : 4;
int J =ac>2 ? atoi(av[2]) : 12;
int h_pos =ac>3 ? atoi(av[3]) : 1;
int h_over=ac>4 ? atoi(av[4]) : 1;
int v_over=ac>5 ? atoi(av[5]) : 1;
int H = h_pos * h_over * v_over;
int pass, passes, x;
int collect[MAXCOLLECT];
int prints[MAXCOLLECT];
raw_t raw;
memset(collect, 0, MAXCOLLECT*sizeof(int));
memset(prints, 0, MAXCOLLECT*sizeof(int));
printf("S=%d J=%d H=%d\n", S, J, H);
if (H > J) {
printf("H > J, so this weave will not work!\n");
}
passes = S * H * 3;
initialize_raw_weave(&raw, S, J, H);
for (pass=0; pass<passes + S * H; pass++) {
int startrow, subpass, phantomjets, jetsused;
calculate_raw_pass_parameters(&raw, pass, &startrow, &subpass);
phantomjets = 0;
jetsused = J;
plotpass(startrow, phantomjets, jetsused, J, S, subpass,
collect, prints);
}
for (pass=MAXCOLLECT - 1; prints[pass] == 0; pass--)
;
for (x=0; x<=pass; x++) {
if (collect[x] < 10)
putchar('0'+collect[x]);
else
putchar('A'+collect[x]-10);
}
putchar('\n');
for (x=0; x<=pass; x++) {
if (prints[x] < 10)
putchar('0'+prints[x]);
else
putchar('A'+prints[x]-10);
}
putchar('\n');
printf(" A first row given by pass lookup doesn't match row lookup\n"
" B jet out of range\n"
" C given jet number of pass doesn't print this row\n"
" D subpass given by reverse lookup doesn't match requested subpass\n");
for (x = S * J; x < S * J * 20; x++) {
int h;
for (h = 0; h < H; h++) {
int pass, jet, start, first, subpass, z;
int a=0, b=0, c=0, d=0;
calculate_raw_row_parameters(&raw, x, h, &pass, &jet, &start);
for (z=0; z < pass; z++) {
putchar(' ');
}
printf("%d", jet);
calculate_raw_pass_parameters(&raw, pass, &first, &subpass);
if (first != start)
a=1;
if (jet < 0 || jet >= J)
b=1;
if (x != first + jet * S)
c=1;
if (subpass != h)
d=1;
if (a || b || c || d) {
printf(" (");
if (a) putchar('A');
if (b) putchar('B');
if (c) putchar('C');
if (d) putchar('D');
putchar(')');
printf("\npass=%d first=%d start=%d jet=%d subpass=%d", pass, first, start, jet, subpass);
}
putchar('\n');
}
//putchar('\n');
}
return 0;
}
#endif /* TEST_RAW */

File diff suppressed because it is too large Load Diff

View File

@ -36,6 +36,10 @@
* rlk 20000112
*/
#ifndef PRINT_HEADER
#define PRINT_HEADER
/*
* Include necessary header files...
*/
@ -59,15 +63,19 @@
#define OUTPUT_GRAY 0 /* Grayscale output */
#define OUTPUT_COLOR 1 /* Color output */
#define OUTPUT_GRAY_COLOR 2 /* Grayscale output using color */
#define ORIENT_AUTO -1 /* Best orientation */
#define ORIENT_PORTRAIT 0 /* Portrait orientation */
#define ORIENT_LANDSCAPE 1 /* Landscape orientation */
#ifndef MIN
# define MIN(a,b) ((a) < (b) ? (a) : (b))
# define MAX(a,b) ((a) > (b) ? (a) : (b))
#endif /* !MIN */
#define MAX_CARRIAGE_WIDTH 80 /* This really needs to go away */
/* For now, this is wide enough for 4B ISO */
#define IMAGE_LINE_ART 0
#define IMAGE_SOLID_TONE 1
#define IMAGE_CONTINUOUS 2
#define IMAGE_MONOCHROME 3
/*
@ -76,23 +84,26 @@
typedef struct
{
unsigned short composite[256];
unsigned short red[256];
unsigned short green[256];
unsigned short blue[256];
unsigned steps;
unsigned short *composite;
unsigned short *red;
unsigned short *green;
unsigned short *blue;
} lut_t;
typedef struct /* Plug-in variables */
{
char output_to[255], /* Name of file or command to print to */
char output_to[256], /* Name of file or command to print to */
driver[64], /* Name of printer "driver" */
ppd_file[255]; /* PPD file */
ppd_file[256]; /* PPD file */
int output_type; /* Color or grayscale output */
char resolution[64], /* Resolution */
media_size[64], /* Media size */
media_type[64], /* Media type */
media_source[64]; /* Media source */
media_source[64], /* Media source */
ink_type[64], /* Ink or cartridge */
dither_algorithm[64]; /* Dithering algorithm */
int brightness; /* Output brightness */
float scaling; /* Scaling, percent of printable area */
int orientation, /* Orientation - 0 = port., 1 = land.,
@ -107,6 +118,13 @@ typedef struct /* Plug-in variables */
int linear; /* Linear density (mostly for testing!) */
float saturation; /* Output saturation */
float density; /* Maximum output density */
int image_type; /* Image type (line art etc.) */
int unit; /* Units for preview area 0=Inch 1=Metric */
float app_gamma; /* Application gamma */
int page_width; /* Width of page in points */
int page_height; /* Height of page in points */
lut_t *lut; /* Look-up table */
unsigned char *cmap; /* Color map */
} vars_t;
typedef struct /**** Printer List ****/
@ -116,133 +134,270 @@ typedef struct /**** Printer List ****/
vars_t v;
} plist_t;
typedef enum papersize_unit
{
PAPERSIZE_ENGLISH,
PAPERSIZE_METRIC
} papersize_unit_t;
typedef struct
{
char name[32];
unsigned width;
unsigned length;
papersize_unit_t paper_unit;
} papersize_t;
/*
* Abstract data type for interfacing with the image creation program
* (in this case, the Gimp).
*/
typedef void *Image;
/* For how to create an Image wrapping a Gimp drawable, see print_gimp.h */
extern void Image_init(Image image);
extern void Image_reset(Image image);
extern void Image_transpose(Image image);
extern void Image_hflip(Image image);
extern void Image_vflip(Image image);
extern void Image_crop(Image image, int left, int top, int right, int bottom);
extern void Image_rotate_ccw(Image image);
extern void Image_rotate_cw(Image image);
extern void Image_rotate_180(Image image);
extern int Image_bpp(Image image);
extern int Image_width(Image image);
extern int Image_height(Image image);
extern const char *Image_get_pluginname(Image image);
extern void Image_get_col(Image image, unsigned char *data, int column);
extern void Image_get_row(Image image, unsigned char *data, int row);
extern const char *Image_get_appname(Image image);
extern void Image_progress_init(Image image);
extern void Image_note_progress(Image image, double current, double total);
extern void Image_progress_conclude(Image image);
typedef struct
typedef struct printer
{
char *long_name, /* Long name for UI */
*driver; /* Short name for printrc file */
int color, /* TRUE if supports color */
model; /* Model number */
float gamma, /* Gamma correction */
density; /* Ink "density" or black level */
char **(*parameters)(int model, char *ppd_file, char *name, int *count);
int model; /* Model number */
char **(*parameters)(const struct printer *printer, char *ppd_file,
char *name, int *count);
/* Parameter names */
void (*media_size)(int model, char *ppd_file, char *media_size,
void (*media_size)(const struct printer *printer, const vars_t *v,
int *width, int *length);
void (*imageable_area)(int model, char *ppd_file, char *media_size,
void (*imageable_area)(const struct printer *printer, const vars_t *v,
int *left, int *right, int *bottom, int *top);
void (*limit)(const struct printer *printer, const vars_t *v,
int *width, int *length);
/* Print function */
void (*print)(int model, int copies, FILE *prn, Image image,
unsigned char *cmap, lut_t *lut, vars_t *v);
void (*print)(const struct printer *printer, int copies, FILE *prn,
Image image, const vars_t *v);
const char *(*default_resolution)(const struct printer *printer);
vars_t printvars;
} printer_t;
typedef void (*convert_t)(unsigned char *in, unsigned short *out, int width,
int bpp, lut_t *lut, unsigned char *cmap,
vars_t *vars);
int bpp, unsigned char *cmap, const vars_t *vars);
typedef struct
{
double value;
unsigned bit_pattern;
int is_dark;
unsigned dot_size;
} simple_dither_range_t;
typedef struct
{
double value;
double lower;
double upper;
unsigned bit_pattern;
int is_dark;
unsigned dot_size;
} dither_range_t;
typedef struct
{
double value_l;
double value_h;
unsigned bits_l;
unsigned bits_h;
int isdark_l;
int isdark_h;
} full_dither_range_t;
/*
* Prototypes...
*/
extern void dither_black(unsigned short *, int, int, int, unsigned char *);
extern void * init_dither(int in_width, int out_width, int horizontal_aspect,
int vertical_aspect, vars_t *vars);
extern void dither_set_transition(void *vd, double);
extern void dither_set_density(void *vd, double);
extern void dither_set_black_lower(void *vd, double);
extern void dither_set_black_upper(void *vd, double);
extern void dither_set_black_levels(void *vd, double, double, double);
extern void dither_set_randomizers(void *vd, double, double, double, double);
extern void dither_set_ink_darkness(void *vd, double, double, double);
extern void dither_set_light_inks(void *vd, double, double, double, double);
extern void dither_set_c_ranges(void *vd, int nlevels,
const simple_dither_range_t *ranges,
double density);
extern void dither_set_m_ranges(void *vd, int nlevels,
const simple_dither_range_t *ranges,
double density);
extern void dither_set_y_ranges(void *vd, int nlevels,
const simple_dither_range_t *ranges,
double density);
extern void dither_set_k_ranges(void *vd, int nlevels,
const simple_dither_range_t *ranges,
double density);
extern void dither_set_k_ranges_full(void *vd, int nlevels,
const full_dither_range_t *ranges,
double density);
extern void dither_set_c_ranges_full(void *vd, int nlevels,
const full_dither_range_t *ranges,
double density);
extern void dither_set_m_ranges_full(void *vd, int nlevels,
const full_dither_range_t *ranges,
double density);
extern void dither_set_y_ranges_full(void *vd, int nlevels,
const full_dither_range_t *ranges,
double density);
extern void dither_set_c_ranges_simple(void *vd, int nlevels,
const double *levels, double density);
extern void dither_set_m_ranges_simple(void *vd, int nlevels,
const double *levels, double density);
extern void dither_set_y_ranges_simple(void *vd, int nlevels,
const double *levels, double density);
extern void dither_set_k_ranges_simple(void *vd, int nlevels,
const double *levels, double density);
extern void dither_set_c_ranges_complete(void *vd, int nlevels,
const dither_range_t *ranges);
extern void dither_set_m_ranges_complete(void *vd, int nlevels,
const dither_range_t *ranges);
extern void dither_set_y_ranges_complete(void *vd, int nlevels,
const dither_range_t *ranges);
extern void dither_set_k_ranges_complete(void *vd, int nlevels,
const dither_range_t *ranges);
extern void dither_set_ink_spread(void *vd, int spread);
extern void dither_set_max_ink(void *vd, int, double);
extern void dither_set_x_oversample(void *vd, int os);
extern void dither_set_y_oversample(void *vd, int os);
extern void dither_set_adaptive_divisor(void *vd, unsigned divisor);
extern void dither_set_error_mix(void *vd, double);
extern void dither_cmyk(unsigned short *, int, int, int, unsigned char *,
extern void free_dither(void *);
extern void * initialize_weave_params(int S, int J, int O,
int firstrow, int lastrow,
int pagelength);
extern void calculate_row_parameters(void *w, int row, int subpass,
int *pass, int *jet, int *startrow,
int *phantomrows, int *jetsused);
extern void destroy_weave_params(void *vw);
extern void dither_fastblack(unsigned short *, int, void *, unsigned char *);
extern void dither_black(unsigned short *, int, void *, unsigned char *);
extern void dither_cmyk(unsigned short *, int, void *, unsigned char *,
unsigned char *, unsigned char *,
unsigned char *, unsigned char *,
unsigned char *, unsigned char *, int);
unsigned char *, unsigned char *);
extern void dither_black4(unsigned short *, int, int, int,
unsigned char *);
extern void dither_cmyk4(unsigned short *, int, int, int, unsigned char *,
unsigned char *, unsigned char *,
unsigned char *);
extern void gray_to_gray(unsigned char *, unsigned short *, int, int,
lut_t *, unsigned char *, vars_t *);
extern void indexed_to_gray(unsigned char *, unsigned short *, int, int,
lut_t *, unsigned char *, vars_t *);
extern void indexed_to_rgb(unsigned char *, unsigned short *, int, int,
lut_t *, unsigned char *, vars_t *);
extern void rgb_to_gray(unsigned char *, unsigned short *, int, int,
lut_t *, unsigned char *, vars_t *);
extern void rgb_to_rgb(unsigned char *, unsigned short *, int, int,
lut_t *, unsigned char *, vars_t *);
extern void compute_lut(lut_t *lut, float print_gamma,
float app_gamma, vars_t *v);
extern void merge_printvars(vars_t *user, const vars_t *print);
extern void free_lut(vars_t *v);
extern void compute_lut(size_t steps, vars_t *v);
extern void default_media_size(int model, char *ppd_file, char *media_size,
extern void default_media_size(const printer_t *printer, const vars_t *v,
int *width, int *length);
extern char **escp2_parameters(int model, char *ppd_file, char *name,
int *count);
extern void escp2_imageable_area(int model, char *ppd_file,
char *media_size, int *left, int *right,
extern char **escp2_parameters(const printer_t *printer, char *ppd_file,
char *name, int *count);
extern void escp2_imageable_area(const printer_t *printer, const vars_t *v,
int *left, int *right,
int *bottom, int *top);
extern void escp2_print(int model, int copies, FILE *prn,
Image image, unsigned char *cmap,
lut_t *lut, vars_t *v);
extern char **pcl_parameters(int model, char *ppd_file, char *name,
int *count);
extern void pcl_imageable_area(int model, char *ppd_file, char *media_size,
int *left, int *right, int *bottom,
int *top);
extern void pcl_print(int model, int copies, FILE *prn,
Image image, unsigned char *cmap,
lut_t *lut, vars_t *v);
extern char **ps_parameters(int model, char *ppd_file, char *name,
int *count);
extern void ps_media_size(int model, char *ppd_file, char *media_size,
extern void escp2_limit(const printer_t *printer, const vars_t *v,
int *width, int *length);
extern void ps_imageable_area(int model, char *ppd_file, char *media_size,
int *left, int *right, int *bottom,
int *top);
extern void ps_print(int model, int copies, FILE *prn,
Image image, unsigned char *cmap,
lut_t *lut, vars_t *v);
extern void escp2_print(const printer_t *printer, int copies, FILE *prn,
Image image, const vars_t *v);
extern const char *escp2_default_resolution(const printer_t *printer);
#ifdef LEFTOVER_8_BIT
extern void dither_cmyk4(unsigned char *, int, int, int, unsigned char *,
unsigned char *, unsigned char *,
unsigned char *);
extern void dither_black4(unsigned char *, int, int, int, unsigned char *);
extern void gray_to_gray(unsigned char *, unsigned char *, int, int,
lut_t *, unsigned char *, float);
extern void indexed_to_gray(unsigned char *, unsigned char *, int, int,
lut_t *, unsigned char *, float);
#endif
int known_printers(void);
const printer_t *get_printers(void);
const printer_t *get_printer_by_index(int);
const printer_t *get_printer_by_long_name(const char *);
const printer_t *get_printer_by_driver(const char *);
int get_printer_index_by_driver(const char *);
extern char **canon_parameters(const printer_t *printer, char *ppd_file,
char *name, int *count);
extern void canon_imageable_area(const printer_t *printer, const vars_t *v,
int *left, int *right,
int *bottom, int *top);
extern void canon_limit(const printer_t *printer, const vars_t *v,
int *width, int *length);
extern void canon_print(const printer_t *printer, int copies, FILE *prn,
Image image, const vars_t *v);
extern const char *canon_default_resolution(const printer_t *printer);
extern char **pcl_parameters(const printer_t *printer, char *ppd_file,
char *name, int *count);
extern void pcl_imageable_area(const printer_t *printer, const vars_t *v,
int *left, int *right,
int *bottom, int *top);
extern void pcl_limit(const printer_t *printer, const vars_t *v,
int *width, int *length);
extern void pcl_print(const printer_t *printer, int copies, FILE *prn,
Image image, const vars_t *v);
extern const char *pcl_default_resolution(const printer_t *printer);
extern char **ps_parameters(const printer_t *printer, char *ppd_file,
char *name, int *count);
extern void ps_media_size(const printer_t *printer, const vars_t *v,
int *width, int *length);
extern void ps_imageable_area(const printer_t *printer, const vars_t *v,
int *left, int *right,
int *bottom, int *top);
extern void ps_limit(const printer_t *printer, const vars_t *v,
int *width, int *length);
extern void ps_print(const printer_t *printer, int copies, FILE *prn,
Image image, const vars_t *v);
extern const char *ps_default_resolution(const printer_t *printer);
extern const char *default_dither_algorithm(void);
extern int known_papersizes(void);
extern const papersize_t *get_papersizes(void);
extern const papersize_t *get_papersize_by_name(const char *);
extern const papersize_t *get_papersize_by_size(int l, int w);
extern int known_printers(void);
extern const printer_t *get_printers(void);
extern const printer_t *get_printer_by_index(int);
extern const printer_t *get_printer_by_long_name(const char *);
extern const printer_t *get_printer_by_driver(const char *);
extern int get_printer_index_by_driver(const char *);
extern int num_dither_algos;
extern char *dither_algo_names[];
extern convert_t choose_colorfunc(int, int, const unsigned char *, int *,
const vars_t *);
extern void
compute_page_parameters(int page_right, int page_left, int page_top,
int page_bottom, int scaling, int image_width,
int image_height, Image image, int *orientation,
int *page_width, int *page_height, int *out_width,
int *out_height, int *left, int *top);
extern int
verify_printer_params(const printer_t *, const vars_t *);
#endif /* PRINT_HEADER */
/*
* End of "$Id$".
*/

View File

@ -26,11 +26,13 @@
* See ChangeLog
*/
#ifndef PRINT_GIMP_HEADER
#define PRINT_GIMP_HEADER
#ifndef __PRINT_GIMP_H__
#define __PRINT_GIMP_H__
#include <gtk/gtk.h>
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
#include "print.h"
@ -38,7 +40,7 @@
* All Gimp-specific code is in this file.
*/
#define PLUG_IN_VERSION "3.0.10 - 01 Apr 2000"
#define PLUG_IN_VERSION VERSION " - " RELEASE_DATE
#define PLUG_IN_NAME "Print"
/*
@ -46,6 +48,16 @@
*/
#define PREVIEW_SIZE_VERT 240 /* Assuming max media size of 24" A2 */
#define PREVIEW_SIZE_HORIZ 240 /* Assuming max media size of 24" A2 */
#define MAX_PLIST 100
#if !defined(GIMP_MINOR_VERSION) || (GIMP_MAJOR_VERSION == 1 && GIMP_MINOR_VERSION == 0) || (GIMP_MAJOR_VERSION == 1 && GIMP_MINOR_VERSION == 1 && GIMP_MICRO_VERSION < 21)
#define GIMP_1_0
#endif
/*
* Function prototypes
*/
/* How to create an Image wrapping a Gimp drawable */
extern Image Image_GDrawable_new(GDrawable *drawable);
#endif /* __PRINT_GIMP_H__ */

File diff suppressed because it is too large Load Diff

6590
plug-ins/print/ran.367.179.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -238,8 +238,8 @@ plug-ins/mosaic/mosaic.c
plug-ins/pagecurl/pagecurl.c
plug-ins/print/gimp_color_window.c
plug-ins/print/gimp_main_window.c
plug-ins/print/print-image-gimp.c
plug-ins/print/print.c
plug-ins/print/print-printers.c
plug-ins/rcm/rcm.c
plug-ins/rcm/rcm_callback.c
plug-ins/rcm/rcm_dialog.c