The R Project SVN R

Rev

Rev 15394 | Rev 15657 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 15394 Rev 15641
Line 47... Line 47...
47
{
47
{
48
    user_xpinch = xpinch;
48
    user_xpinch = xpinch;
49
    user_ypinch = ypinch;
49
    user_ypinch = ypinch;
50
}
50
}
51
 
51
 
-
 
52
static rgb GArgb(int color, double gamma)
-
 
53
{
-
 
54
    int r, g, b;
-
 
55
    if (gamma != 1) {
-
 
56
	r = (int) (255 * pow(R_RED(color) / 255.0, gamma));
-
 
57
	g = (int) (255 * pow(R_GREEN(color) / 255.0, gamma));
-
 
58
	b = (int) (255 * pow(R_BLUE(color) / 255.0, gamma));
-
 
59
    } else {
-
 
60
	r = R_RED(color);
-
 
61
	g = R_GREEN(color);
-
 
62
	b = R_BLUE(color);
-
 
63
    }
-
 
64
    return rgb(r, g, b);
-
 
65
}
-
 
66
 
52
 
67
 
53
 
68
 
54
	/********************************************************/
69
	/********************************************************/
55
	/* This device driver has been documented so that it be	*/
70
	/* This device driver has been documented so that it be	*/
56
	/* used as a template for new drivers 			*/
71
	/* used as a template for new drivers 			*/
Line 90... Line 105...
90
    int   bg;			   /* Background */
105
    int   bg;			   /* Background */
91
    int   fontface;		   /* Typeface */
106
    int   fontface;		   /* Typeface */
92
    int   fontsize, basefontsize;  /* Size in points */
107
    int   fontsize, basefontsize;  /* Size in points */
93
    double fontangle;
108
    double fontangle;
94
 
109
 
95
    /* X11 Driver Specific */
110
    /* devga Driver Specific */
96
    /* parameters with copy per x11 device */
111
    /* parameters with copy per devga device */
97
 
112
 
98
    enum DeviceKinds kind;
113
    enum DeviceKinds kind;
99
    int   windowWidth;		/* Window width (pixels) */
114
    int   windowWidth;		/* Window width (pixels) */
100
    int   windowHeight;		/* Window height (pixels) */
115
    int   windowHeight;		/* Window height (pixels) */
101
    int   showWidth;		/* device width (pixels) */
116
    int   showWidth;		/* device width (pixels) */
Line 121... Line 136...
121
    int quality;
136
    int quality;
122
  /* Used to rescale font size so that bitmap devices have 72dpi */
137
  /* Used to rescale font size so that bitmap devices have 72dpi */
123
    int truedpi, wanteddpi; 
138
    int truedpi, wanteddpi; 
124
    rgb   fgcolor;		/* Foreground color */
139
    rgb   fgcolor;		/* Foreground color */
125
    rgb   bgcolor;		/* Background color */
140
    rgb   bgcolor;		/* Background color */
-
 
141
    rgb   canvascolor;		/* Canvas color */
-
 
142
    rgb   outcolor;		/* Outside canvas color */
126
    rect  clip;			/* The clipping rectangle */
143
    rect  clip;			/* The clipping rectangle */
127
    Rboolean usefixed;
144
    Rboolean usefixed;
128
    font  fixedfont;
145
    font  fixedfont;
129
    font  font;
146
    font  font;
130
    Rboolean locator;
147
    Rboolean locator;
Line 167... Line 184...
167
static void   GA_Line(double, double, double, double, int, DevDesc*);
184
static void   GA_Line(double, double, double, double, int, DevDesc*);
168
static Rboolean GA_Locator(double*, double*, DevDesc*);
185
static Rboolean GA_Locator(double*, double*, DevDesc*);
169
static void   GA_Mode(int);
186
static void   GA_Mode(int);
170
static void   GA_NewPage(DevDesc*);
187
static void   GA_NewPage(DevDesc*);
171
static Rboolean GA_Open(DevDesc*, gadesc*, char*, double, double, 
188
static Rboolean GA_Open(DevDesc*, gadesc*, char*, double, double, 
172
			Rboolean, int);
189
			Rboolean, int, rgb);
