21 #ifdef __GO32__ // dos386/djgpp
29 "ljiip:LaserJet IIp/deskjet compressed graphics:0:ljiip:32:ljiip\n";
36 void plD_line_ljiip(
PLStream *,
short,
short,
short,
short );
37 void plD_polyline_ljiip(
PLStream *,
short *,
short *,
PLINT );
62 #define OF pls->OutFile
63 #define CURX ( (long) ( DPI / 5 ) )
64 #define CURY ( (long) ( DPI / 7 ) )
65 #define XDOTS ( 376 * ( DPI / 50 ) ) // # dots across
66 #define YDOTS ( 500 * ( DPI / 50 ) ) // # dots down
67 #define JETX ( XDOTS - 1 )
68 #define JETY ( YDOTS - 1 )
71 #define BPROW ( XDOTS / 8L ) // # bytes across
72 #define MAX_WID 8 // max pen width in pixels
73 #define BPROW1 ( BPROW + ( MAX_WID + 7 ) / 8 ) // pen has width, make bitmap bigger
74 #define NBYTES BPROW1 * ( YDOTS + MAX_WID ) // total number of bytes
82 {
'\200',
'\100',
'\040',
'\020',
'\010',
'\004',
'\002',
'\001' };
90 static unsigned char _HUGE *bitmap;
94 #ifndef ENABLE_DYNDRIVERS
95 pdt->
pl_MenuStr =
"LaserJet IIp/deskjet compressed graphics";
121 if ( pls->
width == 0 )
172 if ( ( bitmap = (
unsigned char _HUGE *)
173 halloc( (
long) NBYTES,
sizeof (
char ) ) ) == NULL )
174 plexit(
"Out of memory in call to calloc" );
176 if ( ( bitmap = (
unsigned char *) calloc( NBYTES,
sizeof (
char ) ) ) == NULL )
177 plexit(
"Out of memory in call to calloc" );
182 fprintf(
OF,
"%cE", ESC );
192 plD_line_ljiip(
PLStream *pls,
short x1a,
short y1a,
short x2a,
short y2a )
195 int x1 = x1a, y1 = y1a, x2 = x2a, y2 = y2a;
196 int abs_dx, abs_dy,
dx,
dy, incx, incy;
197 int i, j, width, residual;
204 y1 = dev->
ymax - ( y1 - dev->
ymin );
205 y2 = dev->
ymax - ( y2 - dev->
ymin );
238 if ( abs_dy <= abs_dx )
243 tmp = 1.0 - (
PLFLT) abs_dy / abs_dx;
247 tmp = 1.0 - (
PLFLT) abs_dx / abs_dy;
250 width = floor( 0.5 + width * ( tmp * tmp * tmp * ( 1.0 - 0.707107 ) + 0.707107 ) );
256 for ( i = 0; i < width; i++ )
258 for ( j = 0; j < width; j++ )
260 setpoint( (
PLINT) ( x1 + i ), (
PLINT) ( y1 + j ) );
261 setpoint( (
PLINT) ( x2 + i ), (
PLINT) ( y2 + j ) );
265 if ( abs_dx >= abs_dy )
267 residual = -( abs_dx >> 1 );
270 for ( i = 0; i <= abs_dx; i++, x1 += incx )
273 if ( ( residual += abs_dy ) >= 0 )
282 for ( i = 0; i <= abs_dx; i++, x1 += incx )
284 for ( j = 0; j < width; j++ )
286 setpoint( (
PLINT) ( x1 ), (
PLINT) ( y1 + j ) );
287 setpoint( (
PLINT) ( x1 + width - 1 ), (
PLINT) ( y1 + j ) );
289 if ( ( residual += abs_dy ) >= 0 )
299 residual = -( abs_dy >> 1 );
302 for ( i = 0; i <= abs_dy; i++, y1 += incy )
305 if ( ( residual += abs_dx ) >= 0 )
314 for ( i = 0; i <= abs_dy; i++, y1 += incy )
316 for ( j = 0; j < width; j++ )
318 setpoint( (
PLINT) ( x1 + j ), (
PLINT) ( y1 ) );
319 setpoint( (
PLINT) ( x1 + j ), (
PLINT) ( y1 + width - 1 ) );
321 if ( ( residual += abs_dx ) >= 0 )
338 plD_polyline_ljiip(
PLStream *pls,
short *xa,
short *ya,
PLINT npts )
342 for ( i = 0; i < npts - 1; i++ )
343 plD_line_ljiip( pls, xa[i], ya[i], xa[i + 1], ya[i + 1] );
356 unsigned char _HUGE *p;
358 int i, iy, last,
n, jmax;
359 unsigned char _HUGE t_buf[BPROW * 2];
365 fprintf(
OF,
"\033*rB" );
366 fprintf(
OF,
"\033*t%3dR",
DPI );
369 fprintf(
OF,
"\033*r%dS", XDOTS );
370 fprintf(
OF,
"\033*b%1dM", GCMODE );
375 fprintf(
OF,
"\033*p%ldX", CURX );
376 fprintf(
OF,
"\033*p%ldY", CURY );
377 fprintf(
OF,
"\033*r0A" );
382 for ( j = 0, p = bitmap; j < YDOTS; j++, p += BPROW1 )
384 fprintf(
OF,
"\033*b>%dW", BPROW );
385 fwrite( p, BPROW,
sizeof (
char ),
OF );
389 for ( iy = 0, p = bitmap; iy < YDOTS; iy++, p += BPROW1 )
394 while ( last > 0 && p[last] == 0 )
405 jmax = last < jmax ? last : jmax;
406 if ( i < last - 2 && ( c == p[i + 1] ) && ( c == p[i + 2] ) )
409 while ( j < jmax && c == p[j] )
411 t_buf[n++] = ( i - j + 1 ) & 0xff;
417 for ( j = i + 1; j < jmax; j++ )
419 if ( j < last - 2 && ( p[j] == p[j + 1] ) &&
420 ( p[j + 1] == p[j + 2] ) )
423 t_buf[n++] = j - i - 1;
430 fprintf(
OF,
"\033*b%dW", (
int) n );
431 fwrite( t_buf, (
int) n,
sizeof (
char ),
OF );
439 fprintf(
OF,
"\033*rB" );
440 fprintf(
OF,
"%c", FF );
444 memset( (
void *) bitmap,
'\0', NBYTES );
474 fprintf(
OF,
"%cE", ESC );
476 free( (
char *) bitmap );
511 index = x / 8 + y * BPROW1;
512 *( bitmap + index ) = *( bitmap + index ) | mask[x % 8];