24 PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_mem =
"mem:User-supplied memory device:-1:mem:46:mem\n";
29 void plD_line_mem(
PLStream *,
short,
short,
short,
short );
39 #define MAX( a, b ) ( ( a > b ) ? a : b )
40 #define ABS( a ) ( ( a < 0 ) ? -a : a )
42 #define MAX_INTENSITY 255
46 #ifndef ENABLE_DYNDRIVERS
47 pdt->
pl_MenuStr =
"User-supplied memory device";
76 if ( ( pls->
phyxma == 0 ) || ( pls->
dev == NULL ) )
78 plexit(
"Must call plsmem first to set user plotting area!" );
83 plexit(
"The mem driver does not support alpha values! Use plsmem!" );
95 #define sign( a ) ( ( a < 0 ) ? -1 : ( ( a == 0 ) ? 0 : 1 ) )
99 plD_line_mem(
PLStream *pls,
short x1a,
short y1a,
short x2a,
short y2a )
103 int x1 = x1a, y1 = y1a, x2 = x2a, y2 = y2a;
104 PLINT x1b, y1b, x2b, y2b;
106 unsigned char *mem = (
unsigned char *) pls->
dev;
112 y1 = ym - ( y1 - 0 );
113 y2 = ym - ( y2 - 0 );
115 x1b = x1, x2b = x2, y1b = y1, y2b = y2;
116 length = (
PLFLT) sqrt( (
double)
117 ( ( x2b - x1b ) * ( x2b - x1b ) + ( y2b - y1b ) * ( y2b - y1b ) ) );
121 dx = ( x2 - x1 ) / length;
122 dy = ( y2 - y1 ) / length;
126 mem[3 * xm * y1 + 3 * x1 + 0] = pls->
curcolor.
r;
127 mem[3 * xm * y1 + 3 * x1 + 1] = pls->
curcolor.
g;
128 mem[3 * xm * y1 + 3 * x1 + 2] = pls->
curcolor.
b;
130 mem[3 * xm * y2 + 3 * x2 + 0] = pls->
curcolor.
r;
131 mem[3 * xm * y2 + 3 * x2 + 1] = pls->
curcolor.
g;
132 mem[3 * xm * y2 + 3 * x2 + 2] = pls->
curcolor.
b;
134 for ( i = 1; i <= (int) length; i++ )
139 mem[idx + 0] = pls->curcolor.r;
140 mem[idx + 1] = pls->curcolor.g;
141 mem[idx + 2] = pls->curcolor.b;
146 plD_polyline_mem(
PLStream *pls,
short *xa,
short *ya,
PLINT npts )
149 for ( i = 0; i < npts - 1; i++ )
150 plD_line_mem( pls, xa[i], ya[i], xa[i + 1], ya[i + 1] );