173
static void   GA_Polygon(int, double*, double*, int, int, int, DevDesc*);
190
static void   GA_Polygon(int, double*, double*, int, int, int, DevDesc*);
174
static void   GA_Polyline(int, double*, double*, int, DevDesc*);
191
static void   GA_Polyline(int, double*, double*, int, DevDesc*);
175
static void   GA_Rect(double, double, double, double, int, int, int, DevDesc*);
192
static void   GA_Rect(double, double, double, double, int, int, int, DevDesc*);
176
static void   GA_Resize(DevDesc*);
193
static void   GA_Resize(DevDesc*);
177
static double GA_StrWidth(char*, DevDesc*);
194
static double GA_StrWidth(char*, DevDesc*);
Line 189... Line 206...
189
static void SetColor(int, DevDesc *);
206
static void SetColor(int, DevDesc *);
190
static void SetFont(int, int, double, DevDesc *);
207
static void SetFont(int, int, double, DevDesc *);
191
static void SetLinetype(int, double, DevDesc *);
208
static void SetLinetype(int, double, DevDesc *);
192
static int Load_Rbitmap_Dll();
209
static int Load_Rbitmap_Dll();
193
void UnLoad_Rbitmap_Dll();
210
void UnLoad_Rbitmap_Dll();
194
static void SaveAsPng(DevDesc *dd,char *fn);
211
static void SaveAsPng(DevDesc *dd, char *fn);
195
static void SaveAsJpeg(DevDesc *dd,int quality,char *fn);
212
static void SaveAsJpeg(DevDesc *dd, int quality, char *fn);
196
static void SaveAsBmp(DevDesc *dd,char *fn);
213
static void SaveAsBmp(DevDesc *dd, char *fn);
197
static void SaveAsBitmap(DevDesc *dd);
214
static void SaveAsBitmap(DevDesc *dd);
198
 
215
 
199
static void PrivateCopyDevice(DevDesc *dd,DevDesc *ndd, char *name)
216
static void PrivateCopyDevice(DevDesc *dd,DevDesc *ndd, char *name)
200
{
217
{
201
    gadesc *xd = (gadesc *) dd->deviceSpecific;
218
    gadesc *xd = (gadesc *) dd->deviceSpecific;
Line 228... Line 245...
228
    ndd->displayList = R_NilValue;
245
    ndd->displayList = R_NilValue;
229
    GInit(&ndd->dp);
246
    GInit(&ndd->dp);
230
    if (GADeviceDriver(ndd, display,
247
    if (GADeviceDriver(ndd, display,
231
			 GConvertXUnits(1.0, NDC, INCHES, dd),
248
			 GConvertXUnits(1.0, NDC, INCHES, dd),
232
			 GConvertYUnits(1.0, NDC, INCHES, dd),
249
			 GConvertYUnits(1.0, NDC, INCHES, dd),
233
			 dd->gp.ps, 0, 1))
250
			 dd->gp.ps, 0, 1, White))
234
        PrivateCopyDevice(dd, ndd, display);
251
        PrivateCopyDevice(dd, ndd, display);
235
}
252
}
236
 
253
 
237
 
254
 
238
static void SaveAsPostscript(DevDesc *dd, char *fn)
255
static void SaveAsPostscript(DevDesc *dd, char *fn)
Line 257... Line 274...
257
 
274
 
258
    /* Set default values... */
275
    /* Set default values... */
259
    strcpy(family, "Helvetica");
276
    strcpy(family, "Helvetica");
260
    strcpy(encoding, "ISOLatin1.enc");
277
    strcpy(encoding, "ISOLatin1.enc");
261
    strcpy(paper, "default");
278
    strcpy(paper, "default");
262
    strcpy(bg, "white");
279
    strcpy(bg, "transparent");
263
    strcpy(fg, "black");
280
    strcpy(fg, "black");
264
    /* and then try to get it from .PostScript.Options */
281
    /* and then try to get it from .PostScript.Options */
