23 #ifdef __GO32__ // dos386/djgpp
31 "ljiip:LaserJet IIp/deskjet compressed graphics:0:ljiip:32:ljiip\n";
38 void plD_line_ljiip(
PLStream *,
short,
short,
short,
short );
39 void plD_polyline_ljiip(
PLStream *,
short *,
short *,
PLINT );
64 #define OF pls->OutFile
65 #define CURX ( (long) ( DPI / 5 ) )
66 #define CURY ( (long) ( DPI / 7 ) )
67 #define XDOTS ( 376 * ( DPI / 50 ) ) // # dots across
68 #define YDOTS ( 500 * ( DPI / 50 ) ) // # dots down
69 #define JETX ( XDOTS - 1 )
70 #define JETY ( YDOTS - 1 )
73 #define BPROW ( XDOTS / 8L ) // # bytes across
74 #define MAX_WID 8 // max pen width in pixels
75 #define BPROW1 ( BPROW + ( MAX_WID + 7 ) / 8 ) // pen has width, make bitmap bigger
76 #define NBYTES BPROW1 * ( YDOTS + MAX_WID ) // total number of bytes
84 {
'\200',
'\100',
'\040',
'\020',
'\010',
'\004',
'\002',
'\001' };
92 static unsigned char _HUGE *bitmap;
96 #ifndef ENABLE_DYNDRIVERS
97 pdt->
pl_MenuStr =
"LaserJet IIp/deskjet compressed graphics";
123 if ( pls->
width == 0 )
174 if ( ( bitmap = (
unsigned char _HUGE *)
175 halloc( (
long) NBYTES,
sizeof (
char ) ) ) == NULL )
176 plexit(
"Out of memory in call to calloc" );
178 if ( ( bitmap = (
unsigned char *) calloc( NBYTES,
sizeof (
char ) ) ) == NULL )
179 plexit(
"Out of memory in call to calloc" );
184 fprintf(
OF,
"%cE", ESC );
194 plD_line_ljiip(
PLStream *pls,
short x1a,
short y1a,
short x2a,
short y2a )
197 int x1 = x1a, y1 = y1a, x2 = x2a, y2 = y2a;
198 int abs_dx, abs_dy,
dx,
dy, incx, incy;
199 int i, j, width, residual;
206 y1 = dev->
ymax - ( y1 - dev->
ymin );
207 y2 = dev->
ymax - ( y2 - dev->
ymin );
240 if ( abs_dy <= abs_dx )
245 tmp = 1.0 - (
PLFLT) abs_dy / abs_dx;
249 tmp = 1.0 - (
PLFLT) abs_dx / abs_dy;
252 width = floor( 0.5 + width * ( tmp * tmp * tmp * ( 1.0 - 0.707107 ) + 0.707107 ) );
258 for ( i = 0; i < width; i++ )
260 for ( j = 0; j < width; j++ )
262 setpoint( (
PLINT) ( x1 + i ), (
PLINT) ( y1 + j ) );
263 setpoint( (
PLINT) ( x2 + i ), (
PLINT) ( y2 + j ) );
267 if ( abs_dx >= abs_dy )
269 residual = -( abs_dx >> 1 );
272 for ( i = 0; i <= abs_dx; i++, x1 += incx )
275 if ( ( residual += abs_dy ) >= 0 )
284 for ( i = 0; i <= abs_dx; i++, x1 += incx )
286 for ( j = 0; j < width; j++ )
288 setpoint( (
PLINT) ( x1 ), (
PLINT) ( y1 + j ) );
289 setpoint( (
PLINT) ( x1 + width - 1 ), (
PLINT) ( y1 + j ) );
291 if ( ( residual += abs_dy ) >= 0 )
301 residual = -( abs_dy >> 1 );
304 for ( i = 0; i <= abs_dy; i++, y1 += incy )
307 if ( ( residual += abs_dx ) >= 0 )
316 for ( i = 0; i <= abs_dy; i++, y1 += incy )
318 for ( j = 0; j < width; j++ )
320 setpoint( (
PLINT) ( x1 + j ), (
PLINT) ( y1 ) );
321 setpoint( (
PLINT) ( x1 + j ), (
PLINT) ( y1 + width - 1 ) );
323 if ( ( residual += abs_dx ) >= 0 )
340 plD_polyline_ljiip(
PLStream *pls,
short *xa,
short *ya,
PLINT npts )
344 for ( i = 0; i < npts - 1; i++ )
345 plD_line_ljiip( pls, xa[i], ya[i], xa[i + 1], ya[i + 1] );
358 unsigned char _HUGE *p;
360 int i, iy, last,
n, jmax;
361 unsigned char _HUGE t_buf[BPROW * 2];
367 fprintf(
OF,
"\033*rB" );
368 fprintf(
OF,
"\033*t%3dR",
DPI );
371 fprintf(
OF,
"\033*r%dS", XDOTS );
372 fprintf(
OF,
"\033*b%1dM", GCMODE );
377 fprintf(
OF,
"\033*p%ldX", CURX );
378 fprintf(
OF,
"\033*p%ldY", CURY );
379 fprintf(
OF,
"\033*r0A" );
384 for ( j = 0, p = bitmap; j < YDOTS; j++, p += BPROW1 )
386 fprintf(
OF,
"\033*b>%dW", BPROW );
387 fwrite( p, BPROW,
sizeof (
char ),
OF );
391 for ( iy = 0, p = bitmap; iy < YDOTS; iy++, p += BPROW1 )
396 while ( last > 0 && p[last] == 0 )
407 jmax = last < jmax ? last : jmax;
408 if ( i < last - 2 && ( c == p[i + 1] ) && ( c == p[i + 2] ) )
411 while ( j < jmax && c == p[j] )
413 t_buf[n++] = ( i - j + 1 ) & 0xff;
419 for ( j = i + 1; j < jmax; j++ )
421 if ( j < last - 2 && ( p[j] == p[j + 1] ) &&
422 ( p[j + 1] == p[j + 2] ) )
425 t_buf[n++] = j - i - 1;
432 fprintf(
OF,
"\033*b%dW", (
int) n );
433 fwrite( t_buf, (
int) n,
sizeof (
char ),
OF );
441 fprintf(
OF,
"\033*rB" );
442 fprintf(
OF,
"%c", FF );
446 memset( (
void *) bitmap,
'\0', NBYTES );
476 fprintf(
OF,
"%cE", ESC );
478 free( (
char *) bitmap );
513 index = x / 8 + y * BPROW1;
514 *( bitmap + index ) = *( bitmap + index ) | mask[x % 8];