The R Project SVN R

Rev

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

Rev 15657 Rev 16137
Line 38... Line 38...
38
#include "windows.h"
38
#include "windows.h"
39
 
39
 
40
extern console RConsole;
40
extern console RConsole;
41
extern Rboolean AllDevicesKilled;
41
extern Rboolean AllDevicesKilled;
42
 
42
 
-
 
43
/* a colour used to represent the background on png if transparent
-
 
44
   NB: must be grey as used as RGB and BGR
-
 
45
*/
-
 
46
#define PNG_TRANS 0xfefefe
-
 
47
 
43
/* these really are globals: per machine, not per window */
48
/* these really are globals: per machine, not per window */
44
static double user_xpinch = 0.0, user_ypinch = 0.0;
49
static double user_xpinch = 0.0, user_ypinch = 0.0;
45
 
50
 
46
void GAsetunits(double xpinch, double ypinch)
51
void GAsetunits(double xpinch, double ypinch)
47
{
52
{
Line 184... Line 189...
184
static void   GA_Line(double, double, double, double, int, DevDesc*);
189
static void   GA_Line(double, double, double, double, int, DevDesc*);
185
static Rboolean GA_Locator(double*, double*, DevDesc*);
190
static Rboolean GA_Locator(double*, double*, DevDesc*);
186
static void   GA_Mode(int);
191
static void   GA_Mode(int);
187
static void   GA_NewPage(DevDesc*);
192
static void   GA_NewPage(DevDesc*);
188
static Rboolean GA_Open(DevDesc*, gadesc*, char*, double, double, 
193
static Rboolean GA_Open(DevDesc*, gadesc*, char*, double, double, 
189
			Rboolean, int, rgb);
194
			Rboolean, int, int);
190
static void   GA_Polygon(int, double*, double*, int, int, int, DevDesc*);
195
static void   GA_Polygon(int, double*, double*, int, int, int, DevDesc*);
191
static void   GA_Polyline(int, double*, double*, int, DevDesc*);
196
static void   GA_Polyline(int, double*, double*, int, DevDesc*);
192
static void   GA_Rect(double, double, double, double, int, int, int, DevDesc*);
197
static void   GA_Rect(double, double, double, double, int, int, int, DevDesc*);
193
static void   GA_Resize(DevDesc*);
198
static void   GA_Resize(DevDesc*);
194
static double GA_StrWidth(char*, DevDesc*);
199
static double GA_StrWidth(char*, DevDesc*);
Line 1355... Line 1360...
1355
    return 1;
1360
    return 1;
1356
}
1361
}
1357
 
1362
 
1358
static Rboolean GA_Open(DevDesc *dd, gadesc *xd, char *dsp,
1363
static Rboolean GA_Open(DevDesc *dd, gadesc *xd, char *dsp,
1359
			double w, double h, Rboolean recording,
1364
			double w, double h, Rboolean recording,
1360
			int resize, rgb canvascolor)
1365
			int resize, int canvascolor)