265
    if ((s!=R_UnboundValue) && (s!=R_NilValue)) {
282
    if ((s!=R_UnboundValue) && (s!=R_NilValue)) {
266
	SEXP names = getAttrib(s, R_NamesSymbol);
283
	SEXP names = getAttrib(s, R_NamesSymbol);
267
	int i,done;
284
	int i,done;
Line 313... Line 330...
313
    GInit(&ndd->dp);
330
    GInit(&ndd->dp);
314
 
331
 
315
    /* Set default values... */
332
    /* Set default values... */
316
    strcpy(family, "Helvetica");
333
    strcpy(family, "Helvetica");
317
    strcpy(encoding, "ISOLatin1.enc");
334
    strcpy(encoding, "ISOLatin1.enc");
318
    strcpy(bg, "white");
335
    strcpy(bg, "transparent");
319
    strcpy(fg, "black");
336
    strcpy(fg, "black");
320
    /* and then try to get it from .PostScript.Options */
337
    /* and then try to get it from .PostScript.Options */
321
    if ((s!=R_UnboundValue) && (s!=R_NilValue)) {
338
    if ((s!=R_UnboundValue) && (s!=R_NilValue)) {
322
	SEXP names = getAttrib(s, R_NamesSymbol);
339
	SEXP names = getAttrib(s, R_NamesSymbol);
323
	int i,done;
340
	int i,done;
Line 498... Line 515...
498
}
515
}
499
 
516
 
500
 
517
 
501
static void SetColor(int color, DevDesc *dd)
518
static void SetColor(int color, DevDesc *dd)
502
{
519
{
503
    int   r, g, b;
-
 
504
    gadesc *xd = (gadesc *) dd->deviceSpecific;
520
    gadesc *xd = (gadesc *) dd->deviceSpecific;
505
 
521
 
506
    if (color != xd->col) {
522
    if (color != xd->col) {
507
	/* Gamma Correction */
-
 
508
	/* This is very experimental! */
-
 
509
	xd->col = color;
523
	xd->col = color;
510
	if (dd->gp.gamma != 1) {
-
 
511
	    r = (int) (255 * pow(R_RED(color) / 255.0, dd->gp.gamma));
-
 
512
	    g = (int) (255 * pow(R_GREEN(color) / 255.0, dd->gp.gamma));
-
 
513
	    b = (int) (255 * pow(R_BLUE(color) / 255.0, dd->gp.gamma));
-
 
514
	} else {
-
 
515
	    r = R_RED(color);
-
 
516
	    g = R_GREEN(color);
-
 
517
	    b = R_BLUE(color);
-
 
518
	}
-
 
519
	xd->fgcolor = rgb(r, g, b);
524
	xd->fgcolor = GArgb(color, dd->gp.gamma);
520
    }
525
    }
521
}
526
}
522
 
527
 
523
 
528
 
524
/*
529
/*
Line 1306... Line 1311...
1306
    setdata(m, (void *) dd);
1311
    setdata(m, (void *) dd);
1307
    gchangepopup(xd->gawin, xd->grpopup);
1312
    gchangepopup(xd->gawin, xd->grpopup);
1308
 
1313
 
1309
    MCHECK(xd->bm = newbitmap(getwidth(xd->gawin), getheight(xd->gawin), 
1314
    MCHECK(xd->bm = newbitmap(getwidth(xd->gawin), getheight(xd->gawin), 
1310
			      getdepth(xd->gawin)));
1315
			      getdepth(xd->gawin)));
1311
    gfillrect(xd->gawin, LightGray, getrect(xd->gawin));
1316
    gfillrect(xd->gawin, xd->outcolor, getrect(xd->gawin));
1312
    gfillrect(xd->bm, LightGray, getrect(xd->bm));
1317
    gfillrect(xd->bm, xd->outcolor, getrect(xd->bm));
1313
    addto(xd->gawin);
1318
    addto(xd->gawin);
1314
    setdata(xd->mbar, (void *) dd);
1319
    setdata(xd->mbar, (void *) dd);
1315
    setdata(xd->mpng, (void *) dd);
1320
    setdata(xd->mpng, (void *) dd);
1316
    setdata(xd->mbmp, (void *) dd);
1321
    setdata(xd->mbmp, (void *) dd);
1317
    setdata(xd->mjpeg50, (void *) dd);
1322
    setdata(xd->mjpeg50, (void *) dd);
Line 1349... Line 1354...
1349
 
1354
 
1350
    return 1;
1355
    return 1;
1351
}
1356
}
1352
 
1357
 
1353
static Rboolean GA_Open(DevDesc *dd, gadesc *xd, char *dsp,
1358
static Rboolean GA_Open(DevDesc *dd, gadesc *xd, char *dsp,
1354
			double w, double h, Rboolean recording, int resize)
1359
			double w, double h, Rboolean recording,
-
 
1360
			int resize, rgb canvascolor)
1355
{
1361
{
1356
    rect  rr;
1362
    rect  rr;
1357
 
1363
 
1358
    if (!fontinitdone)
1364
    if (!fontinitdone)
1359
	RFontInit();
1365
	RFontInit();
1360
 
1366
 
1361
    /* Foreground and Background Colors */
1367
    /* Foreground and Background Colors */
1362
    xd->bg = dd->dp.bg = R_RGB(255, 255, 255);
1368
    xd->bg = dd->dp.bg = 0xffffffff; /* transparent */
1363
    xd->fg = dd->dp.fg = R_RGB(0, 0, 0);
1369
    xd->fg = dd->dp.fg = R_RGB(0, 0, 0);
1364
    xd->col = dd->dp.col = xd->fg;
1370
    xd->col = dd->dp.col = xd->fg;
1365
 
1371
 
1366
    xd->fgcolor = Black;
1372
    xd->fgcolor = Black;
1367
    xd->bgcolor = White;
1373
    xd->bgcolor = xd->canvascolor = canvascolor;
-
 
1374
    xd->outcolor = myGetSysColor(COLOR_APPWORKSPACE);
1368
    xd->rescale_factor = 1.0;
1375
    xd->rescale_factor = 1.0;
1369
    xd->fast = 1;  /* Use `cosmetic pens' if available */
1376
    xd->fast = 1;  /* Use `cosmetic pens' if available */
1370
    xd->xshift = xd->yshift = 0;
1377
    xd->xshift = xd->yshift = 0;
1371
    if (!dsp[0]) {
1378
    if (!dsp[0]) {
1372
      if (!setupScreenDevice(dd, xd, w, h, recording, resize)) 
1379
      if (!setupScreenDevice(dd, xd, w, h, recording, resize)) 
Line 1375... Line 1382...
1375
	xd->kind = PRINTER;
1382
	xd->kind = PRINTER;
1376
	xd->gawin = newprinter(MM_PER_INCH * w, MM_PER_INCH * h);
1383
	xd->gawin = newprinter(MM_PER_INCH * w, MM_PER_INCH * h);
1377
	if (!xd->gawin)
1384
	if (!xd->gawin)
1378
	    return FALSE;
1385
	    return FALSE;
1379
    } else if (!strncmp(dsp, "png:", 4) || !strncmp(dsp,"bmp:",4)) {
1386
    } else if (!strncmp(dsp, "png:", 4) || !strncmp(dsp,"bmp:",4)) {
-
 
1387
	xd->bg = dd->dp.bg = R_RGB(255, 255, 255); /* white */
1380
        xd->kind = (dsp[0]=='p') ? PNG : BMP;
1388
        xd->kind = (dsp[0]=='p') ? PNG : BMP;
1381
	if (!Load_Rbitmap_Dll()) {
1389
	if (!Load_Rbitmap_Dll()) {
1382
	    warning("Unable to load Rbitmap.dll");
1390
	    warning("Unable to load Rbitmap.dll");
1383
	    return FALSE;
1391
	    return FALSE;
1384
	}
1392
	}
Line 1601... Line 1609...
1601
	    xd->bm = newbitmap(iw, ih, getdepth(xd->gawin));
1609
	    xd->bm = newbitmap(iw, ih, getdepth(xd->gawin));
1602
	    if (!xd->bm) {
1610
	    if (!xd->bm) {
1603
		R_ShowMessage("Insufficient memory for resize. Killing device");
1611
		R_ShowMessage("Insufficient memory for resize. Killing device");
1604
		KillDevice(dd);
1612
		KillDevice(dd);
1605
	    }
1613
	    }
1606
	    gfillrect(xd->gawin, LightGray, getrect(xd->gawin));
1614
	    gfillrect(xd->gawin, xd->outcolor, getrect(xd->gawin));
1607
	    gfillrect(xd->bm, LightGray, getrect(xd->bm));
1615
	    gfillrect(xd->bm, xd->outcolor, getrect(xd->bm));
1608
	}
1616
	}
1609
    }
1617
    }
