time | calls | line |
---|
| | 1 | function tooBig = checkImageSizeForPrint(dpi, screenDPI, width, height)
|
| | 2 | % CHECKIMAGESIZEFORPRINT Checks to see if the image that will be
|
| | 3 | % produced in the print path is within certain bounds. This
|
| | 4 | % undocumented helper function is for internal use.
|
| | 5 |
|
| | 6 | % This function is called during the print path. See usage in
|
| | 7 | % alternatePrintPath.m
|
| | 8 |
|
| | 9 | % Predict how big the image data will be based on the requested
|
| | 10 | % resolution and image size. Returns true if the image size is greater
|
| | 11 | % than the limit in imwrite.
|
| | 12 |
|
| | 13 | % Copyright 2013 The MathWorks, Inc.
|
| | 14 |
|
| 3 | 15 | tooBig = false;
|
| 3 | 16 | scaleFactor = dpi/screenDPI;
|
| 3 | 17 | expectedWidth = width*scaleFactor;
|
| 3 | 18 | expectedHeight = height*scaleFactor;
|
| | 19 |
|
| | 20 | % Like imwrite, validate that the dataset/image will fit within 32-bit
|
| | 21 | % offsets.
|
0.01 | 3 | 22 | max32 = double(intmax('uint32'));
|
| | 23 |
|
| | 24 | % If one of the dimensions is larger than max32, or if the number of
|
| | 25 | % elements in the data (width*height*3 for RGB data) is larger than
|
| | 26 | % max32, then we won't be able to write this image out using imwrite.
|
| 3 | 27 | if expectedWidth > max32 || expectedHeight > max32
|
| | 28 | tooBig = true;
|
| 3 | 29 | elseif ((expectedWidth * expectedHeight * 3) > max32)
|
| | 30 | tooBig = true;
|
| | 31 | end
|
| 3 | 32 | end
|