1361
{
1366
{
1362
    rect  rr;
1367
    rect  rr;
1363
 
1368
 
1364
    if (!fontinitdone)
1369
    if (!fontinitdone)
1365
	RFontInit();
1370
	RFontInit();
Line 1368... Line 1373...
1368
    xd->bg = dd->dp.bg = 0xffffffff; /* transparent */
1373
    xd->bg = dd->dp.bg = 0xffffffff; /* transparent */
1369
    xd->fg = dd->dp.fg = R_RGB(0, 0, 0);
1374
    xd->fg = dd->dp.fg = R_RGB(0, 0, 0);
1370
    xd->col = dd->dp.col = xd->fg;
1375
    xd->col = dd->dp.col = xd->fg;
1371
 
1376
 
1372
    xd->fgcolor = Black;
1377
    xd->fgcolor = Black;
1373
    xd->bgcolor = xd->canvascolor = canvascolor;
1378
    xd->bgcolor = xd->canvascolor = GArgb(canvascolor, 1.0);
1374
    xd->outcolor = myGetSysColor(COLOR_APPWORKSPACE);
1379
    xd->outcolor = myGetSysColor(COLOR_APPWORKSPACE);
1375
    xd->rescale_factor = 1.0;
1380
    xd->rescale_factor = 1.0;
1376
    xd->fast = 1;  /* Use `cosmetic pens' if available */
1381
    xd->fast = 1;  /* Use `cosmetic pens' if available */
1377
    xd->xshift = xd->yshift = 0;
1382
    xd->xshift = xd->yshift = 0;
1378
    if (!dsp[0]) {
1383
    if (!dsp[0]) {
Line 1381... Line 1386...
1381
    } else if (!strcmp(dsp, "win.print")) {
1386
    } else if (!strcmp(dsp, "win.print")) {
1382
	xd->kind = PRINTER;
1387
	xd->kind = PRINTER;
1383
	xd->gawin = newprinter(MM_PER_INCH * w, MM_PER_INCH * h);
1388
	xd->gawin = newprinter(MM_PER_INCH * w, MM_PER_INCH * h);
1384
	if (!xd->gawin)
1389
	if (!xd->gawin)
1385
	    return FALSE;
1390
	    return FALSE;
1386
    } else if (!strncmp(dsp, "png:", 4) || !strncmp(dsp,"bmp:",4)) {
1391
    } else if (!strncmp(dsp, "png:", 4) || !strncmp(dsp,"bmp:", 4)) {
-
 
1392
	if(R_OPAQUE(canvascolor))
-
 
1393
	    xd->bg = dd->dp.bg = GArgb(canvascolor, 1.0);
-
 
1394
	else
-
 
1395
	    xd->bg = dd->dp.bg = canvascolor;
1387
	xd->bg = dd->dp.bg = R_RGB(255, 255, 255); /* white */
1396
	/* was R_RGB(255, 255, 255); white */
1388
        xd->kind = (dsp[0]=='p') ? PNG : BMP;
1397
        xd->kind = (dsp[0]=='p') ? PNG : BMP;
1389
	if (!Load_Rbitmap_Dll()) {
1398
	if (!Load_Rbitmap_Dll()) {
1390
	    warning("Unable to load Rbitmap.dll");
1399
	    warning("Unable to load Rbitmap.dll");
1391
	    return FALSE;
1400
	    return FALSE;
1392
	}
1401
	}
Line 1404... Line 1413...
1404
	    warning("Unable to open file `%s' for writing", &dsp[4]);
1413
	    warning("Unable to open file `%s' for writing", &dsp[4]);
1405
	    return FALSE;
1414
	    return FALSE;
1406
	}
1415
	}
1407
    } else if (!strncmp(dsp, "jpeg:", 5)) {
1416
    } else if (!strncmp(dsp, "jpeg:", 5)) {
1408
        char *p = strchr(&dsp[5], ':');
1417
        char *p = strchr(&dsp[5], ':');
-
 
1418
	xd->bg = dd->dp.bg = GArgb(canvascolor, 1.0);
1409
        xd->kind = JPEG;
1419
        xd->kind = JPEG;
1410
	if (!p) return FALSE;
1420
	if (!p) return FALSE;
1411
	if (!Load_Rbitmap_Dll()) {
1421
	if (!Load_Rbitmap_Dll()) {
1412
	    warning("Unable to load Rbitmap.dll");
1422
	    warning("Unable to load Rbitmap.dll");
1413
	    return FALSE;
1423
	    return FALSE;
Line 1654... Line 1664...
1654
    if (xd->kind != SCREEN) {
1664
    if (xd->kind != SCREEN) {
1655
	xd->needsave = TRUE;
1665
	xd->needsave = TRUE;
1656
	xd->clip = getrect(xd->gawin);
1666
	xd->clip = getrect(xd->gawin);
1657
	if(R_OPAQUE(xd->bg) || xd->kind == PNG || 
1667
	if(R_OPAQUE(xd->bg) || xd->kind == PNG || 
1658
	   xd->kind == BMP || xd->kind == JPEG )
1668
	   xd->kind == BMP || xd->kind == JPEG )
1659
	    DRAW(gfillrect(_d, xd->bgcolor, xd->clip));
1669
	    DRAW(gfillrect(_d, R_OPAQUE(xd->bg) ? xd->bgcolor : PNG_TRANS, 
-
 
1670
			   xd->clip));
1660
    } else {
1671
    } else {
1661
	xd->clip = getregion(xd);
1672
	xd->clip = getregion(xd);
1662
	DRAW(gfillrect(_d, xd->bgcolor, xd->clip));
1673
	DRAW(gfillrect(_d, xd->bgcolor, xd->clip));
1663
    }
1674
    }
1664
}
1675
}
Line 2119... Line 2130...
2119
    dd->dp.font = 1;
2130
    dd->dp.font = 1;
2120
    dd->dp.ps = ps;
2131
    dd->dp.ps = ps;
2121
 
2132
 
2122
    /* Start the Device Driver and Hardcopy.  */
2133
    /* Start the Device Driver and Hardcopy.  */
2123
 
2134
 
2124
    if (!GA_Open(dd, xd, display, width, height, recording, resize,
2135
    if (!GA_Open(dd, xd, display, width, height, recording, resize, canvas)) {
2125
		 GArgb(canvas, 1.0))) {
-
 
2126
	free(xd);
2136
	free(xd);
2127
	return FALSE;
2137
	return FALSE;
2128
    }
2138
    }
2129
    dd->deviceSpecific = (void *) xd;
2139
    dd->deviceSpecific = (void *) xd;
2130
    /* Set up Data Structures  */
2140
    /* Set up Data Structures  */
Line 2304... Line 2314...
2304
    r = ggetcliprect(xd->gawin);
2314
    r = ggetcliprect(xd->gawin);
2305
    gsetcliprect(xd->gawin, getrect(xd->gawin));
2315
    gsetcliprect(xd->gawin, getrect(xd->gawin));
2306
    if (xd->kind==PNG) 
2316
    if (xd->kind==PNG) 
2307
	R_SaveAsPng(xd->gawin, xd->windowWidth, xd->windowHeight,
2317
	R_SaveAsPng(xd->gawin, xd->windowWidth, xd->windowHeight,
2308
		    privategetpixel, 0, xd->fp,
2318
		    privategetpixel, 0, xd->fp,
2309
		    R_OPAQUE(xd->bg) ? 0 : xd->canvascolor) ;
2319
		    R_OPAQUE(xd->bg) ? 0 : PNG_TRANS) ;
2310
    else if (xd->kind==JPEG)
2320
    else if (xd->kind==JPEG)
2311
	R_SaveAsJpeg(xd->gawin, xd->windowWidth, xd->windowHeight,
2321
	R_SaveAsJpeg(xd->gawin, xd->windowWidth, xd->windowHeight,
2312
		     privategetpixel, 0, xd->quality, xd->fp) ;
2322
		     privategetpixel, 0, xd->quality, xd->fp) ;
2313
    else 
2323
    else 
2314
	R_SaveAsBmp(xd->gawin, xd->windowWidth, xd->windowHeight,
2324
	R_SaveAsBmp(xd->gawin, xd->windowWidth, xd->windowHeight,