1610
}
1618
}
1611
 
1619
 
1612
	/********************************************************/
1620
	/********************************************************/
Line 1637... Line 1645...
1637
	    xd->needsave = FALSE;
1645
	    xd->needsave = FALSE;
1638
	else
1646
	else
1639
	    xd->needsave = TRUE;
1647
	    xd->needsave = TRUE;
1640
    }
1648
    }
1641
    xd->bg = dd->dp.bg;
1649
    xd->bg = dd->dp.bg;
1642
    xd->bgcolor = rgb(R_RED(xd->bg),
1650
    if (!R_OPAQUE(xd->bg)) 
1643
		      R_GREEN(xd->bg),
1651
	xd->bgcolor = xd->canvascolor;
-
 
1652
    else
1644
		      R_BLUE(xd->bg));
1653
	xd->bgcolor = GArgb(xd->bg, dd->gp.gamma);
1645
    if (xd->kind!=SCREEN) {
1654
    if (xd->kind != SCREEN) {
1646
	xd->needsave = TRUE;
1655
	xd->needsave = TRUE;
1647
	xd->clip = getrect(xd->gawin);
1656
	xd->clip = getrect(xd->gawin);
1648
	if(xd->bg != R_RGB(255,255,255))
1657
	if(R_OPAQUE(xd->bg) || xd->kind == PNG || 
-
 
1658
	   xd->kind == BMP || xd->kind == JPEG )
1649
	    DRAW(gfillrect(_d, xd->bgcolor, xd->clip));
1659
	    DRAW(gfillrect(_d, xd->bgcolor, xd->clip));
1650
    } else {
1660
    } else {
1651
	xd->clip = getregion(xd);
1661
	xd->clip = getregion(xd);
1652
	DRAW(gfillrect(_d, xd->bgcolor, xd->clip));
1662
	DRAW(gfillrect(_d, xd->bgcolor, xd->clip));
1653
    }
1663
    }
