summaryrefslogtreecommitdiff
path: root/gs/contrib/gdevlx50.c
diff options
context:
space:
mode:
Diffstat (limited to 'gs/contrib/gdevlx50.c')
-rw-r--r--gs/contrib/gdevlx50.c2515
1 files changed, 1253 insertions, 1262 deletions
diff --git a/gs/contrib/gdevlx50.c b/gs/contrib/gdevlx50.c
index 9d6b7da83..1c240247c 100644
--- a/gs/contrib/gdevlx50.c
+++ b/gs/contrib/gdevlx50.c
@@ -38,9 +38,9 @@
Based on the driver for the Lexmark 5700, pioneered by
Stephen Taylor setaylor@ma.ultranet.com staylor@cs.wpi.edu
- and on other pioneering work on the Lexmark 7000 by
+ and on other pioneering work on the Lexmark 7000 by
Henryk Paluch <paluch@bimbo.fjfi.cvut.cz>
-
+
My heartfelt thanks to these blokes (i.e. guys, fellows).
I should also like to thank Marija Svilans, through whom I discovered the
@@ -50,10 +50,10 @@
is Good, Beautiful and True; my Lord and my God, Jesus Christ.
"...all things were made through Him, and without Him was not anything
made that was made." John 1:3
-
+
Peter B. West pbwest@netscape.net
(First release: Friday, 8th October, 1999.)
-
+
*/
/*$Id: gdevlx50.c,v 1.4 2002/07/30 18:53:21 easysw Exp $*/
@@ -111,7 +111,7 @@
* DryingTime is used to include a delay after printing a page, to allow the
* page to dry to some extent before a subsequent page is printed and fed on
* top of it. The range of values is 0-60.
- *
+ *
* Ancilliary files:
*
* blckalgn.out As mentioned above,this is a file of printer commands
@@ -132,7 +132,7 @@
* Usage: cat parkcarts.out >/dev/lp0
*
================== K N O W N P R O B L E M S =======================
-
+
PROBLEMS WITH 1200dpi horizontally
This release was delayed by a bug in the production of black output
@@ -237,12 +237,12 @@
* R C S I D E N T S T R I N G S *
************************************************************************/
const char Id[] =
- "$Id: gdevlx50.c,v 1.4 2002/07/30 18:53:21 easysw Exp $";
+ "$Id: gdevlx50.c,v 1.4 2002/07/30 18:53:21 easysw Exp $";
const char RCSFile[] = "$RCSFile$";
const char Revision[] = "$Revision: 1.4 $";
const char Author[] =
- "Peter B. West pbwest@netscape.net\n"
- "$Author: easysw $\n";
+ "Peter B. West pbwest@netscape.net\n"
+ "$Author: easysw $\n";
/*===========================================================================
In gxdevice.h, the default width and height are expressed in 10ths of an
inch. The conversion to mm will therefore, not be exact.
@@ -398,7 +398,6 @@ const char Author[] =
is always constant, and with respect to the 208 pen, can be determined
from Alignment B.
-
*===========================================================================*/
/************************************************************************
@@ -408,25 +407,23 @@ const char Author[] =
#define A5_11_5000 1
#define A5_11_5700 2
-
#define ALIGN_A_DEF 15
#define ALIGN_A_OFFSET 5 /* in pageinit escape sequence */
#define ALIGN_B_DEF 8
#define ALIGN_B_OFFSET 6 /* in pageinit escape sequence */
#define HEADSEP_DEF 16
- /* number of pixels between even columns in */
- /* output and odd ones */
+ /* number of pixels between even columns in */
+ /* output and odd ones */
#define DRY_TIME_DEF 0 /* Default pause for page to dry */
-
/************************************************************************
* P R I N T E R T Y P E D E F I N I T I O N S *
************************************************************************/
#ifndef LX_BI
# define LX_UNI
- /* or define LX_BI */
+ /* or define LX_BI */
#endif
#define MIN_LX5000_X 300
#define MAX_LX5000_X 1200
@@ -442,8 +439,8 @@ const char Author[] =
# define LX5000_YDPI DEF_LX5000_Y
#endif
- /* Multiply lines by FEED_FACTOR when feeding
- paper. The 5000 feeds in 1200ths. */
+ /* Multiply lines by FEED_FACTOR when feeding
+ paper. The 5000 feeds in 1200ths. */
#define FEED_FACTOR ( 1200/LX5000_YDPI )
#define LX5000_XOFFSET_TO_0_0_XDPI (-48.0)
@@ -463,62 +460,62 @@ const char Author[] =
*/
#define LINE_PAD_BYTES 8
- /* number of bytes of padding on each end of */
- /* scan line to account for head separation */
- /* N.B. Keep this value 16-bit aligned. */
+ /* number of bytes of padding on each end of */
+ /* scan line to account for head separation */
+ /* N.B. Keep this value 16-bit aligned. */
#define RIGHTWARD 0
#define LEFTWARD 1
#define SWIPE_WORD_BITS 16
- /* Bits per directory word */
+ /* Bits per directory word */
#define BLACK_NOZZLES 208
- /* height of printhead in pixels */
+ /* height of printhead in pixels */
#define _1COLOUR_NOZZLES 64
- /* Height of one colour pen in pixels */
+ /* Height of one colour pen in pixels */
- /* Height of colour compatible black swipe */
+ /* Height of colour compatible black swipe */
#define BLK_COLOUR_NOZZLES (_1COLOUR_NOZZLES * 3)
- /* number of shorts described by each */
- /* full black column directory */
+ /* number of shorts described by each */
+ /* full black column directory */
#define BLK_SWIPE_WORDS ( BLACK_NOZZLES / SWIPE_WORD_BITS )
#define COLOUR_SWIPE_WORDS ( BLK_COLOUR_NOZZLES / SWIPE_WORD_BITS )
- /* and for a colour swipe command */
+ /* and for a colour swipe command */
#define _1COLOUR_WORDS ( _1COLOUR_NOZZLES / SWIPE_WORD_BITS )
- /* and for a single colour pen */
+ /* and for a single colour pen */
#define BLK_DIRECTORY_MASK (( ~0 << BLK_SWIPE_WORDS ) ^ ~0 )
#define COLOUR_DIRECTORY_MASK (( ~0 << COLOUR_SWIPE_WORDS ) ^ ~0 )
#define DIRECTORY_TYPE_BIT 0x2000
- /* Directory type: Set = normal;
- unset = repeat compression */
+ /* Directory type: Set = normal;
+ unset = repeat compression */
#define COLOUR_PEN_GAP 24 /* Defined in equivalent nozzles. This will */
- /* also be the offset from the top of the */
- /* first colour pen to the top of the colour */
- /* compatible black pen. */
+ /* also be the offset from the top of the */
+ /* first colour pen to the top of the colour */
+ /* compatible black pen. */
#define COLOUR_PEN_DIFF ( _1COLOUR_NOZZLES + COLOUR_PEN_GAP )
- /* The difference between corresponding */
- /* nozzle positions (e.g. bottom nozzle) on */
- /* contiguous colour pens. */
-
- /* The intial pen scanline positions are */
- /* defined with reference to the first */
- /* printable line (line 0) on the page. The */
- /* initial colour cartridge position is */
- /* immediately above line 0. */
+ /* The difference between corresponding */
+ /* nozzle positions (e.g. bottom nozzle) on */
+ /* contiguous colour pens. */
+
+ /* The intial pen scanline positions are */
+ /* defined with reference to the first */
+ /* printable line (line 0) on the page. The */
+ /* initial colour cartridge position is */
+ /* immediately above line 0. */
#define INITIAL_YELLOW_BOTTOM_LINE ( -1 )
- /* The pen buffer size must be a power of */
- /* 2, so that the index into the buffer */
- /* will either wrap within that size on */
- /* increment, or be able to be masked to */
- /* force a wrap of the index into the */
- /* circular pen buffers. See discussion */
- /* of pen buffers in lx5000_print_page(). */
+ /* The pen buffer size must be a power of */
+ /* 2, so that the index into the buffer */
+ /* will either wrap within that size on */
+ /* increment, or be able to be masked to */
+ /* force a wrap of the index into the */
+ /* circular pen buffers. See discussion */
+ /* of pen buffers in lx5000_print_page(). */
#define COLOUR_BUF_MASK 0xff
- /* 2^8 - 1 */
+ /* 2^8 - 1 */
#define COLOUR_BUF_LINES ( COLOUR_BUF_MASK + 1 )
/************************************************************************
@@ -526,53 +523,53 @@ const char Author[] =
************************************************************************/
#define SWIPE_LEADER 0x1b, '*', 4
- /* Lead-in bytes for swipe command */
+ /* Lead-in bytes for swipe command */
#define CMDLEN_X 3
- /* Index in swipe command of 4 byte */
+ /* Index in swipe command of 4 byte */
#define DIRECTION_X 7
- /* Index in swipe cmd of direction flag */
+ /* Index in swipe cmd of direction flag */
#define UNIDIRECTIONAL 0
#define BIDIRECTIONAL 1
#define HEADSPEED_X 8
- /* Index in swipe cmd of head speed */
- /* Head speeds for various densities */
+ /* Index in swipe cmd of head speed */
+ /* Head speeds for various densities */
#define _300X 1
#define _600X 2
#define _1200X 5
#define PEN_X 9
- /* Index of 2 byte pen selectors */
+ /* Index of 2 byte pen selectors */
#define BLACK0 1
#define BLACK1 1
#define COLOUR0 2
#define COLOUR1 0
#define NOZZLE_COUNT_X 11
- /* Index of nozzle count selector */
+ /* Index of nozzle count selector */
#define _192NOZZLES 0x18
#define _208NOZZLES 0x1a
#define UNKNOWN1_X 12
- /* Index of an unknown byte */
+ /* Index of an unknown byte */
#define UNKNOWN1VAL 0
#define NUM_COLUMNS_X 13
- /* Index in swipe command of 2 byte */
- /* column count */
+ /* Index in swipe command of 2 byte */
+ /* column count */
#define _1ST_COLUMN_X 15
- /* Index in swipe command of 2 byte */
- /* first column horizontal offset */
+ /* Index in swipe command of 2 byte */
+ /* first column horizontal offset */
#define LAST_COLUMN_X 17
- /* Index in swipe command of 2 byte */
- /* last column horizontal offset */
+ /* Index in swipe command of 2 byte */
+ /* last column horizontal offset */
#define SWIPE_HDR_END_X 19
#define SWIPE_HDR_END_LEN 7
#define SWIPE_HDR_END 0, 0, '+', 'p', 'b', 'w', 1
- /* Final byte sequence of swipe cmd header */
+ /* Final byte sequence of swipe cmd header */
#define SWIPE_HDR_LEN ( SWIPE_HDR_END_X + SWIPE_HDR_END_LEN )
@@ -591,7 +588,7 @@ const char Author[] =
#define LO_PEN 0
#define HI_PEN 1
- /* Colour defines for lx5000 black printer */
+ /* Colour defines for lx5000 black printer */
# define NUM_COMPONENTS_BLK 1
# define BITS_PER_PIXEL_BLK 1
@@ -600,7 +597,7 @@ const char Author[] =
# define DITHER_GREYS_BLK 2
# define DITHER_COLOURS_BLK 0
- /* Colour defines for lx5000 colour printer */
+ /* Colour defines for lx5000 colour printer */
# define NUM_COMPONENTS_CMY 4
# define BITS_PER_PIXEL_CMY 4
# define MAX_GREY_CMY 1
@@ -615,8 +612,8 @@ const char Author[] =
# define LAST_CMY_COLOUR CYAN_X
#define BPP BITS_PER_PIXEL_CMY
- /* N.B. This is only required for
- processCMYKline */
+ /* N.B. This is only required for
+ processCMYKline */
# define PIXEL_MASK (( 1 << BPP ) - 1 )
# define INITIAL_PIXEL_SHIFT ( ( sizeof( uchar ) * 8 ) - BPP )
@@ -631,12 +628,12 @@ const char Author[] =
#define DEF_LINE_INCREMENT 1
/* !!!!!!!!!!!!!!!!!!!!! WARNING, WARNING, WILL ROBINSON !!!!!!!!!!!!!!!!!!!!*/
- /* If BPP ever exceeds 8, this will break
- badly, as will the whole of processCMYKline.
- PIXELS_PER_BYTE is used when skipping over
- empty bytes in processCMYKline(). Each
- empty scanline byte skips over this many
- bits in the colourBufs. */
+ /* If BPP ever exceeds 8, this will break
+ badly, as will the whole of processCMYKline.
+ PIXELS_PER_BYTE is used when skipping over
+ empty bytes in processCMYKline(). Each
+ empty scanline byte skips over this many
+ bits in the colourBufs. */
#define PIXELS_PER_BYTE (8 / BPP)
#define COLOUR_MASK (( 1 << ( BITS_PER_COLOUR ) ) - 1 )
@@ -656,24 +653,23 @@ const char Author[] =
************************************************************************/
#define FILL_SWIPE_HEADER( swipeHdr, len, dir, speed, pen0, pen1, nozzles, \
- unknown, numcols, firstcol, lastcol ) \
- swipeHdr[ CMDLEN_X ] = ( ( len >> 24 ) & 0xff ); \
- swipeHdr[ CMDLEN_X + 1 ] = ( ( len >> 16 ) & 0xff ); \
- swipeHdr[ CMDLEN_X + 2 ] = ( ( len >> 8 ) & 0xff ); \
- swipeHdr[ CMDLEN_X + 3 ] = ( len & 0xff ); \
- swipeHdr[ DIRECTION_X ] = dir; \
- swipeHdr[ HEADSPEED_X ] = speed; \
- swipeHdr[ PEN_X ] = pen0; \
- swipeHdr[ PEN_X + 1 ] = pen1; \
- swipeHdr[ NOZZLE_COUNT_X ] = nozzles; \
- swipeHdr[ UNKNOWN1_X ] = unknown; \
- swipeHdr[ NUM_COLUMNS_X ] = ( numcols >> 8 ); \
- swipeHdr[ NUM_COLUMNS_X + 1 ] = ( numcols & 0xff ); \
- swipeHdr[ _1ST_COLUMN_X ] = ( firstcol >> 8 ); \
- swipeHdr[ _1ST_COLUMN_X + 1 ] = ( firstcol & 0xff ); \
- swipeHdr[ LAST_COLUMN_X ] = ( lastcol >> 8 ); \
- swipeHdr[ LAST_COLUMN_X + 1 ] = ( lastcol & 0xff )
-
+ unknown, numcols, firstcol, lastcol ) \
+ swipeHdr[ CMDLEN_X ] = ( ( len >> 24 ) & 0xff ); \
+ swipeHdr[ CMDLEN_X + 1 ] = ( ( len >> 16 ) & 0xff ); \
+ swipeHdr[ CMDLEN_X + 2 ] = ( ( len >> 8 ) & 0xff ); \
+ swipeHdr[ CMDLEN_X + 3 ] = ( len & 0xff ); \
+ swipeHdr[ DIRECTION_X ] = dir; \
+ swipeHdr[ HEADSPEED_X ] = speed; \
+ swipeHdr[ PEN_X ] = pen0; \
+ swipeHdr[ PEN_X + 1 ] = pen1; \
+ swipeHdr[ NOZZLE_COUNT_X ] = nozzles; \
+ swipeHdr[ UNKNOWN1_X ] = unknown; \
+ swipeHdr[ NUM_COLUMNS_X ] = ( numcols >> 8 ); \
+ swipeHdr[ NUM_COLUMNS_X + 1 ] = ( numcols & 0xff ); \
+ swipeHdr[ _1ST_COLUMN_X ] = ( firstcol >> 8 ); \
+ swipeHdr[ _1ST_COLUMN_X + 1 ] = ( firstcol & 0xff ); \
+ swipeHdr[ LAST_COLUMN_X ] = ( lastcol >> 8 ); \
+ swipeHdr[ LAST_COLUMN_X + 1 ] = ( lastcol & 0xff )
/************************************************************************
* Macros to manipulate bit pointers in bitBuf & scanPixels structs *
@@ -682,13 +678,13 @@ const char Author[] =
#define INC_BIT( bitPtr ) \
do { \
if ( ! ((bitPtr).xBit >>= 1 )) \
- { (bitPtr).xByte++ ; (bitPtr).xBit = 0x80; } \
+ { (bitPtr).xByte++ ; (bitPtr).xBit = 0x80; } \
} while (0)
#define DEC_BIT( bitPtr ) \
do { \
if ( ! ( (bitPtr).xBit = (( (bitPtr).xBit << 1 ) & 0xff ))) \
- { (bitPtr).xByte-- ; (bitPtr).xBit = 1; } \
+ { (bitPtr).xByte-- ; (bitPtr).xBit = 1; } \
} while (0)
/************************************************************************
@@ -697,32 +693,32 @@ do { \
#define lx5000_proctab(get_params, put_params, map_color_rgb, map_cmyk_color)\
{ gdev_prn_open,\
- gx_default_get_initial_matrix,\
- NULL, /* sync_output */\
- gdev_prn_output_page,\
- gdev_prn_close,\
- NULL, /* map_rgb_color */\
- map_color_rgb,\
- NULL, /* fill_rectangle */\
- NULL, /* tile_rectangle */\
- NULL, /* copy_mono */\
- NULL, /* copy_color */\
- NULL, /* draw_line */\
- NULL, /* get_bits */\
- get_params,\
- put_params,\
- map_cmyk_color,\
- NULL, /* get_xfont_procs */\
- NULL, /* get_xfont_device */\
- NULL, /* map_rgb_alpha_color */\
- gx_page_device_get_page_device /* get_page_device */\
+ gx_default_get_initial_matrix,\
+ NULL, /* sync_output */\
+ gdev_prn_output_page,\
+ gdev_prn_close,\
+ NULL, /* map_rgb_color */\
+ map_color_rgb,\
+ NULL, /* fill_rectangle */\
+ NULL, /* tile_rectangle */\
+ NULL, /* copy_mono */\
+ NULL, /* copy_color */\
+ NULL, /* draw_line */\
+ NULL, /* get_bits */\
+ get_params,\
+ put_params,\
+ map_cmyk_color,\
+ NULL, /* get_xfont_procs */\
+ NULL, /* get_xfont_device */\
+ NULL, /* map_rgb_alpha_color */\
+ gx_page_device_get_page_device /* get_page_device */\
}
/************************************************************************
* T Y P E D E F S E N U M S & E X T E R N A L S T O R A G E *
************************************************************************/
- /* The procedure descriptors */
- /* declare functions */
+ /* The procedure descriptors */
+ /* declare functions */
static dev_proc_print_page(lx5000_print_page);
static dev_proc_get_params(lx5000_get_params);
static dev_proc_put_params(lx5000_put_params);
@@ -730,17 +726,17 @@ static dev_proc_put_params(lx5000_put_params);
static dev_proc_map_cmyk_color(lx5000_map_cmyk_color);
static dev_proc_map_color_rgb(lx5000_map_color_rgb);
-static const gx_device_procs lx5000_procs =
+static const gx_device_procs lx5000_procs =
lx5000_proctab(
lx5000_get_params,
- lx5000_put_params,
- lx5000_map_color_rgb,
- lx5000_map_cmyk_color
- );
-
- /* The device descriptors */
- /* define a subclass containing useful state */
- /* a sub-class of gx_device_printer */
+ lx5000_put_params,
+ lx5000_map_color_rgb,
+ lx5000_map_cmyk_color
+ );
+
+ /* The device descriptors */
+ /* define a subclass containing useful state */
+ /* a sub-class of gx_device_printer */
typedef struct lx5000_device_s {
gx_device_common;
gx_prn_device_common;
@@ -752,22 +748,21 @@ typedef struct lx5000_device_s {
int lineIncrement; /* 1 for 600Y; 2 for 1200Y */
int scanLineBytes; /* Returned by GS */
int penLineBytes; /* When scanline colour elements are each
- reduced to a single bit, this is the result-
- ing line length in bytes. */
+ reduced to a single bit, this is the result-
+ ing line length in bytes. */
int penLineLen; /* penLineBytes + BOL + EOL padding */
int penBufSize; /* penLineLen * no. of lines */
int swipeBufSize; /* calculated size of a swipe command buffer */
bool isCMYK;
} lx5000_device;
- /* Define a structure for a pointer to an */
- /* individual bit in a scanline */
+ /* Define a structure for a pointer to an */
+ /* individual bit in a scanline */
typedef struct bufBit_s {
byte *xByte; /* Pointer to byte in buffer */
uchar xBit; /* Mask for invidual bit in byte */
} bufBit;
-
typedef struct penData_s {
int topLine; /* Top printable line of this pen */
int bottomLine; /* Bottom printable line of this pen */
@@ -779,40 +774,40 @@ typedef struct penData_s {
int finalLine;
} penData;
- /* Structure for extracting pixels from the
- initial scan line, which must be int
- aligned. */
+ /* Structure for extracting pixels from the
+ initial scan line, which must be int
+ aligned. */
typedef struct scanPixels_s {
uchar *scanByte; /* Pointer to a byte in the scan buffer */
int pixShift; /* Shift required to get next pixel to */
} scanPixels; /* the LSBits of the word. */
- /* Standard lx5000 device */
+ /* Standard lx5000 device */
lx5000_device far_data gs_lx5000_device = {
prn_device_margins_body
- ( lx5000_device,
- lx5000_procs,
- "lx5000",
- DEFAULT_WIDTH_10THS,
- DEFAULT_HEIGHT_10THS,
- LX5000_XDPI, /* x dpi */
- LX5000_YDPI, /* y dpi */
- /* Offset inches from page left to 0,0 */
- LX5000_XOFFSET_TO_0_0,
- /* Offset inches from page top to 0,0 */
- LX5000_YOFFSET_TO_0_0,
- LX5000_LEFT_HWMARGIN_INS, /* margins */
- LX5000_BOTTOM_HWMARGIN_INS,
- LX5000_RIGHT_HWMARGIN_INS,
- LX5000_TOP_HWMARGIN_INS,
- NUM_COMPONENTS_CMY, /* colour info */
- BITS_PER_PIXEL_CMY, /* " */
- MAX_GREY_CMY, /* " */
- MAX_RGB_CMY, /* " */
- DITHER_GREYS_CMY, /* " */
- DITHER_COLOURS_CMY, /* " */
- lx5000_print_page
- ),
+ ( lx5000_device,
+ lx5000_procs,
+ "lx5000",
+ DEFAULT_WIDTH_10THS,
+ DEFAULT_HEIGHT_10THS,
+ LX5000_XDPI, /* x dpi */
+ LX5000_YDPI, /* y dpi */
+ /* Offset inches from page left to 0,0 */
+ LX5000_XOFFSET_TO_0_0,
+ /* Offset inches from page top to 0,0 */
+ LX5000_YOFFSET_TO_0_0,
+ LX5000_LEFT_HWMARGIN_INS, /* margins */
+ LX5000_BOTTOM_HWMARGIN_INS,
+ LX5000_RIGHT_HWMARGIN_INS,
+ LX5000_TOP_HWMARGIN_INS,
+ NUM_COMPONENTS_CMY, /* colour info */
+ BITS_PER_PIXEL_CMY, /* " */
+ MAX_GREY_CMY, /* " */
+ MAX_RGB_CMY, /* " */
+ DITHER_GREYS_CMY, /* " */
+ DITHER_COLOURS_CMY, /* " */
+ lx5000_print_page
+ ),
ALIGN_A_DEF, /* default(!) horizontal pen alignment */
ALIGN_B_DEF, /* default(!) vertical pen alignment */
HEADSEP_DEF, /* default headSeparation value */
@@ -829,19 +824,19 @@ lx5000_device far_data gs_lx5000_device = {
static const gx_device_color_info color_info_cmy =
dci_values(NUM_COMPONENTS_CMY,
- BITS_PER_PIXEL_CMY,
- MAX_GREY_CMY,
- MAX_RGB_CMY,
- DITHER_GREYS_CMY,
- DITHER_COLOURS_CMY);
+ BITS_PER_PIXEL_CMY,
+ MAX_GREY_CMY,
+ MAX_RGB_CMY,
+ DITHER_GREYS_CMY,
+ DITHER_COLOURS_CMY);
static const gx_device_color_info color_info_blk =
dci_values(NUM_COMPONENTS_BLK,
- BITS_PER_PIXEL_BLK,
- MAX_GREY_BLK,
- MAX_RGB_BLK,
- DITHER_GREYS_BLK,
- DITHER_COLOURS_BLK);
+ BITS_PER_PIXEL_BLK,
+ MAX_GREY_BLK,
+ MAX_RGB_BLK,
+ DITHER_GREYS_BLK,
+ DITHER_COLOURS_BLK);
/************************************************************************
************************************************************************
@@ -859,15 +854,15 @@ static const gx_device_color_info color_info_blk =
*----------------------------------------------------------------------*/
static void
initPenConstants( lx5000_device *lx5000dev,
- penData pens[NUM_COLOURS][PENS_PER_COLOUR] )
+ penData pens[NUM_COLOURS][PENS_PER_COLOUR] )
{
- /* Indexed by pensPerColour. */
+ /* Indexed by pensPerColour. */
static const int nozzleCount[ NUM_COLOURS ][ PENS_PER_COLOUR + 1 ] =
{
- { -1, BLACK_NOZZLES, (BLACK_NOZZLES / 2) },
- { -1, _1COLOUR_NOZZLES, (_1COLOUR_NOZZLES / 2) },
- { -1, _1COLOUR_NOZZLES, (_1COLOUR_NOZZLES / 2) },
- { -1, _1COLOUR_NOZZLES, (_1COLOUR_NOZZLES / 2) }
+ { -1, BLACK_NOZZLES, (BLACK_NOZZLES / 2) },
+ { -1, _1COLOUR_NOZZLES, (_1COLOUR_NOZZLES / 2) },
+ { -1, _1COLOUR_NOZZLES, (_1COLOUR_NOZZLES / 2) },
+ { -1, _1COLOUR_NOZZLES, (_1COLOUR_NOZZLES / 2) }
};
int colour, pen;
@@ -875,89 +870,89 @@ initPenConstants( lx5000_device *lx5000dev,
pens[YELLOW_X][LO_PEN].initialBottomLine = -1;
pens[MAGENTA_X][LO_PEN].initialBottomLine =
- pens[YELLOW_X][LO_PEN].initialBottomLine
- - COLOUR_PEN_DIFF;
+ pens[YELLOW_X][LO_PEN].initialBottomLine
+ - COLOUR_PEN_DIFF;
pens[CYAN_X][LO_PEN].initialBottomLine =
- pens[MAGENTA_X][LO_PEN].initialBottomLine
- - COLOUR_PEN_DIFF;
+ pens[MAGENTA_X][LO_PEN].initialBottomLine
+ - COLOUR_PEN_DIFF;
pens[BLACK_X][LO_PEN].initialBottomLine =
- pens[YELLOW_X][LO_PEN].initialBottomLine
- - COLOUR_PEN_GAP
- + ( SWIPE_WORD_BITS - lx5000dev->alignB );
+ pens[YELLOW_X][LO_PEN].initialBottomLine
+ - COLOUR_PEN_GAP
+ + ( SWIPE_WORD_BITS - lx5000dev->alignB );
for ( colour = 0; colour < NUM_COLOURS; colour++ )
{
- pens[colour][LO_PEN].bottomToBottomYellow
- = pens[YELLOW_X][LO_PEN].initialBottomLine
- - pens[colour][LO_PEN].initialBottomLine;
+ pens[colour][LO_PEN].bottomToBottomYellow
+ = pens[YELLOW_X][LO_PEN].initialBottomLine
+ - pens[colour][LO_PEN].initialBottomLine;
}
if ( pensPerColour == 1 )
{
- pens[BLACK_X][LO_PEN].topToBottomYellow =
- BLK_COLOUR_NOZZLES + COLOUR_PEN_GAP
- + lx5000dev->alignB - 1;
- pens[YELLOW_X][LO_PEN].topToBottomYellow = _1COLOUR_NOZZLES - 1;
- pens[MAGENTA_X][LO_PEN].topToBottomYellow =
- pens[YELLOW_X][LO_PEN].topToBottomYellow
- + COLOUR_PEN_DIFF;
- pens[CYAN_X][LO_PEN].topToBottomYellow =
- pens[MAGENTA_X][LO_PEN].topToBottomYellow
- + COLOUR_PEN_DIFF;
-
- for ( colour = 0; colour < NUM_COLOURS; colour++ )
- {
- pens[colour][HI_PEN].topToBottomYellow
- = pens[colour][LO_PEN].topToBottomYellow;
- pens[colour][HI_PEN].initialBottomLine
- = pens[colour][LO_PEN].initialBottomLine;
- pens[colour][HI_PEN].bottomToBottomYellow
- = pens[colour][LO_PEN].bottomToBottomYellow;
- }
+ pens[BLACK_X][LO_PEN].topToBottomYellow =
+ BLK_COLOUR_NOZZLES + COLOUR_PEN_GAP
+ + lx5000dev->alignB - 1;
+ pens[YELLOW_X][LO_PEN].topToBottomYellow = _1COLOUR_NOZZLES - 1;
+ pens[MAGENTA_X][LO_PEN].topToBottomYellow =
+ pens[YELLOW_X][LO_PEN].topToBottomYellow
+ + COLOUR_PEN_DIFF;
+ pens[CYAN_X][LO_PEN].topToBottomYellow =
+ pens[MAGENTA_X][LO_PEN].topToBottomYellow
+ + COLOUR_PEN_DIFF;
+
+ for ( colour = 0; colour < NUM_COLOURS; colour++ )
+ {
+ pens[colour][HI_PEN].topToBottomYellow
+ = pens[colour][LO_PEN].topToBottomYellow;
+ pens[colour][HI_PEN].initialBottomLine
+ = pens[colour][LO_PEN].initialBottomLine;
+ pens[colour][HI_PEN].bottomToBottomYellow
+ = pens[colour][LO_PEN].bottomToBottomYellow;
+ }
}
else /* pensPerColour > 1 */
{
- pens[BLACK_X][HI_PEN].topToBottomYellow =
- BLK_COLOUR_NOZZLES + COLOUR_PEN_GAP
- + lx5000dev->alignB - 1;
- pens[BLACK_X][LO_PEN].topToBottomYellow =
- pens[BLACK_X][HI_PEN].topToBottomYellow
- - nozzleCount[BLACK_X][pensPerColour];
- pens[YELLOW_X][HI_PEN].topToBottomYellow = _1COLOUR_NOZZLES - 1;
- pens[YELLOW_X][LO_PEN].topToBottomYellow =
- pens[YELLOW_X][HI_PEN].topToBottomYellow
- - nozzleCount[YELLOW_X][pensPerColour];
- pens[MAGENTA_X][HI_PEN].topToBottomYellow =
- pens[YELLOW_X][HI_PEN].topToBottomYellow
- + COLOUR_PEN_DIFF;
- pens[MAGENTA_X][LO_PEN].topToBottomYellow =
- pens[MAGENTA_X][HI_PEN].topToBottomYellow
- -nozzleCount[MAGENTA_X][pensPerColour];
- pens[CYAN_X][HI_PEN].topToBottomYellow =
- pens[MAGENTA_X][HI_PEN].topToBottomYellow
- + COLOUR_PEN_DIFF;
- pens[CYAN_X][LO_PEN].topToBottomYellow =
- pens[CYAN_X][HI_PEN].topToBottomYellow
- - nozzleCount[CYAN_X][pensPerColour];
-
- for ( colour = 0; colour < NUM_COLOURS; colour++ )
- {
- pens[colour][HI_PEN].bottomToBottomYellow =
- pens[colour][LO_PEN].bottomToBottomYellow
- + nozzleCount[colour][pensPerColour];
- pens[colour][HI_PEN].initialBottomLine =
- pens[colour][LO_PEN].initialBottomLine
- - nozzleCount[colour][pensPerColour];
- }
+ pens[BLACK_X][HI_PEN].topToBottomYellow =
+ BLK_COLOUR_NOZZLES + COLOUR_PEN_GAP
+ + lx5000dev->alignB - 1;
+ pens[BLACK_X][LO_PEN].topToBottomYellow =
+ pens[BLACK_X][HI_PEN].topToBottomYellow
+ - nozzleCount[BLACK_X][pensPerColour];
+ pens[YELLOW_X][HI_PEN].topToBottomYellow = _1COLOUR_NOZZLES - 1;
+ pens[YELLOW_X][LO_PEN].topToBottomYellow =
+ pens[YELLOW_X][HI_PEN].topToBottomYellow
+ - nozzleCount[YELLOW_X][pensPerColour];
+ pens[MAGENTA_X][HI_PEN].topToBottomYellow =
+ pens[YELLOW_X][HI_PEN].topToBottomYellow
+ + COLOUR_PEN_DIFF;
+ pens[MAGENTA_X][LO_PEN].topToBottomYellow =
+ pens[MAGENTA_X][HI_PEN].topToBottomYellow
+ -nozzleCount[MAGENTA_X][pensPerColour];
+ pens[CYAN_X][HI_PEN].topToBottomYellow =
+ pens[MAGENTA_X][HI_PEN].topToBottomYellow
+ + COLOUR_PEN_DIFF;
+ pens[CYAN_X][LO_PEN].topToBottomYellow =
+ pens[CYAN_X][HI_PEN].topToBottomYellow
+ - nozzleCount[CYAN_X][pensPerColour];
+
+ for ( colour = 0; colour < NUM_COLOURS; colour++ )
+ {
+ pens[colour][HI_PEN].bottomToBottomYellow =
+ pens[colour][LO_PEN].bottomToBottomYellow
+ + nozzleCount[colour][pensPerColour];
+ pens[colour][HI_PEN].initialBottomLine =
+ pens[colour][LO_PEN].initialBottomLine
+ - nozzleCount[colour][pensPerColour];
+ }
}
for ( colour = 0; colour < NUM_COLOURS; colour++ )
{
- for ( pen = 0; pen < PENS_PER_COLOUR; pen++ )
- {
- pens[colour][pen].finalLine =
- ( lx5000dev->height ) + pens[colour][pen].topToBottomYellow;
- }
+ for ( pen = 0; pen < PENS_PER_COLOUR; pen++ )
+ {
+ pens[colour][pen].finalLine =
+ ( lx5000dev->height ) + pens[colour][pen].topToBottomYellow;
+ }
}
}
@@ -974,7 +969,7 @@ pageInit( unsigned int alignA, unsigned int alignB, FILE *prn_stream )
page_init[ALIGN_A_OFFSET] = (uchar)alignA;
page_init[ALIGN_B_OFFSET] = (uchar)alignB;
-
+
fwrite( page_init, 1, sizeof( page_init ), prn_stream );
}
@@ -986,12 +981,12 @@ static void
pageEnd( FILE *prn_stream )
{
static const char page_end[] = {
- 0x1b,'*', 7, 0x65
+ 0x1b,'*', 7, 0x65
};
fwrite( page_end, 1, sizeof( page_end ), prn_stream );
- /* Do it twice - that's what the Windows */
- /* driver for the 5000 does */
+ /* Do it twice - that's what the Windows */
+ /* driver for the 5000 does */
fwrite( page_end, 1, sizeof( page_end ), prn_stream );
}
@@ -1001,11 +996,11 @@ pageEnd( FILE *prn_stream )
*----------------------------------------------------------------------*/
static void
feedPaper( lx5000_device *lx5000dev, int newLine, int *currentLine,
- penData pens[NUM_COLOURS][PENS_PER_COLOUR],
- FILE *prn_stream )
+ penData pens[NUM_COLOURS][PENS_PER_COLOUR],
+ FILE *prn_stream )
{
static const char feed_paper[] = {
- 0x1b, '*', 3
+ 0x1b, '*', 3
};
ushort _1200ths;
@@ -1013,28 +1008,27 @@ feedPaper( lx5000_device *lx5000dev, int newLine, int *currentLine,
if ( newLine >= *currentLine )
{
- _1200ths = (ushort)(( newLine - *currentLine ) * FEED_FACTOR );
- fwrite( feed_paper, 1, sizeof( feed_paper ), prn_stream );
- putc( _1200ths >> 8 , prn_stream);
- putc( _1200ths & 0xff, prn_stream );
-
- *currentLine = newLine;
-
- for ( colour = 0;
- colour < lx5000dev->color_info.num_components;
- colour++ )
- for ( pen = 0; pen < lx5000dev->pensPerColour; pen++ )
- {
- pens[colour][pen].topLine =
- newLine - pens[colour][pen].topToBottomYellow;
- pens[colour][pen].bottomLine =
- newLine - pens[colour][pen].bottomToBottomYellow;
- }
+ _1200ths = (ushort)(( newLine - *currentLine ) * FEED_FACTOR );
+ fwrite( feed_paper, 1, sizeof( feed_paper ), prn_stream );
+ putc( _1200ths >> 8 , prn_stream);
+ putc( _1200ths & 0xff, prn_stream );
+
+ *currentLine = newLine;
+
+ for ( colour = 0;
+ colour < lx5000dev->color_info.num_components;
+ colour++ )
+ for ( pen = 0; pen < lx5000dev->pensPerColour; pen++ )
+ {
+ pens[colour][pen].topLine =
+ newLine - pens[colour][pen].topToBottomYellow;
+ pens[colour][pen].bottomLine =
+ newLine - pens[colour][pen].bottomToBottomYellow;
+ }
}
}
-
/*----------------------------------------------------------------------*
* g e t C o l o u r B u f s ( ) *
*----------------------------------------------------------------------*
@@ -1062,11 +1056,11 @@ feedPaper( lx5000_device *lx5000dev, int newLine, int *currentLine,
*----------------------------------------------------------------------*/
static int
getColourBufs( lx5000_device *lx5000dev,
- byte **lineBufferPtr, byte *colourBufPtrs[],
- byte **swipeBufPtr, bool allocate )
+ byte **lineBufferPtr, byte *colourBufPtrs[],
+ byte **swipeBufPtr, bool allocate )
{
static byte *colourBufs[ NUM_COLOURS ];
- /* Only an array of pointers; OK if too big */
+ /* Only an array of pointers; OK if too big */
static byte *lineBuffer = NULL;
static byte *swipeBuf = NULL;
@@ -1076,124 +1070,123 @@ getColourBufs( lx5000_device *lx5000dev,
if ( allocate )
{
- if ( lineBuffer == NULL )
- {
- /* Initialise the pen buffers */
- for ( colour = 0; colour < numColours; colour++ )
- colourBufs[ colour ] = NULL;
-
- /*---------------------------------------------------------------*
- Derive the size of a colour buffer line: If the number of
- components is one and the number of bits per pixel is one, then
- there is only one bit per pixel in the scan line, so the colour
- buffer line is the same size.
-
- Otherwise, reduce each gx_color_index element in the scan line to
- one bit in the penprint buffer.
- *--------------------------------------------------------------*/
-
- if (lx5000dev->color_info.num_components > GX_DEVICE_COLOR_MAX_COMPONENTS)
- return_error(gs_error_limitcheck);
-
- lx5000dev->scanLineBytes = gdev_mem_bytes_per_scan_line(
- (gx_device *)lx5000dev );
- lx5000dev->penLineBytes =
- ( lx5000dev->color_info.num_components == 1
- && lx5000dev->color_info.depth == 1 )
- ? lx5000dev->scanLineBytes
- : ( lx5000dev->scanLineBytes / lx5000dev->color_info.num_components);
-
- lx5000dev->penLineLen =
- lx5000dev->penLineBytes + ( LINE_PAD_BYTES * 2);
-
- lx5000dev->penBufSize
- = lx5000dev->penLineLen * COLOUR_BUF_LINES;
-
- /* swipeBuf size:
- * No. of columns = No. of bits in the linebuf
- * Bits per column = maximum swipe height
- * Bytes per column = Bits per column / 8 + 2 byte directory
- * Total bytes = Bytes/column * no. of columns + header bytes
- */
- lx5000dev->swipeBufSize =
- ((lx5000dev->penLineLen * 8)
- * ((BLACK_NOZZLES / 8) + 2) + SWIPE_HDR_LEN);
-
- /* Allocate a buffer for a single scan line */
- lineBuffer = (byte *)gs_alloc_byte_array
- ( gs_lib_ctx_get_non_gc_memory_t(), lx5000dev->scanLineBytes, 1,
- "lx5000_print_page(lineBuffer)" );
-
- swipeBuf = (byte *)gs_alloc_byte_array
- ( gs_lib_ctx_get_non_gc_memory_t(), lx5000dev->swipeBufSize, 1,
- "lx5000_print_page(swipeBuf)" );
-
- for ( colour = 0 ; colour < numColours; colour++ )
- {
- if ( ( colourBufs[colour] =
- (byte *)gs_alloc_byte_array
- ( gs_lib_ctx_get_non_gc_memory_t(), lx5000dev->penBufSize, 1,
- "lx5000_print_page(colourBufs)"
- )
- ) == NULL )
- {
- colourBufNull = 1;
- colour = numColours;
- }
- }
- /* Check allocations */
- if ( lineBuffer == NULL || colourBufNull || swipeBuf == NULL ) {
- getColourBufs( lx5000dev, lineBufferPtr, colourBufPtrs,
- swipeBufPtr, DEALLOCATE );
- return_error( gs_error_VMerror );
- }
- }
- /* Clear the black buffer, iff ! isCMYK. If CMYK, scan lines are
- processed by processCMYKlines(), and buffer lines are cleared
- individually, before a new scan line is processed. As part of this
- clearing, the line EOL and BOL pads are also cleared.
- If ! CMYK, the black-only scan line is read or copied directly
- into the black buffer, without clearing the buffer. Therefore, the
- line pad regions must either be cleared individually for each line
- processed, or cleared once when the buffer is allocated.
- */
- if ( ! lx5000dev->isCMYK )
- memset( colourBufs[BLACK_X], 0, lx5000dev->penBufSize );
-
- /* Return the values */
- *lineBufferPtr = lineBuffer;
- *swipeBufPtr = swipeBuf;
- for ( colour = 0; colour < numColours; colour++ )
- colourBufPtrs[colour] = colourBufs[colour];
-
- return 0;
+ if ( lineBuffer == NULL )
+ {
+ /* Initialise the pen buffers */
+ for ( colour = 0; colour < numColours; colour++ )
+ colourBufs[ colour ] = NULL;
+
+ /*---------------------------------------------------------------*
+ Derive the size of a colour buffer line: If the number of
+ components is one and the number of bits per pixel is one, then
+ there is only one bit per pixel in the scan line, so the colour
+ buffer line is the same size.
+
+ Otherwise, reduce each gx_color_index element in the scan line to
+ one bit in the penprint buffer.
+ *--------------------------------------------------------------*/
+
+ if (lx5000dev->color_info.num_components > GX_DEVICE_COLOR_MAX_COMPONENTS)
+ return_error(gs_error_limitcheck);
+
+ lx5000dev->scanLineBytes = gdev_mem_bytes_per_scan_line(
+ (gx_device *)lx5000dev );
+ lx5000dev->penLineBytes =
+ ( lx5000dev->color_info.num_components == 1
+ && lx5000dev->color_info.depth == 1 )
+ ? lx5000dev->scanLineBytes
+ : ( lx5000dev->scanLineBytes / lx5000dev->color_info.num_components);
+
+ lx5000dev->penLineLen =
+ lx5000dev->penLineBytes + ( LINE_PAD_BYTES * 2);
+
+ lx5000dev->penBufSize
+ = lx5000dev->penLineLen * COLOUR_BUF_LINES;
+
+ /* swipeBuf size:
+ * No. of columns = No. of bits in the linebuf
+ * Bits per column = maximum swipe height
+ * Bytes per column = Bits per column / 8 + 2 byte directory
+ * Total bytes = Bytes/column * no. of columns + header bytes
+ */
+ lx5000dev->swipeBufSize =
+ ((lx5000dev->penLineLen * 8)
+ * ((BLACK_NOZZLES / 8) + 2) + SWIPE_HDR_LEN);
+
+ /* Allocate a buffer for a single scan line */
+ lineBuffer = (byte *)gs_alloc_byte_array
+ ( gs_lib_ctx_get_non_gc_memory_t(), lx5000dev->scanLineBytes, 1,
+ "lx5000_print_page(lineBuffer)" );
+
+ swipeBuf = (byte *)gs_alloc_byte_array
+ ( gs_lib_ctx_get_non_gc_memory_t(), lx5000dev->swipeBufSize, 1,
+ "lx5000_print_page(swipeBuf)" );
+
+ for ( colour = 0 ; colour < numColours; colour++ )
+ {
+ if ( ( colourBufs[colour] =
+ (byte *)gs_alloc_byte_array
+ ( gs_lib_ctx_get_non_gc_memory_t(), lx5000dev->penBufSize, 1,
+ "lx5000_print_page(colourBufs)"
+ )
+ ) == NULL )
+ {
+ colourBufNull = 1;
+ colour = numColours;
+ }
+ }
+ /* Check allocations */
+ if ( lineBuffer == NULL || colourBufNull || swipeBuf == NULL ) {
+ getColourBufs( lx5000dev, lineBufferPtr, colourBufPtrs,
+ swipeBufPtr, DEALLOCATE );
+ return_error( gs_error_VMerror );
+ }
+ }
+ /* Clear the black buffer, iff ! isCMYK. If CMYK, scan lines are
+ processed by processCMYKlines(), and buffer lines are cleared
+ individually, before a new scan line is processed. As part of this
+ clearing, the line EOL and BOL pads are also cleared.
+ If ! CMYK, the black-only scan line is read or copied directly
+ into the black buffer, without clearing the buffer. Therefore, the
+ line pad regions must either be cleared individually for each line
+ processed, or cleared once when the buffer is allocated.
+ */
+ if ( ! lx5000dev->isCMYK )
+ memset( colourBufs[BLACK_X], 0, lx5000dev->penBufSize );
+
+ /* Return the values */
+ *lineBufferPtr = lineBuffer;
+ *swipeBufPtr = swipeBuf;
+ for ( colour = 0; colour < numColours; colour++ )
+ colourBufPtrs[colour] = colourBufs[colour];
+
+ return 0;
}
else /* Deallocate the buffers */
{
- for ( colour = 0; colour < numColours; colour++ )
- {
- if ( colourBufs[colour] != NULL )
- gs_free_object( gs_lib_ctx_get_non_gc_memory_t(),
- (char *)colourBufs[colour],
- "lx5000_print_page(colourBufs)" );
- colourBufs[ colour ] = NULL;
- colourBufPtrs[ colour ] = NULL;
- }
- if ( swipeBuf != NULL )
- gs_free_object( gs_lib_ctx_get_non_gc_memory_t(),
- (char *)swipeBuf, "lx5000_print_page(swipeBuf)" );
- swipeBuf = NULL;
- *swipeBufPtr = NULL;
- if ( lineBuffer != NULL )
- gs_free_object( gs_lib_ctx_get_non_gc_memory_t(),
- (char *)lineBuffer, "lx5000_print_page(lineBuffer)" );
- lineBuffer = NULL;
- *lineBufferPtr = NULL;
- return 0;
+ for ( colour = 0; colour < numColours; colour++ )
+ {
+ if ( colourBufs[colour] != NULL )
+ gs_free_object( gs_lib_ctx_get_non_gc_memory_t(),
+ (char *)colourBufs[colour],
+ "lx5000_print_page(colourBufs)" );
+ colourBufs[ colour ] = NULL;
+ colourBufPtrs[ colour ] = NULL;
+ }
+ if ( swipeBuf != NULL )
+ gs_free_object( gs_lib_ctx_get_non_gc_memory_t(),
+ (char *)swipeBuf, "lx5000_print_page(swipeBuf)" );
+ swipeBuf = NULL;
+ *swipeBufPtr = NULL;
+ if ( lineBuffer != NULL )
+ gs_free_object( gs_lib_ctx_get_non_gc_memory_t(),
+ (char *)lineBuffer, "lx5000_print_page(lineBuffer)" );
+ lineBuffer = NULL;
+ *lineBufferPtr = NULL;
+ return 0;
}
}
-
/*----------------------------------------------------------------------*
* p r o c e s s C M Y K l i n e ( ) *
*----------------------------------------------------------------------*
@@ -1203,17 +1196,17 @@ getColourBufs( lx5000_device *lx5000dev,
N.B. The empty indicator for each line for each pen buffer must also be
set by this procedure.
-
+
Things like dithering may well end up in here.
*----------------------------------------------------------------------*/
static void
processCMYKline( lx5000_device *lx5000dev, int linenum,
- byte *lineBuffer, byte *scanLine,
- byte *colourBufs[NUM_COLOURS],
- bufBit
- colourLines[NUM_COLOURS][PENS_PER_COLOUR][COLOUR_BUF_LINES],
- penData pens[NUM_COLOURS][PENS_PER_COLOUR],
- bool lineEmpty[NUM_COLOURS][ COLOUR_BUF_LINES ] )
+ byte *lineBuffer, byte *scanLine,
+ byte *colourBufs[NUM_COLOURS],
+ bufBit
+ colourLines[NUM_COLOURS][PENS_PER_COLOUR][COLOUR_BUF_LINES],
+ penData pens[NUM_COLOURS][PENS_PER_COLOUR],
+ bool lineEmpty[NUM_COLOURS][ COLOUR_BUF_LINES ] )
{
int colour;
int numColours = lx5000dev->color_info.num_components;
@@ -1223,7 +1216,7 @@ processCMYKline( lx5000_device *lx5000dev, int linenum,
uchar scanPixel;
scanPixels nextPixel;
bufBit nextBit[ 8 ];
- /* The end of the (scan)line. */
+ /* The end of the (scan)line. */
uchar *scanEnd = scanLine + lx5000dev->scanLineBytes;
nextPixel.scanByte = scanLine; /* Set up the moving pixel pointer. */
@@ -1232,102 +1225,101 @@ processCMYKline( lx5000_device *lx5000dev, int linenum,
for ( colour = 0; colour < numColours; colour++ )
{
- /* Set up the moving output bit pointer for
- each of the colours. */
- nextBit[ colour ].xByte = colourBufs[ colour ] + LINE_PAD_BYTES
- + ( lineIndex * lx5000dev->penLineLen );
- nextBit[ colour ].xBit = BIT_TO_MASK( 0 );
- /* Clear the colourBuf line if necessary */
- if ( ! lineEmpty[ colour ][ lineIndex ] )
- {
- memset( nextBit[ colour ].xByte - LINE_PAD_BYTES,
- 0, lx5000dev->penLineLen );
- lineEmpty[ colour ][ lineIndex ] = true;
- }
+ /* Set up the moving output bit pointer for
+ each of the colours. */
+ nextBit[ colour ].xByte = colourBufs[ colour ] + LINE_PAD_BYTES
+ + ( lineIndex * lx5000dev->penLineLen );
+ nextBit[ colour ].xBit = BIT_TO_MASK( 0 );
+ /* Clear the colourBuf line if necessary */
+ if ( ! lineEmpty[ colour ][ lineIndex ] )
+ {
+ memset( nextBit[ colour ].xByte - LINE_PAD_BYTES,
+ 0, lx5000dev->penLineLen );
+ lineEmpty[ colour ][ lineIndex ] = true;
+ }
}
- /* Is the line empty? */
+ /* Is the line empty? */
if (( ! *scanLine ) &&
- ! memcmp( scanLine, scanLine + 1, lx5000dev->scanLineBytes - 1 ))
- return; /* N.B. empty flag is pre-set to true */
+ ! memcmp( scanLine, scanLine + 1, lx5000dev->scanLineBytes - 1 ))
+ return; /* N.B. empty flag is pre-set to true */
while ( nextPixel.scanByte < scanEnd )
{
- int colour;
- int cmy; /* Used to detect if C+M+Y set */
- int skipPixels, skipBytes, skipBits;
- /* Number of consecutive empty pixels, equiv-
- alent bytes and remainder bits just skipped
- over in the CMYK line being processed. */
-
- /* Get next pixel and increment the pointer */
- scanPixel =
- ( ( *(nextPixel.scanByte) >> nextPixel.pixShift ) & PIXEL_MASK );
-
- /* pixShift is the number of bits to right-shift the scanByte
- before applying PIXEL_MASK. When we attempt to decrement
- it past 0, it's time to look at the next scanByte.
- N.B. We assume that the subtraction of BPP will end with
- zero, i.e., that there are an integral number of BPPs in
- INITIAL_PIXEL_SHIFT. We test for <= 0 just
- in case this condition gets violated.
- */
- skipPixels = 0;
- if ( nextPixel.pixShift <= 0 )
- {
- nextPixel.scanByte++;
- nextPixel.pixShift = INITIAL_PIXEL_SHIFT;
- /* If the next byte is empty, skip it */
- while (( ! *nextPixel.scanByte ) && nextPixel.scanByte < scanEnd )
- {
- nextPixel.scanByte++;
- skipPixels += PIXELS_PER_BYTE;
- }
- }
- else
- nextPixel.pixShift -= BPP;
- /* Get the black bit(s) */
- colourBits[ BLACK_X ] = scanPixel & COLOUR_MASK;
- scanPixel >>= BITS_PER_COLOUR;
- /* Set to catch all ANDed bits from colours */
- cmy = ~0;
- for ( colour = YELLOW_X; colour <= CYAN_X; colour++ )
- {
- colourBits[ colour ] = scanPixel & COLOUR_MASK;
- cmy &= scanPixel & COLOUR_MASK;
- scanPixel >>= BITS_PER_COLOUR;
- }
- if ( ( cmy ^ COLOUR_MASK ) == 0 ) /* C, M & Y all set == COLOUR_MASK */
- {
- colourBits[ YELLOW_X ] =
- colourBits[ MAGENTA_X ] = colourBits[ CYAN_X ] = 0;
- colourBits[ BLACK_X ] = COLOUR_MASK;
- }
- /* Now set the colourBuf bits */
- skipBytes = skipPixels >> 3;
- skipBits = skipPixels & 7;
- for ( colour = 0; colour < numColours; colour++ )
- {
- if ( colourBits[ colour ] )
- {
- *( nextBit[ colour ].xByte ) |= nextBit[ colour ].xBit;
- lineEmpty[ colour ][ lineIndex ] = false;
- }
- INC_BIT( nextBit[ colour ] );
- if ( skipPixels )
- {
- int bitSkip = skipBits;
-
- nextBit[ colour ].xByte += skipBytes;
- while ( bitSkip-- )
- {
- INC_BIT( nextBit[ colour ] );
- }
- }
- }
+ int colour;
+ int cmy; /* Used to detect if C+M+Y set */
+ int skipPixels, skipBytes, skipBits;
+ /* Number of consecutive empty pixels, equiv-
+ alent bytes and remainder bits just skipped
+ over in the CMYK line being processed. */
+
+ /* Get next pixel and increment the pointer */
+ scanPixel =
+ ( ( *(nextPixel.scanByte) >> nextPixel.pixShift ) & PIXEL_MASK );
+
+ /* pixShift is the number of bits to right-shift the scanByte
+ before applying PIXEL_MASK. When we attempt to decrement
+ it past 0, it's time to look at the next scanByte.
+ N.B. We assume that the subtraction of BPP will end with
+ zero, i.e., that there are an integral number of BPPs in
+ INITIAL_PIXEL_SHIFT. We test for <= 0 just
+ in case this condition gets violated.
+ */
+ skipPixels = 0;
+ if ( nextPixel.pixShift <= 0 )
+ {
+ nextPixel.scanByte++;
+ nextPixel.pixShift = INITIAL_PIXEL_SHIFT;
+ /* If the next byte is empty, skip it */
+ while (( ! *nextPixel.scanByte ) && nextPixel.scanByte < scanEnd )
+ {
+ nextPixel.scanByte++;
+ skipPixels += PIXELS_PER_BYTE;
+ }
+ }
+ else
+ nextPixel.pixShift -= BPP;
+ /* Get the black bit(s) */
+ colourBits[ BLACK_X ] = scanPixel & COLOUR_MASK;
+ scanPixel >>= BITS_PER_COLOUR;
+ /* Set to catch all ANDed bits from colours */
+ cmy = ~0;
+ for ( colour = YELLOW_X; colour <= CYAN_X; colour++ )
+ {
+ colourBits[ colour ] = scanPixel & COLOUR_MASK;
+ cmy &= scanPixel & COLOUR_MASK;
+ scanPixel >>= BITS_PER_COLOUR;
+ }
+ if ( ( cmy ^ COLOUR_MASK ) == 0 ) /* C, M & Y all set == COLOUR_MASK */
+ {
+ colourBits[ YELLOW_X ] =
+ colourBits[ MAGENTA_X ] = colourBits[ CYAN_X ] = 0;
+ colourBits[ BLACK_X ] = COLOUR_MASK;
+ }
+ /* Now set the colourBuf bits */
+ skipBytes = skipPixels >> 3;
+ skipBits = skipPixels & 7;
+ for ( colour = 0; colour < numColours; colour++ )
+ {
+ if ( colourBits[ colour ] )
+ {
+ *( nextBit[ colour ].xByte ) |= nextBit[ colour ].xBit;
+ lineEmpty[ colour ][ lineIndex ] = false;
+ }
+ INC_BIT( nextBit[ colour ] );
+ if ( skipPixels )
+ {
+ int bitSkip = skipBits;
+
+ nextBit[ colour ].xByte += skipBytes;
+ while ( bitSkip-- )
+ {
+ INC_BIT( nextBit[ colour ] );
+ }
+ }
+ }
}
}
-
/*----------------------------------------------------------------------*
* r e f r e s h B u f f e r ( ) *
*----------------------------------------------------------------------*
@@ -1353,12 +1345,12 @@ processCMYKline( lx5000_device *lx5000dev, int linenum,
*----------------------------------------------------------------------*/
static void
refreshBuffer( lx5000_device *lx5000dev,
- int *nextLineToGet, int *nextLineToPrint,
- byte *lineBuffer, byte *colourBufs[],
- bufBit
- colourLines[NUM_COLOURS][PENS_PER_COLOUR][COLOUR_BUF_LINES],
- penData pens[NUM_COLOURS][PENS_PER_COLOUR],
- bool lineEmpty[NUM_COLOURS][COLOUR_BUF_LINES] )
+ int *nextLineToGet, int *nextLineToPrint,
+ byte *lineBuffer, byte *colourBufs[],
+ bufBit
+ colourLines[NUM_COLOURS][PENS_PER_COLOUR][COLOUR_BUF_LINES],
+ penData pens[NUM_COLOURS][PENS_PER_COLOUR],
+ bool lineEmpty[NUM_COLOURS][COLOUR_BUF_LINES] )
{
byte *lineBuf;
uchar nextToGet; /* Circular buffer pointer, 0 to ff */
@@ -1367,99 +1359,99 @@ refreshBuffer( lx5000_device *lx5000dev,
int _1stPrintable; /* Across all pens */
int numColours = lx5000dev->color_info.num_components;
- /* Establish the next line to print, if it
- is already in the buffer. */
+ /* Establish the next line to print, if it
+ is already in the buffer. */
_1stPrintable = pens[YELLOW_X][LO_PEN].finalLine;
for ( colour = 0; colour < numColours; colour++ )
{
- for ( pen = 0; pen < lx5000dev->pensPerColour; pen++ )
- if ( pens[ colour ][ pen ].nextPrintLine < _1stPrintable)
- _1stPrintable = pens[ colour ][ pen ].nextPrintLine;
+ for ( pen = 0; pen < lx5000dev->pensPerColour; pen++ )
+ if ( pens[ colour ][ pen ].nextPrintLine < _1stPrintable)
+ _1stPrintable = pens[ colour ][ pen ].nextPrintLine;
}
*nextLineToPrint = _1stPrintable;
nextToGet = (uchar)(*nextLineToGet & COLOUR_BUF_MASK);
- /* nextLineToPrint may be set high (i.e. not
- known), or may be a known print line. */
+ /* nextLineToPrint may be set high (i.e. not
+ known), or may be a known print line. */
while ( ( *nextLineToGet < *nextLineToPrint
- || ( *nextLineToGet - *nextLineToPrint ) < COLOUR_BUF_LINES )
- && *nextLineToGet < lx5000dev->height )
+ || ( *nextLineToGet - *nextLineToPrint ) < COLOUR_BUF_LINES )
+ && *nextLineToGet < lx5000dev->height )
{
- bufferOffset = LINE_PAD_BYTES + ( lx5000dev->penLineLen * nextToGet );
-
- if ( ! lx5000dev->isCMYK )
- {
- /* For black-only, read the bits directly into
- the colour buffer. */
- gdev_prn_get_bits( (gx_device_printer *)lx5000dev, *nextLineToGet,
- colourBufs[BLACK_X] + bufferOffset, &lineBuf );
- /* If necessary, copy the bits into the actual
- buffer. */
- if ( lineBuf != colourBufs[BLACK_X] + bufferOffset )
- memcpy(colourBufs[BLACK_X] + bufferOffset,
- lineBuf, lx5000dev->penLineBytes);
- /* Check for a printing line */
- if ( *(colourBufs[BLACK_X] + bufferOffset) != 0
- || memcmp( colourBufs[BLACK_X] + bufferOffset,
- colourBufs[BLACK_X] + bufferOffset + 1,
- lx5000dev->scanLineBytes - 1 ))
- lineEmpty[ BLACK_X ][ nextToGet ] = false;
- else
- lineEmpty[ BLACK_X ][ nextToGet ] = true;
- }
- else /* CMYK printing */
- {
- /* Process a CMYK line from GS */
- gdev_prn_get_bits( (gx_device_printer *)lx5000dev,
- *nextLineToGet, lineBuffer, &lineBuf );
- processCMYKline( lx5000dev, *nextLineToGet, lineBuffer, lineBuf,
- colourBufs, colourLines, pens, lineEmpty );
- }
- for (colour = 0; colour < numColours; colour++ )
- {
- /* Check for printing line -
- N.B. For two-pen colour, this becomes more
- complicated. The relationship between the
- first print line of the lower and of the
- upper pen is determined by odd/even line
- numbers, although this is not an essential
- relationship. Blank lines at the top of
- the lower pen could be skipped, and the
- first available line could be printed by
- the lower pen. */
- if ( ! lineEmpty[colour][nextToGet] )
- {
- if ( pens[colour][LO_PEN].nextPrintLine > *nextLineToGet )
- pens[colour][LO_PEN].nextPrintLine = *nextLineToGet;
- if ( *nextLineToPrint > *nextLineToGet )
- *nextLineToPrint = *nextLineToGet;
- }
- }
- ++*nextLineToGet;
- nextToGet = ( *nextLineToGet & COLOUR_BUF_MASK ); /* N.B. This is safer
- than just doing the increment, in case the
- buffer length changes. */
+ bufferOffset = LINE_PAD_BYTES + ( lx5000dev->penLineLen * nextToGet );
+
+ if ( ! lx5000dev->isCMYK )
+ {
+ /* For black-only, read the bits directly into
+ the colour buffer. */
+ gdev_prn_get_bits( (gx_device_printer *)lx5000dev, *nextLineToGet,
+ colourBufs[BLACK_X] + bufferOffset, &lineBuf );
+ /* If necessary, copy the bits into the actual
+ buffer. */
+ if ( lineBuf != colourBufs[BLACK_X] + bufferOffset )
+ memcpy(colourBufs[BLACK_X] + bufferOffset,
+ lineBuf, lx5000dev->penLineBytes);
+ /* Check for a printing line */
+ if ( *(colourBufs[BLACK_X] + bufferOffset) != 0
+ || memcmp( colourBufs[BLACK_X] + bufferOffset,
+ colourBufs[BLACK_X] + bufferOffset + 1,
+ lx5000dev->scanLineBytes - 1 ))
+ lineEmpty[ BLACK_X ][ nextToGet ] = false;
+ else
+ lineEmpty[ BLACK_X ][ nextToGet ] = true;
+ }
+ else /* CMYK printing */
+ {
+ /* Process a CMYK line from GS */
+ gdev_prn_get_bits( (gx_device_printer *)lx5000dev,
+ *nextLineToGet, lineBuffer, &lineBuf );
+ processCMYKline( lx5000dev, *nextLineToGet, lineBuffer, lineBuf,
+ colourBufs, colourLines, pens, lineEmpty );
+ }
+ for (colour = 0; colour < numColours; colour++ )
+ {
+ /* Check for printing line -
+ N.B. For two-pen colour, this becomes more
+ complicated. The relationship between the
+ first print line of the lower and of the
+ upper pen is determined by odd/even line
+ numbers, although this is not an essential
+ relationship. Blank lines at the top of
+ the lower pen could be skipped, and the
+ first available line could be printed by
+ the lower pen. */
+ if ( ! lineEmpty[colour][nextToGet] )
+ {
+ if ( pens[colour][LO_PEN].nextPrintLine > *nextLineToGet )
+ pens[colour][LO_PEN].nextPrintLine = *nextLineToGet;
+ if ( *nextLineToPrint > *nextLineToGet )
+ *nextLineToPrint = *nextLineToGet;
+ }
+ }
+ ++*nextLineToGet;
+ nextToGet = ( *nextLineToGet & COLOUR_BUF_MASK ); /* N.B. This is safer
+ than just doing the increment, in case the
+ buffer length changes. */
}
- /* Check that no buffer padding is necessary */
+ /* Check that no buffer padding is necessary */
if ( *nextLineToPrint < lx5000dev->height )
{
- while ( ( *nextLineToGet - *nextLineToPrint ) < COLOUR_BUF_LINES )
- { /* Last refresh fell short of COLOUR_BUF_LINES
- because last line of page was reached.
- Pad the buffer to COLOUR_BUF_LINES with 0
- (no print) bytes. */
- for ( colour = 0; colour < numColours; colour++ )
- { /* Fill the colour line buffer, incl pad */
- memset( colourBufs[colour]
- + ( lx5000dev->penLineLen * nextToGet ),
- 0, lx5000dev->penLineLen );
- /* Set empty indicator - note that firstBit
- is NOT set here. */
- lineEmpty[colour][nextToGet] = true;
- }
- ++*nextLineToGet;
- nextToGet = ( *nextLineToGet & COLOUR_BUF_MASK );
- }
+ while ( ( *nextLineToGet - *nextLineToPrint ) < COLOUR_BUF_LINES )
+ { /* Last refresh fell short of COLOUR_BUF_LINES
+ because last line of page was reached.
+ Pad the buffer to COLOUR_BUF_LINES with 0
+ (no print) bytes. */
+ for ( colour = 0; colour < numColours; colour++ )
+ { /* Fill the colour line buffer, incl pad */
+ memset( colourBufs[colour]
+ + ( lx5000dev->penLineLen * nextToGet ),
+ 0, lx5000dev->penLineLen );
+ /* Set empty indicator - note that firstBit
+ is NOT set here. */
+ lineEmpty[colour][nextToGet] = true;
+ }
+ ++*nextLineToGet;
+ nextToGet = ( *nextLineToGet & COLOUR_BUF_MASK );
+ }
}
}
@@ -1476,31 +1468,31 @@ refreshBuffer( lx5000_device *lx5000dev,
*----------------------------------------------------------------------*/
static int
cartridgeMoveTo( lx5000_device *lx5000dev,
- penData pens[NUM_COLOURS][PENS_PER_COLOUR],
- int _1stColour, int lastColour )
+ penData pens[NUM_COLOURS][PENS_PER_COLOUR],
+ int _1stColour, int lastColour )
{
if ( _1stColour != BLACK_X && ! lx5000dev->isCMYK )
- /* Send back an off-the-page value */
- return pens[CYAN_X][LO_PEN].finalLine;
+ /* Send back an off-the-page value */
+ return pens[CYAN_X][LO_PEN].finalLine;
else
{
- int colour, pen, minLine;
-
- minLine = pens[CYAN_X][LO_PEN].finalLine; /* Initialise high */
- /* For each pen, calculate a moveto value
- which will print the next line with the
- first nozzle of that pen.
- Return the minimum of these values. */
- for ( colour = _1stColour; colour <= lastColour; colour++ )
- for ( pen = 0; pen < lx5000dev->pensPerColour; pen++ )
- if ( ( pens[colour][pen].nextPrintLine
- + pens[colour][pen].topToBottomYellow )
- < minLine )
- minLine =
- pens[colour][pen].nextPrintLine
- + pens[colour][pen].topToBottomYellow;
-
- return minLine;
+ int colour, pen, minLine;
+
+ minLine = pens[CYAN_X][LO_PEN].finalLine; /* Initialise high */
+ /* For each pen, calculate a moveto value
+ which will print the next line with the
+ first nozzle of that pen.
+ Return the minimum of these values. */
+ for ( colour = _1stColour; colour <= lastColour; colour++ )
+ for ( pen = 0; pen < lx5000dev->pensPerColour; pen++ )
+ if ( ( pens[colour][pen].nextPrintLine
+ + pens[colour][pen].topToBottomYellow )
+ < minLine )
+ minLine =
+ pens[colour][pen].nextPrintLine
+ + pens[colour][pen].topToBottomYellow;
+
+ return minLine;
}
}
/*----------------------------------------------------------------------*
@@ -1513,9 +1505,9 @@ cartridgeMoveTo( lx5000_device *lx5000dev,
*----------------------------------------------------------------------*/
static void
setColourColumnExtent( lx5000_device *lx5000dev, byte *colourBuf,
- bool lineEmpty[COLOUR_BUF_LINES],
- int _1stLine, int _1stNozzle, int lastLine,
- int *_1stColumn, int *lastColumn, int *columnExtent )
+ bool lineEmpty[COLOUR_BUF_LINES],
+ int _1stLine, int _1stNozzle, int lastLine,
+ int *_1stColumn, int *lastColumn, int *columnExtent )
{
uchar _1stIndex;
int firstPrintByte, lastPrintByte;
@@ -1527,47 +1519,47 @@ setColourColumnExtent( lx5000_device *lx5000dev, byte *colourBuf,
for ( ; line <= lastLine; line += lx5000dev->lineIncrement )
{ /* For each active line in swipe */
- int columnByte;
-
- _1stIndex = line & COLOUR_BUF_MASK;
- if ( lineEmpty[ _1stIndex ] )
- continue; /* If the line is empty, skip it. */
- /* Otherwise, scan from the beginning to any
- previously found non-zero byte for the
- beginning of the active column extent. */
- for ( columnByte = 0; columnByte < firstPrintByte; columnByte++ )
- if ( colourBuf[ _1stIndex * lx5000dev->penLineLen
- + LINE_PAD_BYTES + columnByte ] )
- {
- firstPrintByte = columnByte;
- break;
- }
- /* Scan from the end of the line to any pre-
- viously found non-zero byte for the end of
- the active column extent. */
- for ( columnByte = lx5000dev->penLineBytes;
- columnByte > lastPrintByte; columnByte-- )
- if ( colourBuf[ _1stIndex * lx5000dev->penLineLen
- + LINE_PAD_BYTES + columnByte ] )
- {
- lastPrintByte = columnByte;
- break;
- }
+ int columnByte;
+
+ _1stIndex = line & COLOUR_BUF_MASK;
+ if ( lineEmpty[ _1stIndex ] )
+ continue; /* If the line is empty, skip it. */
+ /* Otherwise, scan from the beginning to any
+ previously found non-zero byte for the
+ beginning of the active column extent. */
+ for ( columnByte = 0; columnByte < firstPrintByte; columnByte++ )
+ if ( colourBuf[ _1stIndex * lx5000dev->penLineLen
+ + LINE_PAD_BYTES + columnByte ] )
+ {
+ firstPrintByte = columnByte;
+ break;
+ }
+ /* Scan from the end of the line to any pre-
+ viously found non-zero byte for the end of
+ the active column extent. */
+ for ( columnByte = lx5000dev->penLineBytes;
+ columnByte > lastPrintByte; columnByte-- )
+ if ( colourBuf[ _1stIndex * lx5000dev->penLineLen
+ + LINE_PAD_BYTES + columnByte ] )
+ {
+ lastPrintByte = columnByte;
+ break;
+ }
}
- /* If we have no extent, there are no
- printable lines for this pen. */
+ /* If we have no extent, there are no
+ printable lines for this pen. */
if ( firstPrintByte > lastPrintByte )
{
- *_1stColumn = firstPrintByte * 8;
- *lastColumn = lastPrintByte * 8;
- *columnExtent = 0;
- return;
+ *_1stColumn = firstPrintByte * 8;
+ *lastColumn = lastPrintByte * 8;
+ *columnExtent = 0;
+ return;
}
*_1stColumn = firstPrintByte * 8;
*lastColumn = lastPrintByte * 8 + 7 + lx5000dev->headSeparation;
*columnExtent = ( *lastColumn - *_1stColumn ) + 1;
-
+
}
/*----------------------------------------------------------------------*
@@ -1581,102 +1573,102 @@ setColourColumnExtent( lx5000_device *lx5000dev, byte *colourBuf,
*----------------------------------------------------------------------*/
static void
setColourLines( lx5000_device *lx5000dev,
- byte *colourBuf, bufBit colourLines[COLOUR_BUF_LINES],
- int _1stLine, int _1stNozzle, int lastLine, int direction,
- int _1stColumn, int lastColumn )
+ byte *colourBuf, bufBit colourLines[COLOUR_BUF_LINES],
+ int _1stLine, int _1stNozzle, int lastLine, int direction,
+ int _1stColumn, int lastColumn )
{
uchar _1stIndex;
int line, nozzle, bit, headSep, headSepBytes, headSepBits;
int firstPrintByte, lastPrintByte, lastPrintBit;
bufBit startPtr;
-
+
/* Now initialize the penBits bufBit structures to point to the
beginning and end of the extent for each of the active lines in
this swipe
-
+
Adjust the beginning for all EVEN nozzles by moving it to the
left by HeadSeparation bits.
*/
headSep = lx5000dev->headSeparation;
if ( lx5000dev->x_pixels_per_inch == 300.0 )
- headSep = headSep >> 1; /* Halve the value at 300 dpi */
+ headSep = headSep >> 1; /* Halve the value at 300 dpi */
if ( lx5000dev->x_pixels_per_inch == 1200.0 )
- headSep = headSep << 1; /* Double the value at 1200dpi */
+ headSep = headSep << 1; /* Double the value at 1200dpi */
headSepBytes = headSep / 8;
headSepBits = headSep % 8;
firstPrintByte = _1stColumn / 8;
lastPrintByte = lastColumn / 8;
lastPrintBit = lastColumn % 8;
-
+
if ( direction == RIGHTWARD )
{
- /* Set up the ODD columns first */
- startPtr.xByte = colourBuf + LINE_PAD_BYTES + firstPrintByte;
- startPtr.xBit = BIT_TO_MASK( 0 );
- line = _1stLine;
- nozzle = _1stNozzle; /* Is 1st nozzle effectively odd? */
- if ( ! ( nozzle & 1 ) ) /* Nozzle is even, so increment */
- line += lx5000dev->lineIncrement;
- for ( ; line <= lastLine; line += ( lx5000dev->lineIncrement << 1 ) )
- {
- _1stIndex = (uchar)( line & COLOUR_BUF_MASK );
- colourLines[_1stIndex].xByte =
- startPtr.xByte + _1stIndex * lx5000dev->penLineLen;
- colourLines[_1stIndex].xBit = startPtr.xBit;
- }
- /* Set up EVEN columns */
- startPtr.xByte -= headSepBytes;
- for ( bit = 0; bit < headSepBits; bit++ )
- {
- DEC_BIT( startPtr );
- }
- line = _1stLine;
- nozzle = _1stNozzle; /* Is 1st nozzle effectively even? */
- if ( nozzle & 1 ) /* Nozzle is odd, so increment */
- line += lx5000dev->lineIncrement;
- for ( ; line <= lastLine; line += ( lx5000dev->lineIncrement << 1 ) )
- {
- _1stIndex = (uchar)( line & COLOUR_BUF_MASK );
- colourLines[_1stIndex].xByte =
- startPtr.xByte + _1stIndex * lx5000dev->penLineLen;
- colourLines[_1stIndex].xBit = startPtr.xBit;
- }
+ /* Set up the ODD columns first */
+ startPtr.xByte = colourBuf + LINE_PAD_BYTES + firstPrintByte;
+ startPtr.xBit = BIT_TO_MASK( 0 );
+ line = _1stLine;
+ nozzle = _1stNozzle; /* Is 1st nozzle effectively odd? */
+ if ( ! ( nozzle & 1 ) ) /* Nozzle is even, so increment */
+ line += lx5000dev->lineIncrement;
+ for ( ; line <= lastLine; line += ( lx5000dev->lineIncrement << 1 ) )
+ {
+ _1stIndex = (uchar)( line & COLOUR_BUF_MASK );
+ colourLines[_1stIndex].xByte =
+ startPtr.xByte + _1stIndex * lx5000dev->penLineLen;
+ colourLines[_1stIndex].xBit = startPtr.xBit;
+ }
+ /* Set up EVEN columns */
+ startPtr.xByte -= headSepBytes;
+ for ( bit = 0; bit < headSepBits; bit++ )
+ {
+ DEC_BIT( startPtr );
+ }
+ line = _1stLine;
+ nozzle = _1stNozzle; /* Is 1st nozzle effectively even? */
+ if ( nozzle & 1 ) /* Nozzle is odd, so increment */
+ line += lx5000dev->lineIncrement;
+ for ( ; line <= lastLine; line += ( lx5000dev->lineIncrement << 1 ) )
+ {
+ _1stIndex = (uchar)( line & COLOUR_BUF_MASK );
+ colourLines[_1stIndex].xByte =
+ startPtr.xByte + _1stIndex * lx5000dev->penLineLen;
+ colourLines[_1stIndex].xBit = startPtr.xBit;
+ }
}
else /* direction == LEFTWARD */
{
- /* Set up the ODD columns first */
- startPtr.xByte = colourBuf + LINE_PAD_BYTES + lastPrintByte;
- startPtr.xBit = BIT_TO_MASK( lastPrintBit );
- line = _1stLine;
- nozzle = _1stNozzle; /* Is 1st nozzle effectively odd? */
- if ( ! ( nozzle & 1 ) ) /* Nozzle is even, so increment */
- line += lx5000dev->lineIncrement;
- for ( ; line <= lastLine; line += ( lx5000dev->lineIncrement << 1 ) )
- {
- _1stIndex = (uchar)( line & COLOUR_BUF_MASK );
- colourLines[_1stIndex].xByte =
- startPtr.xByte + _1stIndex * lx5000dev->penLineLen;
- colourLines[_1stIndex].xBit = startPtr.xBit;
- }
- /* Set up EVEN columns */
- startPtr.xByte -= headSepBytes;
- for ( bit = 0; bit < headSepBits; bit++ )
- {
- DEC_BIT( startPtr );
- }
- line = _1stLine;
- nozzle = _1stNozzle; /* Is 1st nozzle effectively even? */
- if ( nozzle & 1 ) /* Nozzle is odd, so increment */
- line += lx5000dev->lineIncrement;
- for ( ; line <= lastLine; line += ( lx5000dev->lineIncrement << 1 ) )
- {
- _1stIndex = (uchar)( line & COLOUR_BUF_MASK );
- colourLines[_1stIndex].xByte =
- startPtr.xByte + _1stIndex * lx5000dev->penLineLen;
- colourLines[_1stIndex].xBit = startPtr.xBit;
- }
+ /* Set up the ODD columns first */
+ startPtr.xByte = colourBuf + LINE_PAD_BYTES + lastPrintByte;
+ startPtr.xBit = BIT_TO_MASK( lastPrintBit );
+ line = _1stLine;
+ nozzle = _1stNozzle; /* Is 1st nozzle effectively odd? */
+ if ( ! ( nozzle & 1 ) ) /* Nozzle is even, so increment */
+ line += lx5000dev->lineIncrement;
+ for ( ; line <= lastLine; line += ( lx5000dev->lineIncrement << 1 ) )
+ {
+ _1stIndex = (uchar)( line & COLOUR_BUF_MASK );
+ colourLines[_1stIndex].xByte =
+ startPtr.xByte + _1stIndex * lx5000dev->penLineLen;
+ colourLines[_1stIndex].xBit = startPtr.xBit;
+ }
+ /* Set up EVEN columns */
+ startPtr.xByte -= headSepBytes;
+ for ( bit = 0; bit < headSepBits; bit++ )
+ {
+ DEC_BIT( startPtr );
+ }
+ line = _1stLine;
+ nozzle = _1stNozzle; /* Is 1st nozzle effectively even? */
+ if ( nozzle & 1 ) /* Nozzle is odd, so increment */
+ line += lx5000dev->lineIncrement;
+ for ( ; line <= lastLine; line += ( lx5000dev->lineIncrement << 1 ) )
+ {
+ _1stIndex = (uchar)( line & COLOUR_BUF_MASK );
+ colourLines[_1stIndex].xByte =
+ startPtr.xByte + _1stIndex * lx5000dev->penLineLen;
+ colourLines[_1stIndex].xBit = startPtr.xBit;
+ }
}
}
@@ -1686,12 +1678,12 @@ setColourLines( lx5000_device *lx5000dev,
*----------------------------------------------------------------------*/
static void
printSwipe( lx5000_device *lx5000dev, byte *colourBufs[NUM_COLOURS],
- bufBit
- colourLines[NUM_COLOURS][PENS_PER_COLOUR][COLOUR_BUF_LINES],
- penData pens[NUM_COLOURS][PENS_PER_COLOUR],
- bool lineEmpty[NUM_COLOURS][COLOUR_BUF_LINES], byte *swipeBuf,
- int *nextLineToPrint, int *nextLineToGet, int direction,
- int _1stColour, int lastColour, FILE *prn_stream )
+ bufBit
+ colourLines[NUM_COLOURS][PENS_PER_COLOUR][COLOUR_BUF_LINES],
+ penData pens[NUM_COLOURS][PENS_PER_COLOUR],
+ bool lineEmpty[NUM_COLOURS][COLOUR_BUF_LINES], byte *swipeBuf,
+ int *nextLineToPrint, int *nextLineToGet, int direction,
+ int _1stColour, int lastColour, FILE *prn_stream )
{
/*--------------------------------------------------------------------*
For unidirectional colour swathes, the effective print direction on
@@ -1703,320 +1695,320 @@ printSwipe( lx5000_device *lx5000dev, byte *colourBufs[NUM_COLOURS],
*--------------------------------------------------------------------*/
static const char swipeHeader[SWIPE_HDR_LEN] = {
- SWIPE_LEADER,
- 0, 0, 0, 0, /* command length */
- 0, /* direction */
- 0, /* head speed */
- 0, 0, /* pen selector */
- 0, /* nozzle count */
- 0, /* don't know */
- 0, 0, /* number of columns */
- 0, 0, /* 1st column */
- 0, 0, /* last column */
- SWIPE_HDR_END
+ SWIPE_LEADER,
+ 0, 0, 0, 0, /* command length */
+ 0, /* direction */
+ 0, /* head speed */
+ 0, 0, /* pen selector */
+ 0, /* nozzle count */
+ 0, /* don't know */
+ 0, 0, /* number of columns */
+ 0, 0, /* 1st column */
+ 0, 0, /* last column */
+ SWIPE_HDR_END
};
static const int wordsPerPen[NUM_COLOURS][PENS_PER_COLOUR + 1] =
{
- { -1,
- BLACK_NOZZLES / SWIPE_WORD_BITS,
- BLACK_NOZZLES / SWIPE_WORD_BITS / 2
- },
- { -1,
- _1COLOUR_NOZZLES / SWIPE_WORD_BITS,
- _1COLOUR_NOZZLES / SWIPE_WORD_BITS / 2
- },
- { -1,
- _1COLOUR_NOZZLES / SWIPE_WORD_BITS,
- _1COLOUR_NOZZLES / SWIPE_WORD_BITS / 2
- },
- { -1,
- _1COLOUR_NOZZLES / SWIPE_WORD_BITS,
- _1COLOUR_NOZZLES / SWIPE_WORD_BITS / 2
- }
- };
+ { -1,
+ BLACK_NOZZLES / SWIPE_WORD_BITS,
+ BLACK_NOZZLES / SWIPE_WORD_BITS / 2
+ },
+ { -1,
+ _1COLOUR_NOZZLES / SWIPE_WORD_BITS,
+ _1COLOUR_NOZZLES / SWIPE_WORD_BITS / 2
+ },
+ { -1,
+ _1COLOUR_NOZZLES / SWIPE_WORD_BITS,
+ _1COLOUR_NOZZLES / SWIPE_WORD_BITS / 2
+ },
+ { -1,
+ _1COLOUR_NOZZLES / SWIPE_WORD_BITS,
+ _1COLOUR_NOZZLES / SWIPE_WORD_BITS / 2
+ }
+ };
int _1stNozzle[NUM_COLOURS][PENS_PER_COLOUR];
- /* 1st active nozzle for pen */
+ /* 1st active nozzle for pen */
int lastNozzle[NUM_COLOURS][PENS_PER_COLOUR];
- /* Last nozzle of this pen */
+ /* Last nozzle of this pen */
int _1stLine[NUM_COLOURS][PENS_PER_COLOUR];
- /* Line no. of first print line for pen */
+ /* Line no. of first print line for pen */
int _1stPenColumn[NUM_COLOURS][PENS_PER_COLOUR];
int lastPenColumn[NUM_COLOURS][PENS_PER_COLOUR];
- /* Per-pen values... */
+ /* Per-pen values... */
int penExtent[NUM_COLOURS][PENS_PER_COLOUR];
int _1stColumn; /* ...and overall values of... */
int lastColumn;
int columnExtent; /* Column range after */
- /* stripping leading and trailing white space*/
+ /* stripping leading and trailing white space*/
int column; /* Loop variable - current column */
int line; /* Loop variables - line corresponding to
- current nozzle & temp line variable. */
+ current nozzle & temp line variable. */
uchar lineIndex; /* Circular index into pen buffer,
- corresponding to current line. */
+ corresponding to current line. */
int swipeCmdLen; /* Length of the swipe command */
int colour, pen;
byte *outp;
int x_dpi = (int)( lx5000dev->x_pixels_per_inch + 0.1 );
- /* Initialize worst case values for column
- extremities. */
+ /* Initialize worst case values for column
+ extremities. */
_1stColumn = lx5000dev->penLineBytes * 8
- + 7 + lx5000dev->headSeparation;
+ + 7 + lx5000dev->headSeparation;
lastColumn = 0;
- /* Set up extents on a per-colour basis. */
+ /* Set up extents on a per-colour basis. */
for ( colour = _1stColour; colour <= lastColour; colour++ )
- for ( pen = 0; pen < lx5000dev->pensPerColour; pen++ )
- {
- _1stLine[colour][pen] = pens[colour][pen].nextPrintLine;
- _1stNozzle[colour][pen] = _1stLine[colour][pen]
- - pens[colour][pen].topLine;
- lastNozzle[colour][pen] = pens[colour][pen].bottomLine
- - pens[colour][pen].topLine;
-
- setColourColumnExtent( lx5000dev, colourBufs[colour],
- lineEmpty[colour], _1stLine[colour][pen],
- _1stNozzle[colour][pen],
- pens[colour][pen].bottomLine,
- &_1stPenColumn[colour][pen],
- &lastPenColumn[colour][pen],
- &penExtent[colour][pen] );
- /* Get the overall extents for the swipe */
- if ( _1stPenColumn[colour][pen] < _1stColumn )
- _1stColumn = _1stPenColumn[colour][pen];
- if ( lastPenColumn[colour][pen] > lastColumn )
- lastColumn = lastPenColumn[colour][pen];
- }
- /* Set overall extent */
+ for ( pen = 0; pen < lx5000dev->pensPerColour; pen++ )
+ {
+ _1stLine[colour][pen] = pens[colour][pen].nextPrintLine;
+ _1stNozzle[colour][pen] = _1stLine[colour][pen]
+ - pens[colour][pen].topLine;
+ lastNozzle[colour][pen] = pens[colour][pen].bottomLine
+ - pens[colour][pen].topLine;
+
+ setColourColumnExtent( lx5000dev, colourBufs[colour],
+ lineEmpty[colour], _1stLine[colour][pen],
+ _1stNozzle[colour][pen],
+ pens[colour][pen].bottomLine,
+ &_1stPenColumn[colour][pen],
+ &lastPenColumn[colour][pen],
+ &penExtent[colour][pen] );
+ /* Get the overall extents for the swipe */
+ if ( _1stPenColumn[colour][pen] < _1stColumn )
+ _1stColumn = _1stPenColumn[colour][pen];
+ if ( lastPenColumn[colour][pen] > lastColumn )
+ lastColumn = lastPenColumn[colour][pen];
+ }
+ /* Set overall extent */
columnExtent = ( lastColumn - _1stColumn ) + 1;
- /* Set the column range for each of the colour
- pens now that the full extent is known. */
+ /* Set the column range for each of the colour
+ pens now that the full extent is known. */
for ( colour = _1stColour; colour <= lastColour; colour++ )
- for ( pen = 0; pen < lx5000dev->pensPerColour; pen++ )
- {
- setColourLines( lx5000dev, colourBufs[colour],
- colourLines[colour][pen],
- _1stLine[colour][pen], _1stNozzle[colour][pen],
- pens[colour][pen].bottomLine, direction,
- _1stColumn, lastColumn );
- }
-
+ for ( pen = 0; pen < lx5000dev->pensPerColour; pen++ )
+ {
+ setColourLines( lx5000dev, colourBufs[colour],
+ colourLines[colour][pen],
+ _1stLine[colour][pen], _1stNozzle[colour][pen],
+ pens[colour][pen].bottomLine, direction,
+ _1stColumn, lastColumn );
+ }
+
memcpy( swipeBuf, swipeHeader, SWIPE_HDR_LEN );
outp = swipeBuf + SWIPE_HDR_LEN;
- /* For each column of the output, build two
- stripes. One uses the standard directory
- scheme, and the other uses the repeat
- compression scheme. Output the more
- compact result. */
+ /* For each column of the output, build two
+ stripes. One uses the standard directory
+ scheme, and the other uses the repeat
+ compression scheme. Output the more
+ compact result. */
for ( column = _1stColumn; column <= lastColumn; column++ )
{
- ushort dataword; /* Loop transient - contents of swipe data
- word currently under construction. */
- ushort lastWord; /* Last data word constructed for repeat
- compression directory method. */
- int nozzle; /* Loop variable - current nozzle */
- /* The arrays of the two sets of data words
- generated by each of the swipe construction
- methods for a single swipe. Does not
- include the 16 bit directory word. */
- int wordCount1; /* The count of words in the column arrays, */
- int wordCount2; /* below. */
- ushort column1[BLK_SWIPE_WORDS];
- ushort column2[BLK_SWIPE_WORDS];
- int columnWord; /* Current word within column. */
- bufBit *lineBit; /* Loop transient - current scan line bit */
- ushort wordBit; /* Current bit within swipe word - incremented
- by right shifts. */
- ushort directoryBit; /* Current bit within directory word. It
- indicates the currently active set of 16
- nozzles. Incremented by left shifts. */
- ushort directory1; /* The directories for the two methods. Each */
- ushort directory2; /* bit controls one following 16bit word. */
-
- if ( _1stColour == BLACK_X )
- {
- directory1 = (ushort)(BLK_DIRECTORY_MASK); /* empty */
- directory2 = (ushort)(BLK_DIRECTORY_MASK); /* empty */
- }
- else
- {
- directory1 = (ushort)(COLOUR_DIRECTORY_MASK); /* empty */
- directory2 = (ushort)(COLOUR_DIRECTORY_MASK); /* empty */
- }
- directory1 |= DIRECTORY_TYPE_BIT; /* Normal directory */
- directory2 &= ~DIRECTORY_TYPE_BIT; /* Repeat compression
- directory */
- /* LSBit of directory refers to 1st following
- word */
- directoryBit = 1;
- lastWord = 0;
- wordCount1 = 0;
- wordCount2 = 0;
- /* Note that the order of the pens in the
- datawords (top nozzle to bottom) is
- CMY, the reverse of the numbering */
- /*------------------------------------------
- N.B. What are the implications of this for
- pen processing within a colour?
- -----------------------------------------*/
- for ( colour = lastColour; colour >= _1stColour; colour-- )
- for ( pen = 0; pen < lx5000dev->pensPerColour; pen++ )
- {
- dataword = 0;
- nozzle = 0;
- line = _1stLine[colour][pen];
- /* If there are any non-printing nozzles at
- the top of the printhead, set up the entries
- for them here. */
- while ( ( ( _1stNozzle[colour][pen] - nozzle )
- >= SWIPE_WORD_BITS )
- && ( nozzle <= lastNozzle[colour][pen] ) )
- {
- if ( lastWord != 0 )
- {
- directory2 &= ~directoryBit;
- column2[ wordCount2++ ] = dataword;
- lastWord = dataword;
- }
- nozzle += SWIPE_WORD_BITS;
- directoryBit <<= 1;
- }
- /* Shift over any remaining empty bits in
- the current column word. */
- wordBit = ( 1 << ( SWIPE_WORD_BITS - 1 ));
- wordBit >>= ( _1stNozzle[colour][pen] - nozzle );
-
- for ( columnWord = _1stNozzle[colour][pen] / SWIPE_WORD_BITS;
- columnWord <
- wordsPerPen[colour][lx5000dev->pensPerColour];
- columnWord++ )
- {
- while ( wordBit )
- {
- lineIndex = (uchar)( line & COLOUR_BUF_MASK );
- /* Get the bit from the next line */
- lineBit = &colourLines[colour][pen][lineIndex];
- if ( *(lineBit->xByte) & lineBit->xBit )
- dataword |= wordBit;
- wordBit >>= 1;
- if ( direction == LEFTWARD )
- {
- DEC_BIT( *lineBit );
- }
- else
- {
- INC_BIT( *lineBit );
- }
- line += lx5000dev->lineIncrement;
- }
- /* Do we have a non-null dataword? */
- if ( dataword )/* For normal compression, every nonempty */
- { /* dataword is noted and sent to printer */
- directory1 &= ~directoryBit;
- column1[ wordCount1++ ] = dataword;
- }
- if ( dataword != lastWord ) /* For repeat compression, */
- { /* only datawords which change are recorded */
- directory2 &= ~directoryBit;
- column2[ wordCount2++ ] = dataword;
- lastWord = dataword;
- }
- /* Look at next set of nozzles */
- directoryBit <<= 1;
- dataword = 0;
- /* Reset dataword bit mask to 1st bit */
- wordBit = ( 1 << ( SWIPE_WORD_BITS - 1 ));
- }
- }
- /* Output the smaller array of column words -
- is it normal or repeat compressed? */
- if ( wordCount1 < wordCount2 )
- { /* A normal directory + data */
- int i;
-
- *outp++ = directory1 >> 8;
- *outp++ = directory1 & 0xff;
- for ( i = 0; i < wordCount1; i++ )
- {
- *outp++ = column1[ i ] >> 8;
- *outp++ = column1[ i ] & 0xff;
- }
- }
- else
- { /* A repeat compression directory + data */
- int i;
-
- *outp++ = directory2 >> 8;
- *outp++ = directory2 & 0xff;
- for ( i = 0; i < wordCount2; i++ )
- {
- *outp++ = column2[ i ] >> 8;
- *outp++ = column2[ i ] & 0xff;
- }
- }
+ ushort dataword; /* Loop transient - contents of swipe data
+ word currently under construction. */
+ ushort lastWord; /* Last data word constructed for repeat
+ compression directory method. */
+ int nozzle; /* Loop variable - current nozzle */
+ /* The arrays of the two sets of data words
+ generated by each of the swipe construction
+ methods for a single swipe. Does not
+ include the 16 bit directory word. */
+ int wordCount1; /* The count of words in the column arrays, */
+ int wordCount2; /* below. */
+ ushort column1[BLK_SWIPE_WORDS];
+ ushort column2[BLK_SWIPE_WORDS];
+ int columnWord; /* Current word within column. */
+ bufBit *lineBit; /* Loop transient - current scan line bit */
+ ushort wordBit; /* Current bit within swipe word - incremented
+ by right shifts. */
+ ushort directoryBit; /* Current bit within directory word. It
+ indicates the currently active set of 16
+ nozzles. Incremented by left shifts. */
+ ushort directory1; /* The directories for the two methods. Each */
+ ushort directory2; /* bit controls one following 16bit word. */
+
+ if ( _1stColour == BLACK_X )
+ {
+ directory1 = (ushort)(BLK_DIRECTORY_MASK); /* empty */
+ directory2 = (ushort)(BLK_DIRECTORY_MASK); /* empty */
+ }
+ else
+ {
+ directory1 = (ushort)(COLOUR_DIRECTORY_MASK); /* empty */
+ directory2 = (ushort)(COLOUR_DIRECTORY_MASK); /* empty */
+ }
+ directory1 |= DIRECTORY_TYPE_BIT; /* Normal directory */
+ directory2 &= ~DIRECTORY_TYPE_BIT; /* Repeat compression
+ directory */
+ /* LSBit of directory refers to 1st following
+ word */
+ directoryBit = 1;
+ lastWord = 0;
+ wordCount1 = 0;
+ wordCount2 = 0;
+ /* Note that the order of the pens in the
+ datawords (top nozzle to bottom) is
+ CMY, the reverse of the numbering */
+ /*------------------------------------------
+ N.B. What are the implications of this for
+ pen processing within a colour?
+ -----------------------------------------*/
+ for ( colour = lastColour; colour >= _1stColour; colour-- )
+ for ( pen = 0; pen < lx5000dev->pensPerColour; pen++ )
+ {
+ dataword = 0;
+ nozzle = 0;
+ line = _1stLine[colour][pen];
+ /* If there are any non-printing nozzles at
+ the top of the printhead, set up the entries
+ for them here. */
+ while ( ( ( _1stNozzle[colour][pen] - nozzle )
+ >= SWIPE_WORD_BITS )
+ && ( nozzle <= lastNozzle[colour][pen] ) )
+ {
+ if ( lastWord != 0 )
+ {
+ directory2 &= ~directoryBit;
+ column2[ wordCount2++ ] = dataword;
+ lastWord = dataword;
+ }
+ nozzle += SWIPE_WORD_BITS;
+ directoryBit <<= 1;
+ }
+ /* Shift over any remaining empty bits in
+ the current column word. */
+ wordBit = ( 1 << ( SWIPE_WORD_BITS - 1 ));
+ wordBit >>= ( _1stNozzle[colour][pen] - nozzle );
+
+ for ( columnWord = _1stNozzle[colour][pen] / SWIPE_WORD_BITS;
+ columnWord <
+ wordsPerPen[colour][lx5000dev->pensPerColour];
+ columnWord++ )
+ {
+ while ( wordBit )
+ {
+ lineIndex = (uchar)( line & COLOUR_BUF_MASK );
+ /* Get the bit from the next line */
+ lineBit = &colourLines[colour][pen][lineIndex];
+ if ( *(lineBit->xByte) & lineBit->xBit )
+ dataword |= wordBit;
+ wordBit >>= 1;
+ if ( direction == LEFTWARD )
+ {
+ DEC_BIT( *lineBit );
+ }
+ else
+ {
+ INC_BIT( *lineBit );
+ }
+ line += lx5000dev->lineIncrement;
+ }
+ /* Do we have a non-null dataword? */
+ if ( dataword )/* For normal compression, every nonempty */
+ { /* dataword is noted and sent to printer */
+ directory1 &= ~directoryBit;
+ column1[ wordCount1++ ] = dataword;
+ }
+ if ( dataword != lastWord ) /* For repeat compression, */
+ { /* only datawords which change are recorded */
+ directory2 &= ~directoryBit;
+ column2[ wordCount2++ ] = dataword;
+ lastWord = dataword;
+ }
+ /* Look at next set of nozzles */
+ directoryBit <<= 1;
+ dataword = 0;
+ /* Reset dataword bit mask to 1st bit */
+ wordBit = ( 1 << ( SWIPE_WORD_BITS - 1 ));
+ }
+ }
+ /* Output the smaller array of column words -
+ is it normal or repeat compressed? */
+ if ( wordCount1 < wordCount2 )
+ { /* A normal directory + data */
+ int i;
+
+ *outp++ = directory1 >> 8;
+ *outp++ = directory1 & 0xff;
+ for ( i = 0; i < wordCount1; i++ )
+ {
+ *outp++ = column1[ i ] >> 8;
+ *outp++ = column1[ i ] & 0xff;
+ }
+ }
+ else
+ { /* A repeat compression directory + data */
+ int i;
+
+ *outp++ = directory2 >> 8;
+ *outp++ = directory2 & 0xff;
+ for ( i = 0; i < wordCount2; i++ )
+ {
+ *outp++ = column2[ i ] >> 8;
+ *outp++ = column2[ i ] & 0xff;
+ }
+ }
}
- /* Set up the header and output the swipe */
+ /* Set up the header and output the swipe */
swipeCmdLen = outp - swipeBuf;
{
- int ps1, ps2, direction, density, nozzles;
-
- direction = UNIDIRECTIONAL;
- if ( x_dpi == 300 )
- {
- density = _300X;
- }
- else
- {
- if ( x_dpi == 1200 )
- density = _1200X;
- else
- density = _600X;
- }
-
- if ( _1stColour == BLACK_X )
- {
- ps1 = BLACK0;
- ps2 = BLACK1;
- nozzles = _208NOZZLES;
- }
- else
- {
- ps1 = COLOUR0;
- ps2 = COLOUR1;
- nozzles = _192NOZZLES;
- }
- FILL_SWIPE_HEADER( swipeBuf, swipeCmdLen, direction, density,
- ps1, ps2, nozzles, UNKNOWN1VAL,
- columnExtent, _1stColumn, lastColumn );
+ int ps1, ps2, direction, density, nozzles;
+
+ direction = UNIDIRECTIONAL;
+ if ( x_dpi == 300 )
+ {
+ density = _300X;
+ }
+ else
+ {
+ if ( x_dpi == 1200 )
+ density = _1200X;
+ else
+ density = _600X;
+ }
+
+ if ( _1stColour == BLACK_X )
+ {
+ ps1 = BLACK0;
+ ps2 = BLACK1;
+ nozzles = _208NOZZLES;
+ }
+ else
+ {
+ ps1 = COLOUR0;
+ ps2 = COLOUR1;
+ nozzles = _192NOZZLES;
+ }
+ FILL_SWIPE_HEADER( swipeBuf, swipeCmdLen, direction, density,
+ ps1, ps2, nozzles, UNKNOWN1VAL,
+ columnExtent, _1stColumn, lastColumn );
}
fwrite( swipeBuf,1, outp - swipeBuf, prn_stream );
for ( colour = _1stColour; colour <= lastColour; colour++ )
- for ( pen = 0; pen < lx5000dev->pensPerColour; pen++ )
- {
- /* Scan the buffer for the next print line,
- if present. If not, set sentinel value. */
- if ( pens[colour][pen].nextPrintLine
- <= pens[colour][pen].bottomLine
- || pens[colour][pen].nextPrintLine >= *nextLineToGet )
- {
- pens[colour][pen].nextPrintLine =
- pens[YELLOW_X][LO_PEN].finalLine;
- line = pens[colour][pen].bottomLine + 1;
- while ( line < *nextLineToGet )
- {
- lineIndex = (uchar)( line & COLOUR_BUF_MASK );
- if ( ! lineEmpty[colour][ lineIndex ] )
- {
- pens[colour][pen].nextPrintLine = line;
- break;
- }
- line += lx5000dev->lineIncrement;
- }
- }
- }
+ for ( pen = 0; pen < lx5000dev->pensPerColour; pen++ )
+ {
+ /* Scan the buffer for the next print line,
+ if present. If not, set sentinel value. */
+ if ( pens[colour][pen].nextPrintLine
+ <= pens[colour][pen].bottomLine
+ || pens[colour][pen].nextPrintLine >= *nextLineToGet )
+ {
+ pens[colour][pen].nextPrintLine =
+ pens[YELLOW_X][LO_PEN].finalLine;
+ line = pens[colour][pen].bottomLine + 1;
+ while ( line < *nextLineToGet )
+ {
+ lineIndex = (uchar)( line & COLOUR_BUF_MASK );
+ if ( ! lineEmpty[colour][ lineIndex ] )
+ {
+ pens[colour][pen].nextPrintLine = line;
+ break;
+ }
+ line += lx5000dev->lineIncrement;
+ }
+ }
+ }
}
/*----------------------------------------------------------------------*
@@ -2029,28 +2021,28 @@ lx5000_print_page( gx_device_printer *pdev, FILE *prn_stream )
{
/*
Data structures for the buffer:
-
+
------------------------------------------------------------------*
- C O L O U R B U F F E R S
+ C O L O U R B U F F E R S
------------------------------------------------------------------*
The colour buffers contain the individual colour bits that will
actually be passed to the print heads; therefore, there is one bit
per printable element. So far, the correspondence between the
gx_color_index elements in the scan line and the individual print
bits is 1-to-1.
-
+
For the colour driver, the colour buffers will be:
- Cbuffer, Mbuffer, Ybuffer and Kbuffer
+ Cbuffer, Mbuffer, Ybuffer and Kbuffer
while for the black driver, only Kbuffer is used.
(See BUFFER HANDLING MACROS.)
-
+
------------------------------------------------------------------*
- D E T E R M I N I N G B U F F E R S I Z E
+ D E T E R M I N I N G B U F F E R S I Z E
------------------------------------------------------------------*
The colour buffers are circular buffers: in order to implement this
characteristic, the size of the buffer must be 2^n. The buffers may
then be indexed by the scan line number, masked by 2^n - 1.
-
+
The buffer must be able to accommodate the maximum range of scan
lines that might be affected by a single swipe command. For colour
pens this is 240 ( 3 x 64 pens + 2 x 24 inter-pen gaps). For the
@@ -2058,72 +2050,72 @@ lx5000_print_page( gx_device_printer *pdev, FILE *prn_stream )
In fact, this is probably also the optimal buffer size, as there seems
to be no advantage in buffering twice the number of scan line required
to hold any individual swipe.
-
+
------------------------------------------------------------------*
- S T R U C T U R E O F T H E C O L O U R B U F F E R S
+ S T R U C T U R E O F T H E C O L O U R B U F F E R S
------------------------------------------------------------------*
The colour buffers hold the data for individual colour printheads,
extracted from the original data provided as scan lines. When the
data for each colour is extracted from the scan line, it is placed
into a line of the colour buffer corresponding to the scan line.
-
+
Within each line of the colour buffer, the data is structured like so:
+-------+------------------- ~ ---------------------+-------+
| Pad | Scan line data bits for one colour | Pad |
| bytes | | bytes |
+-------+-------------------------------------------+-------+
-
+
When the scan line data is first processed, the colour data is copied
into the colour buffer in the position indicated above. This line of
data is padded on both ends. The size of the pad is sufficient to
account for the number of bits of head separation between the EVEN
and ODD rows of nozzles in each print head; by default 16.
-
+
The individual lines are accessed through an array of colourLines struct-
ures. This is defined in the TYPEDEFS & EXTERNAL STORAGE secion above.
-
+
The colourLines structure contains a byte pointer which points to one of
the bytes of an individual colour buffer line, and an unsigned char
which is a single bit mask isolating one bit of the byte pointed to by
the other element.
- typedef struct bufBit_s {
- byte * xByte;
- uchar xBit;
- } bufBit;
-
+ typedef struct bufBit_s {
+ byte * xByte;
+ uchar xBit;
+ } bufBit;
+
The colourLines structure holds one instance of a bufBit; it points to
the first bit of the scan line. In general, the bit pointers for the
first bit of the EVEN columns will point to the beginning of the
extracted scan line data. For the ODD columns, the first bit
will point into the leading PAD bytes by 16 bits before the start of
the actual scan line data.
-
+
In this way, all of the complications of managing the separation
between the EVEN and ODD columns on the heads is contained in the
set-up procedures for the pointers in the scanLines array. If it is
required to reverse the adjustments of EVEN and ODD columns (for bi-
directional printing, for example) this is achieved by adjusting the
firstBit entries in this array.
-
+
That, at any rate, is the theory. It seemed like a good idea at the
time.
-
+
*/
static const unsigned char init_string[] = {
- 0xa5, 0, 6, 0x40, 3, 3, 0xc0, 0x0f, 0x0f,
- 0xa5, 0, 3, 0x40, 4, 5,
- 0xa5, 0, 3, 0x40, 4, 6,
- 0xa5, 0, 3, 0x40, 4, 7,
- 0xa5, 0, 3, 0x40, 4, 8,
- 0xa5, 0, 4, 0x40, 0xe0, 0xb, 3,
- 0xa5, 0, 11, 0x40, 0xe0, 0x41, 0, 0, 0, 0, 0, 0, 0, A5_11_5000,
- 0xa5, 0, 6, 0x40, 5, 0, 0, 0x80, 0,
- 0x1b, '*', 7, 0x73, 0x30,
- 0x1b, '*', 'm', 0, 0x14, 3, 0x84, 2, 0, 1, 0xf4,
- 0x1b, '*', 7, 0x63,
- 0x1b, '*', 'm', 0, 0x42, 0, 0,
- 0xa5, 0, 5, 0x40, 0xe0, 0x80, 8, 7
+ 0xa5, 0, 6, 0x40, 3, 3, 0xc0, 0x0f, 0x0f,
+ 0xa5, 0, 3, 0x40, 4, 5,
+ 0xa5, 0, 3, 0x40, 4, 6,
+ 0xa5, 0, 3, 0x40, 4, 7,
+ 0xa5, 0, 3, 0x40, 4, 8,
+ 0xa5, 0, 4, 0x40, 0xe0, 0xb, 3,
+ 0xa5, 0, 11, 0x40, 0xe0, 0x41, 0, 0, 0, 0, 0, 0, 0, A5_11_5000,
+ 0xa5, 0, 6, 0x40, 5, 0, 0, 0x80, 0,
+ 0x1b, '*', 7, 0x73, 0x30,
+ 0x1b, '*', 'm', 0, 0x14, 3, 0x84, 2, 0, 1, 0xf4,
+ 0x1b, '*', 7, 0x63,
+ 0x1b, '*', 'm', 0, 0x42, 0, 0,
+ 0xa5, 0, 5, 0x40, 0xe0, 0x80, 8, 7
};
byte *lineBuffer;
@@ -2132,183 +2124,183 @@ lx5000_print_page( gx_device_printer *pdev, FILE *prn_stream )
bufBit colourLines[NUM_COLOURS][PENS_PER_COLOUR][COLOUR_BUF_LINES];
bool lineEmpty[ NUM_COLOURS ][ COLOUR_BUF_LINES ];
penData pens[ NUM_COLOURS ][ PENS_PER_COLOUR ];
- /* nextLineToPrint is the top unprinted line
- in the buffers. It is adjusted as lines
- are processed and printed. Its sentinel
- value is pens[YELLOW_X][LO_PEN].finalLine.
- When any line
- which is not blank is read from GS &
- processed, nextLineToPrint will be set to
- this line if it is less than the current
- value.
-
- nextLineToGet is the next scanline to read
- from GS. */
+ /* nextLineToPrint is the top unprinted line
+ in the buffers. It is adjusted as lines
+ are processed and printed. Its sentinel
+ value is pens[YELLOW_X][LO_PEN].finalLine.
+ When any line
+ which is not blank is read from GS &
+ processed, nextLineToPrint will be set to
+ this line if it is less than the current
+ value.
+
+ nextLineToGet is the next scanline to read
+ from GS. */
int nextLineToPrint;
int nextLineToGet = 0;
- /* The current bottom line position of
- the colour cartridge. */
+ /* The current bottom line position of
+ the colour cartridge. */
int bottomYellowLine;
int retval;
-
+
lx5000_device *lx5000dev = (lx5000_device *)pdev;
nextLineToPrint = pens[YELLOW_X][LO_PEN].finalLine;
bottomYellowLine = INITIAL_YELLOW_BOTTOM_LINE;
- /* Allocate the buffer storage */
+ /* Allocate the buffer storage */
if ( ( retval = getColourBufs( lx5000dev, &lineBuffer, colourBufs,
- &swipeBuffer, ALLOCATE ) ))
- return retval;
+ &swipeBuffer, ALLOCATE ) ))
+ return retval;
initPenConstants( lx5000dev, pens );
- /* Initialize the lineEmpty[] and pens[] arrays -
- should happen during parameter setup process */
+ /* Initialize the lineEmpty[] and pens[] arrays -
+ should happen during parameter setup process */
{
- int colour, pen, line;
-
- for ( colour = 0;
- colour < lx5000dev->color_info.num_components;
- colour++ )
- {
- for ( pen = 0; pen < lx5000dev->pensPerColour; pen++ )
- {
- pens[colour][pen].nextPrintLine =
- pens[YELLOW_X][LO_PEN].finalLine;
-
- pens[colour][pen].bottomLine =
- pens[colour][pen].initialBottomLine;
- pens[colour][pen].topLine =
- bottomYellowLine
- - pens[colour][pen].topToBottomYellow;
- }
- for ( line = 0; line < COLOUR_BUF_LINES; line++ )
- /* Force the zeroing of the line first time through */
- lineEmpty[colour][line] = false;
- }
+ int colour, pen, line;
+
+ for ( colour = 0;
+ colour < lx5000dev->color_info.num_components;
+ colour++ )
+ {
+ for ( pen = 0; pen < lx5000dev->pensPerColour; pen++ )
+ {
+ pens[colour][pen].nextPrintLine =
+ pens[YELLOW_X][LO_PEN].finalLine;
+
+ pens[colour][pen].bottomLine =
+ pens[colour][pen].initialBottomLine;
+ pens[colour][pen].topLine =
+ bottomYellowLine
+ - pens[colour][pen].topToBottomYellow;
+ }
+ for ( line = 0; line < COLOUR_BUF_LINES; line++ )
+ /* Force the zeroing of the line first time through */
+ lineEmpty[colour][line] = false;
+ }
}
- /* Initialize the printer and reset margins. */
+ /* Initialize the printer and reset margins. */
pageInit( (uchar)lx5000dev->alignA, (uchar)lx5000dev->alignB, prn_stream );
fwrite( init_string, 1, sizeof( init_string ), prn_stream );
- /*--------------------------------------------------------------*
- Assume that COLOUR_BUF_LINES of data are available, starting with
- nextLineToPrint. Work out which cartridge will be doing the
- printing, and how far it will have to move.
-
- Something is available to be printed. This may (should?) involve
- initial paper movement to line up the appropriate pen. Deciding
- on when to move the paper and by how much is tricky. One aim is
- to minimize paper movements.
-
- Check for black vs colour printing first. If the required
- movement for any of the colour pens is less than the required
- movement for the black pen, print a colour swathe, adjust all of
- the colour buffer values, and the nextLineToPrint value if
- necessary.
-
- Then refreshBuffer() and take another look. Sooner or later,
- the next required movement of the colour cartridge will exceed
- the movement required of the black cartridge. Print a black
- swathe. Whether to move the black cartridge for this print is
- determined by checking on the subsequent colour cartridge
- movement.
-
- If the difference between the required movement for the black
- and the required movement for the colour is less than or equal
- to one colour pen depth, do not move the pen before printing the
- black swathe.
-
- Adjust black buffer values, including nextLineToPrint, which will
- (almost?) certainly change after a black print. refreshBuffer()
- and try again.
-
- A note on 192 vs 208 black swathes. I can see the reasons for
- using the 192 swathes. When printing solid blocks with some of
- each colour and black on each scan line, use of 192 nozzles
- obviates the need for any black-related head movement. A black
- swathe can be printed on every third movement of the heads, and,
- in the circumstances sketched above, will use all 192 nozzles.
-
- Obviously, the same simple algorithm can be used when the colours
- are less densely packed. The Alignment B value, coded into the
- header of every swipe command, automatically adjusts the first
- pen of the set of 192 within a range of 0-15, so that the 192
- nozzles are symmetrically arranged with respect to the colour
- pens. The complication is that the EVEN/ODD status of the
- nozzles in the 208 set is unaffected, even though the numbering
- may change.
-
- It originally seemed to me that it was completely unnecessary
- to use the 192 nozzle set. The alignment value was needed to
- get the positioning right, but for all other purposes, the
- 208 set could be used, and adjustments made on the fly.
- However, I when considering the printing of pseudo 1200Y
- pages, which involves the use of half-height pseudo-pens, it
- became clear that the calculation of the half-height of a
- pens would be greatly simplified by the use of 192 nozzles.
- This would leave the height of a pseudo-pen at an integral
- number of 16-bit datawords.
-
- As a result, I will use 192 nozzles only when printing at
- Nx1200Ydpi.
-
- *--------------------------------------------------------------*/
+ /*--------------------------------------------------------------*
+ Assume that COLOUR_BUF_LINES of data are available, starting with
+ nextLineToPrint. Work out which cartridge will be doing the
+ printing, and how far it will have to move.
+
+ Something is available to be printed. This may (should?) involve
+ initial paper movement to line up the appropriate pen. Deciding
+ on when to move the paper and by how much is tricky. One aim is
+ to minimize paper movements.
+
+ Check for black vs colour printing first. If the required
+ movement for any of the colour pens is less than the required
+ movement for the black pen, print a colour swathe, adjust all of
+ the colour buffer values, and the nextLineToPrint value if
+ necessary.
+
+ Then refreshBuffer() and take another look. Sooner or later,
+ the next required movement of the colour cartridge will exceed
+ the movement required of the black cartridge. Print a black
+ swathe. Whether to move the black cartridge for this print is
+ determined by checking on the subsequent colour cartridge
+ movement.
+
+ If the difference between the required movement for the black
+ and the required movement for the colour is less than or equal
+ to one colour pen depth, do not move the pen before printing the
+ black swathe.
+
+ Adjust black buffer values, including nextLineToPrint, which will
+ (almost?) certainly change after a black print. refreshBuffer()
+ and try again.
+
+ A note on 192 vs 208 black swathes. I can see the reasons for
+ using the 192 swathes. When printing solid blocks with some of
+ each colour and black on each scan line, use of 192 nozzles
+ obviates the need for any black-related head movement. A black
+ swathe can be printed on every third movement of the heads, and,
+ in the circumstances sketched above, will use all 192 nozzles.
+
+ Obviously, the same simple algorithm can be used when the colours
+ are less densely packed. The Alignment B value, coded into the
+ header of every swipe command, automatically adjusts the first
+ pen of the set of 192 within a range of 0-15, so that the 192
+ nozzles are symmetrically arranged with respect to the colour
+ pens. The complication is that the EVEN/ODD status of the
+ nozzles in the 208 set is unaffected, even though the numbering
+ may change.
+
+ It originally seemed to me that it was completely unnecessary
+ to use the 192 nozzle set. The alignment value was needed to
+ get the positioning right, but for all other purposes, the
+ 208 set could be used, and adjustments made on the fly.
+ However, I when considering the printing of pseudo 1200Y
+ pages, which involves the use of half-height pseudo-pens, it
+ became clear that the calculation of the half-height of a
+ pens would be greatly simplified by the use of 192 nozzles.
+ This would leave the height of a pseudo-pen at an integral
+ number of 16-bit datawords.
+
+ As a result, I will use 192 nozzles only when printing at
+ Nx1200Ydpi.
+
+ *--------------------------------------------------------------*/
refreshBuffer( lx5000dev, &nextLineToGet, &nextLineToPrint,
- lineBuffer, colourBufs, colourLines, pens, lineEmpty );
+ lineBuffer, colourBufs, colourLines, pens, lineEmpty );
while ( nextLineToPrint < pdev->height )
{
- int blackDirection = RIGHTWARD;
- int colourDirection = LEFTWARD;
- /* Target of next move of colour cartridge */
- int nextColourLine;
- int nextBlack208Line = cartridgeMoveTo( lx5000dev, pens,
- BLACK_X,
- BLACK_X );
-
- /* In Black-only mode, cartridgeMoveTo
- will return an off-page value for the
- colour pens. */
- nextColourLine = cartridgeMoveTo( lx5000dev, pens,
- _1ST_CMY_COLOUR,
- LAST_CMY_COLOUR );
- if ( lx5000dev->isCMYK && nextColourLine <= nextBlack208Line )
- { /* Move the head & print a 3-colour swathe */
- feedPaper( lx5000dev, nextColourLine, &bottomYellowLine, pens,
- prn_stream );
- printSwipe( lx5000dev, colourBufs, colourLines, pens,
- lineEmpty, swipeBuffer,
- &nextLineToPrint, &nextLineToGet, colourDirection,
- _1ST_CMY_COLOUR, LAST_CMY_COLOUR,
- prn_stream );
- }
- else
- {
- feedPaper( lx5000dev, nextBlack208Line, &bottomYellowLine,
- pens, prn_stream );
- printSwipe( lx5000dev, colourBufs, colourLines, pens,
- lineEmpty, swipeBuffer,
- &nextLineToPrint, &nextLineToGet, blackDirection,
- BLACK_X, BLACK_X,
- prn_stream );
- }
- refreshBuffer( lx5000dev, &nextLineToGet, &nextLineToPrint,
- lineBuffer, colourBufs, colourLines, pens, lineEmpty );
+ int blackDirection = RIGHTWARD;
+ int colourDirection = LEFTWARD;
+ /* Target of next move of colour cartridge */
+ int nextColourLine;
+ int nextBlack208Line = cartridgeMoveTo( lx5000dev, pens,
+ BLACK_X,
+ BLACK_X );
+
+ /* In Black-only mode, cartridgeMoveTo
+ will return an off-page value for the
+ colour pens. */
+ nextColourLine = cartridgeMoveTo( lx5000dev, pens,
+ _1ST_CMY_COLOUR,
+ LAST_CMY_COLOUR );
+ if ( lx5000dev->isCMYK && nextColourLine <= nextBlack208Line )
+ { /* Move the head & print a 3-colour swathe */
+ feedPaper( lx5000dev, nextColourLine, &bottomYellowLine, pens,
+ prn_stream );
+ printSwipe( lx5000dev, colourBufs, colourLines, pens,
+ lineEmpty, swipeBuffer,
+ &nextLineToPrint, &nextLineToGet, colourDirection,
+ _1ST_CMY_COLOUR, LAST_CMY_COLOUR,
+ prn_stream );
+ }
+ else
+ {
+ feedPaper( lx5000dev, nextBlack208Line, &bottomYellowLine,
+ pens, prn_stream );
+ printSwipe( lx5000dev, colourBufs, colourLines, pens,
+ lineEmpty, swipeBuffer,
+ &nextLineToPrint, &nextLineToGet, blackDirection,
+ BLACK_X, BLACK_X,
+ prn_stream );
+ }
+ refreshBuffer( lx5000dev, &nextLineToGet, &nextLineToPrint,
+ lineBuffer, colourBufs, colourLines, pens, lineEmpty );
} /* ends the loop for swipes of the print head.*/
- /* Eject the page, reinitialize the printer */
+ /* Eject the page, reinitialize the printer */
pageEnd( prn_stream );
fflush( prn_stream );
getColourBufs( lx5000dev, &lineBuffer, colourBufs, &swipeBuffer,
- DEALLOCATE );
+ DEALLOCATE );
if ( lx5000dev->dryTime )
- sleep( lx5000dev->dryTime );
+ sleep( lx5000dev->dryTime );
return 0;
}
-/*
- * There are a number of parameters which can differ between ink cartridges.
+/*
+ * There are a number of parameters which can differ between ink cartridges.
* The Windows driver asks you to recalibrate every time you load a new
* cartridge.
*
@@ -2358,22 +2350,22 @@ lx5000_print_page( gx_device_printer *pdev, FILE *prn_stream )
static int
lx5000_get_params( gx_device *pdev, gs_param_list *plist )
/*----------------------------------------------------------------------*/
-{
+{
lx5000_device *lx5000dev = (lx5000_device *)pdev;
int code = gdev_prn_get_params( pdev, plist );
if ( code < 0 ||
- ( code =
- param_write_int( plist, "HeadSeparation",
- &lx5000dev->headSeparation )) < 0 ||
- ( code = param_write_int(plist, "AlignA", &lx5000dev->alignA)) < 0 ||
- ( code = param_write_int(plist, "AlignB", &lx5000dev->alignB)) < 0 ||
- ( code = param_write_bool( plist, "CMYK", &lx5000dev->isCMYK )) < 0 ||
- ( code = param_write_bool( plist,
- "DryingTime", &lx5000dev->dryTime )) < 0
- )
- return code;
-
+ ( code =
+ param_write_int( plist, "HeadSeparation",
+ &lx5000dev->headSeparation )) < 0 ||
+ ( code = param_write_int(plist, "AlignA", &lx5000dev->alignA)) < 0 ||
+ ( code = param_write_int(plist, "AlignB", &lx5000dev->alignB)) < 0 ||
+ ( code = param_write_bool( plist, "CMYK", &lx5000dev->isCMYK )) < 0 ||
+ ( code = param_write_bool( plist,
+ "DryingTime", &lx5000dev->dryTime )) < 0
+ )
+ return code;
+
return code;
}
@@ -2382,28 +2374,28 @@ lx5000_get_params( gx_device *pdev, gs_param_list *plist )
*----------------------------------------------------------------------*/
static int
lx5000_put_param_int(
- gs_param_list *plist, gs_param_name pname,
- int *pvalue, int minval, int maxval, int ecode
- )
+ gs_param_list *plist, gs_param_name pname,
+ int *pvalue, int minval, int maxval, int ecode
+ )
/*----------------------------------------------------------------------*/
{
int code, value;
-
+
switch ( code = param_read_int( plist, pname, &value ) )
{
default:
- return code;
+ return code;
case 0:
- if ( value < minval || value > maxval )
- {
- code =
- param_signal_error( plist, pname, gs_error_rangecheck );
- ecode = ( code < 0 ? code : ecode );
- }
- else
- *pvalue = value;
+ if ( value < minval || value > maxval )
+ {
+ code =
+ param_signal_error( plist, pname, gs_error_rangecheck );
+ ecode = ( code < 0 ? code : ecode );
+ }
+ else
+ *pvalue = value;
case 1:
- return ecode;
+ return ecode;
}
}
@@ -2412,9 +2404,9 @@ lx5000_put_param_int(
*----------------------------------------------------------------------*/
static int
lx5000_put_param_bool(
- gs_param_list *plist, gs_param_name pname,
- bool *pvalue, int ecode
- )
+ gs_param_list *plist, gs_param_name pname,
+ bool *pvalue, int ecode
+ )
/*----------------------------------------------------------------------*/
{
int code;
@@ -2422,12 +2414,12 @@ lx5000_put_param_bool(
switch ( code = param_read_bool( plist, pname, pvalue ) )
{
default:
- ecode = code;
- param_signal_error(plist, pname, ecode);
- return code;
+ ecode = code;
+ param_signal_error(plist, pname, ecode);
+ return code;
case 1:
case 0:
- return ecode;
+ return ecode;
}
}
@@ -2453,119 +2445,118 @@ lx5000_put_params( gx_device *pdev, gs_param_list *plist )
bool isCMYK_old = isCMYK;
code = lx5000_put_param_int( plist, "HeadSeparation", &headSeparation,
- 8, 24, code ); /* 8 - 24 columns */
+ 8, 24, code ); /* 8 - 24 columns */
code = lx5000_put_param_int( plist, "AlignA", &alignA, 0, 30, code );
- /* 0 - 30 columns */
+ /* 0 - 30 columns */
code = lx5000_put_param_int( plist, "AlignB", &alignB, 0, 15, code );
- /* 0 -15 nozzles */
+ /* 0 -15 nozzles */
code = lx5000_put_param_int( plist, "DryingTime", &dryTime, 0, 60, code );
- /* 0 -60 seconds */
+ /* 0 -60 seconds */
code = lx5000_put_param_int
- ( plist, "BitsPerPixel", &bitsPerPixel, 1, 4, code );
- /* Black cartridge only */
+ ( plist, "BitsPerPixel", &bitsPerPixel, 1, 4, code );
+ /* Black cartridge only */
code = lx5000_put_param_bool( plist, "CMYK", &isCMYK, code );
- /* Black cartridge only */
+ /* Black cartridge only */
/* Take precautions against input errors */
if ( bitsPerPixel != 1 ) { bitsPerPixel = 4; }
if ( isCMYK != isCMYK_old || bitsPerPixel != oldBPP )
{
- bool isCMYK_new;
- /* What has changed? Assume that initial values were consistent,
- and set isCMYK to a value consistent with the changed args
- If both have changed, give precedence to isCMYK
- */
- if ( bitsPerPixel != oldBPP )
- {
- if ( bitsPerPixel == 1 )
- { isCMYK_new = false; }
- else
- { isCMYK_new = true; };
- }
- if ( isCMYK != isCMYK_old )
- { isCMYK_new = isCMYK; }
-
- isCMYK = isCMYK_new;
- bitsPerPixel = isCMYK ? 4 : 1;
-
- if ( isCMYK )
- {
- lx5000dev->color_info = color_info_cmy;
- dev_proc(pdev, map_cmyk_color) = lx5000_map_cmyk_color;
- dev_proc(pdev, map_rgb_color) = NULL;
- dev_proc(pdev, map_color_rgb) = lx5000_map_color_rgb;
- }
- else
- {
- lx5000dev->color_info = color_info_blk;
- dev_proc(pdev, map_cmyk_color) = NULL;
- dev_proc(pdev, map_rgb_color) = gdev_prn_map_rgb_color;
- dev_proc(pdev, map_color_rgb) = gdev_prn_map_color_rgb;
- }
- if ( pdev->is_open )
- gs_closedevice(pdev);
+ bool isCMYK_new;
+ /* What has changed? Assume that initial values were consistent,
+ and set isCMYK to a value consistent with the changed args
+ If both have changed, give precedence to isCMYK
+ */
+ if ( bitsPerPixel != oldBPP )
+ {
+ if ( bitsPerPixel == 1 )
+ { isCMYK_new = false; }
+ else
+ { isCMYK_new = true; };
+ }
+ if ( isCMYK != isCMYK_old )
+ { isCMYK_new = isCMYK; }
+
+ isCMYK = isCMYK_new;
+ bitsPerPixel = isCMYK ? 4 : 1;
+
+ if ( isCMYK )
+ {
+ lx5000dev->color_info = color_info_cmy;
+ dev_proc(pdev, map_cmyk_color) = lx5000_map_cmyk_color;
+ dev_proc(pdev, map_rgb_color) = NULL;
+ dev_proc(pdev, map_color_rgb) = lx5000_map_color_rgb;
+ }
+ else
+ {
+ lx5000dev->color_info = color_info_blk;
+ dev_proc(pdev, map_cmyk_color) = NULL;
+ dev_proc(pdev, map_rgb_color) = gdev_prn_map_rgb_color;
+ dev_proc(pdev, map_color_rgb) = gdev_prn_map_color_rgb;
+ }
+ if ( pdev->is_open )
+ gs_closedevice(pdev);
}
- /* call super class put_params */
+ /* call super class put_params */
ecode = gdev_prn_put_params( pdev, plist );
if ( ecode < 0 || code < 0 )
{
- if ( isCMYK != isCMYK_old )
- {
- if ( ! isCMYK )
- {
- lx5000dev->color_info = color_info_cmy;
- dev_proc(pdev, map_cmyk_color) = lx5000_map_cmyk_color;
- dev_proc(pdev, map_rgb_color) = NULL;
- dev_proc(pdev, map_color_rgb) = lx5000_map_color_rgb;
- }
- else
- {
- lx5000dev->color_info = color_info_blk;
- dev_proc(pdev, map_cmyk_color) = NULL;
- dev_proc(pdev, map_rgb_color) = gdev_prn_map_rgb_color;
- dev_proc(pdev, map_color_rgb) = gdev_prn_map_color_rgb;
- }
- if ( pdev->is_open )
- gs_closedevice(pdev);
- }
- return ecode < 0 ? ecode : code;
+ if ( isCMYK != isCMYK_old )
+ {
+ if ( ! isCMYK )
+ {
+ lx5000dev->color_info = color_info_cmy;
+ dev_proc(pdev, map_cmyk_color) = lx5000_map_cmyk_color;
+ dev_proc(pdev, map_rgb_color) = NULL;
+ dev_proc(pdev, map_color_rgb) = lx5000_map_color_rgb;
+ }
+ else
+ {
+ lx5000dev->color_info = color_info_blk;
+ dev_proc(pdev, map_cmyk_color) = NULL;
+ dev_proc(pdev, map_rgb_color) = gdev_prn_map_rgb_color;
+ dev_proc(pdev, map_color_rgb) = gdev_prn_map_color_rgb;
+ }
+ if ( pdev->is_open )
+ gs_closedevice(pdev);
+ }
+ return ecode < 0 ? ecode : code;
}
- /* looks like everything okay; */
- /* go ahead and set parameters */
+ /* looks like everything okay; */
+ /* go ahead and set parameters */
lx5000dev->headSeparation = headSeparation;
lx5000dev->alignA = alignA;
lx5000dev->alignB = alignB;
lx5000dev->dryTime = dryTime;
lx5000dev->isCMYK = isCMYK;
- /* N.B. I am only setting these values here -
- should they also be set as part of the "two
- phase commit" of parameter changes? My
- code is the only place these things are
- accessed. */
+ /* N.B. I am only setting these values here -
+ should they also be set as part of the "two
+ phase commit" of parameter changes? My
+ code is the only place these things are
+ accessed. */
if ( lx5000dev->y_pixels_per_inch == MAX_LX5000_Y )
{
- lx5000dev->pensPerColour = 2;
- lx5000dev->lineIncrement = 2;
+ lx5000dev->pensPerColour = 2;
+ lx5000dev->lineIncrement = 2;
}
else
{
- lx5000dev->pensPerColour = 1;
- lx5000dev->lineIncrement = 1;
+ lx5000dev->pensPerColour = 1;
+ lx5000dev->lineIncrement = 1;
}
- if ( code == 1 ) return ecode;
+ if ( code == 1 ) return ecode;
return 0;
}
-
/*----------------------------------------------------------------------*
* The following colour handling procedures are lifted from gdevbit.c
*----------------------------------------------------------------------*/
@@ -2573,7 +2564,7 @@ lx5000_put_params( gx_device *pdev, gs_param_list *plist )
/* used, we do a case test rather than providing 3 separate routines. */
static int
lx5000_map_color_rgb(gx_device * dev, gx_color_index color,
- gx_color_value rgb[3])
+ gx_color_value rgb[3])
{
int depth = dev->color_info.depth;
int ncomp = dev->color_info.num_components;
@@ -2611,7 +2602,7 @@ lx5000_map_cmyk_color(gx_device * dev, const gx_color_value cv[])
gx_color_value cyan = cv[0], magenta = cv[1], yellow = cv[2], black = cv[3];
gx_color_index color =
((((((cyan >> drop) << bpc) +
- (magenta >> drop)) << bpc) +
+ (magenta >> drop)) << bpc) +
(yellow >> drop)) << bpc) +
(black >> drop);