1
/* $Id: plbuf.c,v 1.3 2004/01/31 06:39:53 airwin Exp $
1
/* $Id: plbuf.c,v 1.10 2005/05/10 12:37:41 tomduck Exp $
5
5
Copyright (C) 1992 Maurice LeBrun
6
6
Copyright (C) 2004 Alan W. Irwin
7
Copyright (C) 2005 Thomas J. Duck
8
9
This file is part of PLplot.
20
21
You should have received a copy of the GNU Library General Public License
21
22
along with PLplot; if not, write to the Free Software
22
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25
26
#define NEED_PLDEBUG
191
192
case PLSTATE_COLOR0: {
192
U_CHAR icol0 = pls->icol0;
193
short icol0 = pls->icol0;
193
194
U_CHAR r = pls->curcolor.r;
194
195
U_CHAR g = pls->curcolor.g;
195
196
U_CHAR b = pls->curcolor.b;
197
fwrite(&icol0, sizeof(U_CHAR), 1, pls->plbufFile);
198
fwrite(&icol0, sizeof(short), 1, pls->plbufFile);
198
199
if (icol0 == PL_RGB_COLOR) {
199
200
fwrite(&r, sizeof(U_CHAR), 1, pls->plbufFile);
200
201
fwrite(&g, sizeof(U_CHAR), 1, pls->plbufFile);
253
254
/*--------------------------------------------------------------------------*\
258
\*--------------------------------------------------------------------------*/
261
plbuf_text(PLStream *pls, EscText *text)
266
dbug_enter("plbuf_text");
268
/* Retrieve the font characterization integer */
271
/* Write the text information */
273
fwrite(&fci, sizeof(PLUNICODE), 1, pls->plbufFile);
275
fwrite(&pls->chrht, sizeof(PLFLT), 1, pls->plbufFile);
276
fwrite(&pls->diorot, sizeof(PLFLT), 1, pls->plbufFile);
277
fwrite(&pls->clpxmi, sizeof(PLFLT), 1, pls->plbufFile);
278
fwrite(&pls->clpxma, sizeof(PLFLT), 1, pls->plbufFile);
279
fwrite(&pls->clpymi, sizeof(PLFLT), 1, pls->plbufFile);
280
fwrite(&pls->clpyma, sizeof(PLFLT), 1, pls->plbufFile);
282
fwrite(&text->base, sizeof(PLINT), 1, pls->plbufFile);
283
fwrite(&text->just, sizeof(PLFLT), 1, pls->plbufFile);
284
fwrite(text->xform, sizeof(PLFLT), 4, pls->plbufFile);
285
fwrite(&text->x, sizeof(PLINT), 1, pls->plbufFile);
286
fwrite(&text->y, sizeof(PLINT), 1, pls->plbufFile);
287
fwrite(&text->refx, sizeof(PLINT), 1, pls->plbufFile);
288
fwrite(&text->refy, sizeof(PLINT), 1, pls->plbufFile);
290
fwrite(&text->unicode_array_len, sizeof(PLINT), 1, pls->plbufFile);
291
if(text->unicode_array_len)
292
fwrite(text->unicode_array, sizeof(PLUNICODE),
293
text->unicode_array_len, pls->plbufFile);
296
/*--------------------------------------------------------------------------*\
256
299
* Escape function. Note that any data written must be in device
433
481
case PLSTATE_COLOR0:{
434
U_CHAR icol0, r, g, b;
436
fread(&icol0, sizeof(U_CHAR), 1, pls->plbufFile);
485
fread(&icol0, sizeof(short), 1, pls->plbufFile);
437
486
if (icol0 == PL_RGB_COLOR) {
438
487
fread(&r, sizeof(U_CHAR), 1, pls->plbufFile);
439
488
fread(&g, sizeof(U_CHAR), 1, pls->plbufFile);
440
489
fread(&b, sizeof(U_CHAR), 1, pls->plbufFile);
443
if ((int) icol0 < 0 || (int) icol0 >= pls->ncol0) {
445
sprintf(buffer, "rdbuf_state: Invalid color map entry: %d", (int) icol0);
492
if ((int) icol0 >= pls->ncol0) {
494
sprintf(buffer, "rdbuf_state: Invalid color map entry: %d", (int) icol0);
449
498
r = pls->cmap0[icol0].r;
450
499
g = pls->cmap0[icol0].g;
558
614
rdbuf_image(PLStream *pls)
560
short *dev_ix, *dev_iy;
561
unsigned short *dev_z, dev_zmin, dev_zmax;
562
PLINT nptsX,nptsY, npts;
563
PLFLT xmin, ymin, dx, dy;
616
short *dev_ix, *dev_iy;
617
unsigned short *dev_z, dev_zmin, dev_zmax;
618
PLINT nptsX,nptsY, npts;
619
PLFLT xmin, ymin, dx, dy;
565
621
dbug_enter("rdbuf_image");
618
674
/*--------------------------------------------------------------------------*\
677
* Draw PostScript text.
678
\*--------------------------------------------------------------------------*/
681
rdbuf_text(PLStream *pls)
692
/* Read in the data */
694
fread(&fci, sizeof(PLUNICODE), 1, pls->plbufFile);
696
fread(&pls->chrht, sizeof(PLFLT), 1, pls->plbufFile);
697
fread(&pls->diorot, sizeof(PLFLT), 1, pls->plbufFile);
698
fread(&pls->clpxmi, sizeof(PLFLT), 1, pls->plbufFile);
699
fread(&pls->clpxma, sizeof(PLFLT), 1, pls->plbufFile);
700
fread(&pls->clpymi, sizeof(PLFLT), 1, pls->plbufFile);
701
fread(&pls->clpyma, sizeof(PLFLT), 1, pls->plbufFile);
703
fread(&text.base, sizeof(PLINT), 1, pls->plbufFile);
704
fread(&text.just, sizeof(PLFLT), 1, pls->plbufFile);
705
fread(text.xform, sizeof(PLFLT), 4, pls->plbufFile);
706
fread(&text.x, sizeof(PLINT), 1, pls->plbufFile);
707
fread(&text.y, sizeof(PLINT), 1, pls->plbufFile);
708
fread(&text.refx, sizeof(PLINT), 1, pls->plbufFile);
709
fread(&text.refy, sizeof(PLINT), 1, pls->plbufFile);
711
fread(&text.unicode_array_len, sizeof(PLINT), 1, pls->plbufFile);
712
if(text.unicode_array_len) {
713
if((unicode=(PLUNICODE *)malloc(text.unicode_array_len*sizeof(PLUNICODE)))
715
plexit("rdbuf_text: Insufficient memory");
717
fread(unicode, sizeof(PLUNICODE), text.unicode_array_len, pls->plbufFile);
718
text.unicode_array = unicode;
720
else text.unicode_array = NULL;
722
/* Make the call for unicode devices */
723
if(pls->dev_unicode) {
725
plP_esc(PLESC_HAS_TEXT,&text);
729
/*--------------------------------------------------------------------------*\
621
732
* Rebuilds plot from plot buffer, usually in response to a window