Line 1766... Line 1776...
1766
	tmp = y0;
1776
	tmp = y0;
1767
	y0 = y1;
1777
	y0 = y1;
1768
	y1 = tmp;
1778
	y1 = tmp;
1769
    }
1779
    }
1770
    r = rect((int) x0, (int) y0, (int) x1 - (int) x0, (int) y1 - (int) y0);
1780
    r = rect((int) x0, (int) y0, (int) x1 - (int) x0, (int) y1 - (int) y0);
1771
    if (bg != NA_INTEGER) {
1781
    if (R_OPAQUE(bg)) {
1772
	SetColor(bg, dd);
1782
	SetColor(bg, dd);
1773
	DRAW(gfillrect(_d, xd->fgcolor, r));
1783
	DRAW(gfillrect(_d, xd->fgcolor, r));
1774
 
1784
 
1775
    }
1785
    }
1776
    if (fg != NA_INTEGER) {
1786
    if (R_OPAQUE(fg)) {
1777
	SetColor(fg, dd);
1787
	SetColor(fg, dd);
1778
	SetLinetype(dd->gp.lty, dd->gp.lwd, dd);
1788
	SetLinetype(dd->gp.lty, dd->gp.lwd, dd);
1779
	DRAW(gdrawrect(_d, xd->lwd, xd->lty, xd->fgcolor, r, 0));
1789
	DRAW(gdrawrect(_d, xd->lwd, xd->lty, xd->fgcolor, r, 0));
1780
    }
1790
    }
1781
}
1791
}
Line 1813... Line 1823...
1813
 
1823
 
1814
    GConvert(&x, &y, coords, DEVICE, dd);
1824
    GConvert(&x, &y, coords, DEVICE, dd);
1815
    ix = (int) x;
1825
    ix = (int) x;
1816
    iy = (int) y;
1826
    iy = (int) y;
1817
    rr = rect(ix - ir, iy - ir, 2 * ir, 2 * ir);
1827
    rr = rect(ix - ir, iy - ir, 2 * ir, 2 * ir);
1818
    if (col != NA_INTEGER) {
1828
    if (R_ALPHA(col)) {
1819
	SetColor(col, dd);
1829
	SetColor(col, dd);
1820
	DRAW(gfillellipse(_d, xd->fgcolor, rr));
1830
	DRAW(gfillellipse(_d, xd->fgcolor, rr));
1821
    }
1831
    }
1822
    if (border != NA_INTEGER) {
1832
    if (R_OPAQUE(border)) {
1823
	SetLinetype(dd->gp.lty, dd->gp.lwd, dd);
1833
	SetLinetype(dd->gp.lty, dd->gp.lwd, dd);
1824
	SetColor(border, dd);
1834
	SetColor(border, dd);
1825
	DRAW(gdrawellipse(_d, xd->lwd, xd->fgcolor, rr, 0));
1835
	DRAW(gdrawellipse(_d, xd->lwd, xd->fgcolor, rr, 0));
1826
    }
1836
    }
1827
}
1837
}
Line 1849... Line 1859...
1849
    xx2 = (int) x2;
