From ripley at stats.ox.ac.uk  Fri Feb 10 20:37:19 2017
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Fri, 10 Feb 2017 19:37:19 +0000
Subject: [Rd] Grapics Device Resolution Limits
In-Reply-To: <37d1d5c0-17c0-38bb-c3bf-d5cc09920769@stats.ox.ac.uk>
References: <MWHPR01MB27011180C046283EE5E82B44CD440@MWHPR01MB2701.prod.exchangelabs.com>
	<22685.61492.113047.478744@stat.math.ethz.ch>
	<37d1d5c0-17c0-38bb-c3bf-d5cc09920769@stats.ox.ac.uk>
Message-ID: <16afdf42-2d7b-c483-8da1-0f27fb17dc2f@stats.ox.ac.uk>

On 10/02/2017 19:27, Prof Brian Ripley wrote:
> Note that there are at least 5 separate png() devices, so Linux was not
> using the (default) device used on Windows.
>
> In general, the device-limits info is not on the help page because we do
> not know it.  On Windows the default device limits depend on the OS
> version, 32/64-bit, RAM and the graphics hardware.  This sounds like the
> last: you were asking for 49 megapixels which is far larger than the
> largest screens.  (Or all but the highest-end digital cameras, so one
> could well ask what you can usefully do with such an image.)

Scratch that: res is in ppi so the image should be 2755px square: still 
rather large.

> Normally you will get warning(s) accompanying that Error, but it might
> just be
>
> Warning: unable to allocate bitmap
> Warning: opening device failed
>
> The first of those is reporting what the GraphApp toolkit said, talking
> directly to Windows GDI (and look at the Windows documentation for e.g.
> CreateCompatibleBitmap to see that no limits are mentioned).
>
>
> Even on Windows you have the option of using other png() devices:
>
> png(filename = "Rplot03d.png",
>     width = 480, height = 480, units = "px", pointsize = 12,
>     bg = "white", res = NA, family = "", restoreConsole = TRUE,
>     type = c("windows", "cairo", "cairo-png"), antialias)
>
> Try the other 2 types: the cairo devices do not use your graphics
> hardware nor MicroSoft's GDI. (The other 2 devices are Xlib on a
> Unix-alike and Quartz on macOS.)
>
>
> On 10/02/2017 16:54, Martin Maechler wrote:
>>>>>>> Dario Strbenac <dstr7320 at uni.sydney.edu.au>
>>>>>>>     on Fri, 10 Feb 2017 02:00:08 +0000 writes:
>>
>>     > Good day,
>>     > Could the documentation of graphics devices give some
>> explanation of how big the bitmap limits are? For example,
>>
>>     >> png("Figure1A.png", h = 7, w = 7, res = 1000, units = "cm")
>>
>>     > Results in Error: unable to start png() device,
>>
>> This is amazing to me.  I see
>>
>> ------------------------------------------------------------------------------
>>
>>> png("Figure1A.png", h = 7, w = 7, res = 1000, units = "cm")
>>> plot(1)
>>> dev.off()
>> null device
>>           1
>>> file.info("Figure1A.png")[1:5]
>>               size isdir mode               mtime               ctime
>> Figure1A.png 41272 FALSE  644 2017-02-10 17:40:42 2017-02-10 17:40:42
>>>
>> ------------------------------------------------------------------------------
>>
>>
>> in three different versions of R I've tried (all were 64-bit Linux).
>> Note how *small* the file is.
>> Now, I've also tried a 32-bit version of Linux (Ubuntu 14.04 LTS) and get
>> a similar result (not exactly the same number of bytes for the file
>> size).
>>
>>
>>> but the help page of devices doesn't explain that there are any
>>> limits or how they are determined. The wording of the error message
>>> could also be improved, to explain that the resolution is too high or
>>> the dimensions are too large.
>>
>> If one/some of those who can reproduce the problem in their
>> versions of R  provide (concise and not hard to read) patches to
>> the source of R, we'd probably gratefully accept them..
>>
>> Martin Maechler
>>
>>     >> sessionInfo()
>>     > R version 3.3.2 Patched (2017-02-07 r72138)
>>     > Platform: i386-w64-mingw32/i386 (32-bit)
>>     > Running under: Windows 7 (build 7601) Service Pack 1
>>
>>     > --------------------------------------
>>     > Dario Strbenac
>>     > University of Sydney
>>     > Camperdown NSW 2050
>>     > Australia
>


-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Emeritus Professor of Applied Statistics, University of Oxford



[Rd] Grapics Device Resolution Limits
Prof Brian Ripley