1859
    xx2 = (int) x2;
1850
    yy2 = (int) y2;
1860
    yy2 = (int) y2;
1851
 
1861
 
1852
    SetColor(dd->gp.col, dd),
1862
    SetColor(dd->gp.col, dd),
1853
    SetLinetype(dd->gp.lty, dd->gp.lwd, dd);
1863
    SetLinetype(dd->gp.lty, dd->gp.lwd, dd);
-
 
1864
    if (R_OPAQUE(xd->fgcolor))
1854
    DRAW(gdrawline(_d, xd->lwd, xd->lty, xd->fgcolor,
1865
	DRAW(gdrawline(_d, xd->lwd, xd->lty, xd->fgcolor,
1855
		   pt(xx1, yy1), pt(xx2, yy2), 0));
1866
		       pt(xx1, yy1), pt(xx2, yy2), 0));
1856
}
1867
}
1857
 
1868
 
1858
	/********************************************************/
1869
	/********************************************************/
1859
	/* device_Polyline should have the side-effect that a	*/
1870
	/* device_Polyline should have the side-effect that a	*/
1860
	/* series of line segments are drawn using the given x	*/
1871
	/* series of line segments are drawn using the given x	*/
Line 1877... Line 1888...
1877
	devy = y[i];
1888
	devy = y[i];
1878
	GConvert(&devx, &devy, coords, DEVICE, dd);
1889
	GConvert(&devx, &devy, coords, DEVICE, dd);
1879
	p[i].x = (int) devx;
1890
	p[i].x = (int) devx;
1880
	p[i].y = (int) devy;
1891
	p[i].y = (int) devy;
1881
    }
1892
    }
1882
    SetColor(dd->gp.col, dd),
1893
    SetColor(dd->gp.col, dd);
1883
	SetLinetype(dd->gp.lty, dd->gp.lwd, dd);
1894
    SetLinetype(dd->gp.lty, dd->gp.lwd, dd);
-
 
1895
    if (R_OPAQUE(xd->fgcolor))
1884
    DRAW(gdrawpolyline(_d, xd->lwd, xd->lty, xd->fgcolor, p, n, 0, 0));
1896
	DRAW(gdrawpolyline(_d, xd->lwd, xd->lty, xd->fgcolor, p, n, 0, 0));
1885
    vmaxset(vmax);
1897
    vmaxset(vmax);
1886
}
1898
}
1887
 
1899
 
1888
	/********************************************************/
1900
	/********************************************************/
1889
	/* device_Polygon should have the side-effect that a 	*/
1901
	/* device_Polygon should have the side-effect that a 	*/
Line 1915... Line 1927...
1915
	devy = y[i];
1927
	devy = y[i];
1916
	GConvert(&devx, &devy, coords, DEVICE, dd);
1928
	GConvert(&devx, &devy, coords, DEVICE, dd);
1917
	points[i].x = (int) (devx);
1929
	points[i].x = (int) (devx);
1918
	points[i].y = (int) (devy);
1930
	points[i].y = (int) (devy);
1919
    }
1931
    }
1920
    if (bg != NA_INTEGER) {
1932
    if (R_OPAQUE(bg)) {
1921
	SetColor(bg, dd);
1933
	SetColor(bg, dd);
1922
	DRAW(gfillpolygon(_d, xd->fgcolor, points, n));
1934
	DRAW(gfillpolygon(_d, xd->fgcolor, points, n));
1923
    }
1935
    }
1924
    if (fg != NA_INTEGER) {
1936
    if (R_OPAQUE(fg)) {
1925
	SetColor(fg, dd);
1937
	SetColor(fg, dd);
1926
	SetLinetype(dd->gp.lty, dd->gp.lwd, dd);
1938
	SetLinetype(dd->gp.lty, dd->gp.lwd, dd);
1927
	DRAW(gdrawpolygon(_d, xd->lwd, xd->lty, xd->fgcolor, points, n, 0 ));
1939
	DRAW(gdrawpolygon(_d, xd->lwd, xd->lty, xd->fgcolor, points, n, 0 ));
1928
    }
1940
    }
1929
    vmaxset(vmax);
1941
    vmaxset(vmax);
Line 1956... Line 1968...
1956
    rot1 = rot * DEG2RAD;
1968
    rot1 = rot * DEG2RAD;
1957
    x += -xl * cos(rot1) + yl * sin(rot1);
1969
    x += -xl * cos(rot1) + yl * sin(rot1);
1958
    y -= -xl * sin(rot1) - yl * cos(rot1);
1970
    y -= -xl * sin(rot1) - yl * cos(rot1);
1959
    SetFont(dd->gp.font, size, rot, dd);
1971
    SetFont(dd->gp.font, size, rot, dd);
1960
    SetColor(dd->gp.col, dd);
1972
    SetColor(dd->gp.col, dd);
-
 
1973
    if (R_OPAQUE(xd->fgcolor)) {
1961
#ifdef NOCLIPTEXT
1974
#ifdef NOCLIPTEXT
1962
    gsetcliprect(xd->gawin, getrect(xd->gawin));
1975
	gsetcliprect(xd->gawin, getrect(xd->gawin));
1963
    gdrawstr1(xd->gawin, xd->font, xd->fgcolor, pt(x, y), str, hadj);
1976
	gdrawstr1(xd->gawin, xd->font, xd->fgcolor, pt(x, y), str, hadj);
1964
    if (xd->kind==SCREEN) {
1977
	if (xd->kind==SCREEN) {
1965
	gsetcliprect(xd->bm, getrect(xd->bm));
1978
	    gsetcliprect(xd->bm, getrect(xd->bm));
1966
	gdrawstr1(xd->bm, xd->font, xd->fgcolor, pt(x, y), str, hadj);
1979
	    gdrawstr1(xd->bm, xd->font, xd->fgcolor, pt(x, y), str, hadj);
1967
    }
1980
	}
1968
#else
1981
#else
1969
    DRAW(gdrawstr1(_d, xd->font, xd->fgcolor, pt(x, y), str, hadj));
1982
	DRAW(gdrawstr1(_d, xd->font, xd->fgcolor, pt(x, y), str, hadj));
1970
#endif
1983
#endif
-
 
1984
    }
1971
}
1985
}
1972
 
1986
 
1973
	/********************************************************/
1987
	/********************************************************/
1974
	/* device_Locator should return the location of the next*/
1988
	/* device_Locator should return the location of the next*/
1975
	/* mouse click (in DEVICE coordinates;  GLocator is	*/
1989
	/* mouse click (in DEVICE coordinates;  GLocator is	*/
Line 2074... Line 2088...
2074
 
2088
 
2075
 
2089
 
2076
 
2090
 
2077
Rboolean GADeviceDriver(DevDesc *dd, char *display, double width, 
2091
Rboolean GADeviceDriver(DevDesc *dd, char *display, double width, 
2078
			double height, double pointsize, 
2092
			double height, double pointsize, 
2079
			Rboolean recording, int resize)
2093
			Rboolean recording, int resize, int canvas)
2080
{
2094
{
2081
    /* if need to bail out with some sort of "error" then */
2095
    /* if need to bail out with some sort of "error" then */
2082
    /* must free(dd) */
2096
    /* must free(dd) */
2083
 
2097
 
2084
    int   ps;
2098
    int   ps;
Line 2105... Line 2119...
2105
    dd->dp.font = 1;
2119
    dd->dp.font = 1;
2106
    dd->dp.ps = ps;
2120
    dd->dp.ps = ps;
2107
 
2121
 
2108
    /* Start the Device Driver and Hardcopy.  */
2122
    /* Start the Device Driver and Hardcopy.  */
2109
 
2123
 
2110
    if (!GA_Open(dd, xd, display, width, height, recording, resize)) {
2124
    if (!GA_Open(dd, xd, display, width, height, recording, resize,
-
 
2125
		 GArgb(canvas, dd->gp.gamma))) {
2111
	free(xd);
2126
	free(xd);
2112
	return FALSE;
2127
	return FALSE;
2113
    }
2128
    }
2114
    dd->deviceSpecific = (void *) xd;
2129
    dd->deviceSpecific = (void *) xd;
2115
    /* Set up Data Structures  */
2130
    /* Set up Data Structures  */
Line 2228... Line 2243...
2228
    } else if (!strcmp(tp, "wmf")) {
2243
    } else if (!strcmp(tp, "wmf")) {
2229
	sprintf(display, "win.metafile:%s", fn);
2244
	sprintf(display, "win.metafile:%s", fn);
2230
	SaveAsWin(dd, display);
2245
	SaveAsWin(dd, display);
2231
    } else if (!strcmp(tp, "ps")) {
2246
    } else if (!strcmp(tp, "ps")) {
2232
	SaveAsPostscript(dd, fn);
2247
	SaveAsPostscript(dd, fn);
-
 
2248
    } else if (!strcmp(tp, "pdf")) {
-
 
2249
	SaveAsPDF(dd, fn);
2233
    } else
2250
    } else
2234
	errorcall(call, "unknown type");
2251
	errorcall(call, "unknown type");
2235
    return R_NilValue;
2252
    return R_NilValue;
2236
}
2253
}
2237
 
2254
 
Line 2286... Line 2303...
2286
    gadesc *xd = (gadesc *) dd->deviceSpecific;
2303
    gadesc *xd = (gadesc *) dd->deviceSpecific;
2287
    r = ggetcliprect(xd->gawin);
2304
    r = ggetcliprect(xd->gawin);
2288
    gsetcliprect(xd->gawin, getrect(xd->gawin));
2305
    gsetcliprect(xd->gawin, getrect(xd->gawin));
2289
    if (xd->kind==PNG) 
2306
    if (xd->kind==PNG) 
2290
	R_SaveAsPng(xd->gawin, xd->windowWidth, xd->windowHeight,
2307
	R_SaveAsPng(xd->gawin, xd->windowWidth, xd->windowHeight,
2291
		    privategetpixel, 0, xd->fp) ;
2308
		    privategetpixel, 0, xd->fp,
-
 
2309
		    R_OPAQUE(xd->bg) ? 0 : xd->canvascolor) ;
2292
    else if (xd->kind==JPEG)
2310
    else if (xd->kind==JPEG)
2293
	R_SaveAsJpeg(xd->gawin, xd->windowWidth, xd->windowHeight,
2311
	R_SaveAsJpeg(xd->gawin, xd->windowWidth, xd->windowHeight,
2294
		     privategetpixel, 0, xd->quality, xd->fp) ;
2312
		     privategetpixel, 0, xd->quality, xd->fp) ;
2295
    else 
2313
    else 
2296
	R_SaveAsBmp(xd->gawin, xd->windowWidth, xd->windowHeight,
2314
	R_SaveAsBmp(xd->gawin, xd->windowWidth, xd->windowHeight,
Line 2307... Line 2325...
2307
    gadesc *xd = (gadesc *) dd->deviceSpecific;
2325
    gadesc *xd = (gadesc *) dd->deviceSpecific;
2308
    if (!Load_Rbitmap_Dll()) {
2326
    if (!Load_Rbitmap_Dll()) {
2309
	R_ShowMessage("Impossible to load Rbitmap.dll");
2327
	R_ShowMessage("Impossible to load Rbitmap.dll");
2310
	return;
2328
	return;
2311
    }
2329
    }
2312
    if ((fp=fopen(fn,"wb")) == NULL) {
2330
    if ((fp=fopen(fn, "wb")) == NULL) {
2313
	char msg[MAX_PATH+32];
2331
	char msg[MAX_PATH+32];
2314
 
2332
 
2315
	strcpy(msg,"Impossible to open ");
2333
	strcpy(msg, "Impossible to open ");
2316
	strncat(msg, fn, MAX_PATH);
2334
	strncat(msg, fn, MAX_PATH);
2317
	R_ShowMessage(msg);
2335
	R_ShowMessage(msg);
2318
	return;
2336
	return;
2319
    }
2337
    }
2320
    r = ggetcliprect(xd->bm);
2338
    r = ggetcliprect(xd->bm);
2321
    gsetcliprect(xd->bm, getrect(xd->bm));
2339
    gsetcliprect(xd->bm, getrect(xd->bm));
2322
    R_SaveAsPng(xd->bm, xd->windowWidth, xd->windowHeight,
2340
    R_SaveAsPng(xd->bm, xd->windowWidth, xd->windowHeight,
2323
		privategetpixel, 0, fp) ;
2341
		privategetpixel, 0, fp, 0) ;
-
 
2342
    /* R_OPAQUE(xd->bg) ? 0 : xd->canvascolor) ; */
2324
    gsetcliprect(xd->bm, r);
2343
    gsetcliprect(xd->bm, r);
2325
    fclose(fp);
2344
    fclose(fp);
2326
}
2345
}
2327
 
2346
 
2328
static void SaveAsJpeg(DevDesc *dd,int quality,char *fn)
2347
static void SaveAsJpeg(DevDesc *dd,int quality,char *fn)